Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
a2a3c7f4
Commit
a2a3c7f4
authored
May 03, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collect both STDOUT and STDERR for logs
parent
4496f82d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
FlashViewModel.kt
...main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt
+21
-17
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt
View file @
a2a3c7f4
...
@@ -24,6 +24,8 @@ import com.topjohnwu.magisk.utils.*
...
@@ -24,6 +24,8 @@ import com.topjohnwu.magisk.utils.*
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
me.tatarka.bindingcollectionadapter2.ItemBinding
import
me.tatarka.bindingcollectionadapter2.ItemBinding
import
java.io.File
import
java.io.File
import
java.util.Collections
import
kotlin.collections.ArrayList
class
FlashViewModel
(
class
FlashViewModel
(
action
:
String
,
action
:
String
,
...
@@ -42,30 +44,36 @@ class FlashViewModel(
...
@@ -42,30 +44,36 @@ class FlashViewModel(
itemBinding
.
bindExtra
(
BR
.
viewModel
,
this
@FlashViewModel
)
itemBinding
.
bindExtra
(
BR
.
viewModel
,
this
@FlashViewModel
)
}
}
private
val
rawItems
=
ObservableArrayList
<
String
>()
private
val
outItems
=
object
:
ObservableArrayList
<
String
>()
{
private
val
logItems
=
ObservableArrayList
<
String
>()
override
fun
add
(
element
:
String
?):
Boolean
{
if
(
element
!=
null
)
logItems
.
add
(
element
)
return
super
.
add
(
element
)
}
}
private
val
logItems
=
Collections
.
synchronizedList
(
ArrayList
<
String
>())
init
{
init
{
raw
Items
.
sendUpdatesTo
(
items
)
{
it
.
map
{
ConsoleRvItem
(
it
)
}
}
out
Items
.
sendUpdatesTo
(
items
)
{
it
.
map
{
ConsoleRvItem
(
it
)
}
}
state
=
State
.
LOADING
state
=
State
.
LOADING
val
uri
=
uri
?:
Uri
.
EMPTY
val
uri
=
uri
?:
Uri
.
EMPTY
when
(
action
)
{
when
(
action
)
{
Const
.
Value
.
FLASH_ZIP
->
Flashing
Const
.
Value
.
FLASH_ZIP
->
Flashing
.
Install
(
uri
,
raw
Items
,
logItems
,
this
)
.
Install
(
uri
,
out
Items
,
logItems
,
this
)
.
exec
()
.
exec
()
Const
.
Value
.
UNINSTALL
->
Flashing
Const
.
Value
.
UNINSTALL
->
Flashing
.
Uninstall
(
uri
,
raw
Items
,
logItems
,
this
)
.
Uninstall
(
uri
,
out
Items
,
logItems
,
this
)
.
exec
()
.
exec
()
Const
.
Value
.
FLASH_MAGISK
->
Patching
Const
.
Value
.
FLASH_MAGISK
->
Patching
.
Direct
(
raw
Items
,
logItems
,
this
)
.
Direct
(
out
Items
,
logItems
,
this
)
.
exec
()
.
exec
()
Const
.
Value
.
FLASH_INACTIVE_SLOT
->
Patching
Const
.
Value
.
FLASH_INACTIVE_SLOT
->
Patching
.
SecondSlot
(
raw
Items
,
logItems
,
this
)
.
SecondSlot
(
out
Items
,
logItems
,
this
)
.
exec
()
.
exec
()
Const
.
Value
.
PATCH_FILE
->
Patching
Const
.
Value
.
PATCH_FILE
->
Patching
.
File
(
uri
,
raw
Items
,
logItems
,
this
)
.
File
(
uri
,
out
Items
,
logItems
,
this
)
.
exec
()
.
exec
()
}
}
}
}
...
@@ -90,16 +98,12 @@ class FlashViewModel(
...
@@ -90,16 +98,12 @@ class FlashViewModel(
.
map
{
Const
.
MAGISK_INSTALL_LOG_FILENAME
.
format
(
it
)
}
.
map
{
Const
.
MAGISK_INSTALL_LOG_FILENAME
.
format
(
it
)
}
.
map
{
File
(
Const
.
EXTERNAL_PATH
,
it
)
}
.
map
{
File
(
Const
.
EXTERNAL_PATH
,
it
)
}
.
map
{
file
->
.
map
{
file
->
val
log
=
items
.
filterIsInstance
<
ConsoleRvItem
>()
file
.
bufferedWriter
().
use
{
writer
->
.
joinToString
(
"\n"
)
{
it
.
item
}
logItems
.
forEach
{
file
.
writeText
(
log
)
writer
.
write
(
it
)
writer
.
newLine
()
val
rawLog
=
logItems
.
toList
().
joinToString
(
"\n"
)
}
if
(
rawLog
.
isNotBlank
())
{
file
.
appendText
(
"\n=== LOG ===\n"
)
file
.
appendText
(
rawLog
)
}
}
file
.
path
file
.
path
}
}
.
subscribeK
{
SnackbarEvent
(
it
).
publish
()
}
.
subscribeK
{
SnackbarEvent
(
it
).
publish
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment