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
Show 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.*
import
com.topjohnwu.superuser.Shell
import
me.tatarka.bindingcollectionadapter2.ItemBinding
import
java.io.File
import
java.util.Collections
import
kotlin.collections.ArrayList
class
FlashViewModel
(
action
:
String
,
...
...
@@ -42,30 +44,36 @@ class FlashViewModel(
itemBinding
.
bindExtra
(
BR
.
viewModel
,
this
@FlashViewModel
)
}
private
val
rawItems
=
ObservableArrayList
<
String
>()
private
val
logItems
=
ObservableArrayList
<
String
>()
private
val
outItems
=
object
:
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
{
raw
Items
.
sendUpdatesTo
(
items
)
{
it
.
map
{
ConsoleRvItem
(
it
)
}
}
out
Items
.
sendUpdatesTo
(
items
)
{
it
.
map
{
ConsoleRvItem
(
it
)
}
}
state
=
State
.
LOADING
val
uri
=
uri
?:
Uri
.
EMPTY
when
(
action
)
{
Const
.
Value
.
FLASH_ZIP
->
Flashing
.
Install
(
uri
,
raw
Items
,
logItems
,
this
)
.
Install
(
uri
,
out
Items
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
UNINSTALL
->
Flashing
.
Uninstall
(
uri
,
raw
Items
,
logItems
,
this
)
.
Uninstall
(
uri
,
out
Items
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
FLASH_MAGISK
->
Patching
.
Direct
(
raw
Items
,
logItems
,
this
)
.
Direct
(
out
Items
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
FLASH_INACTIVE_SLOT
->
Patching
.
SecondSlot
(
raw
Items
,
logItems
,
this
)
.
SecondSlot
(
out
Items
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
PATCH_FILE
->
Patching
.
File
(
uri
,
raw
Items
,
logItems
,
this
)
.
File
(
uri
,
out
Items
,
logItems
,
this
)
.
exec
()
}
}
...
...
@@ -90,16 +98,12 @@ class FlashViewModel(
.
map
{
Const
.
MAGISK_INSTALL_LOG_FILENAME
.
format
(
it
)
}
.
map
{
File
(
Const
.
EXTERNAL_PATH
,
it
)
}
.
map
{
file
->
val
log
=
items
.
filterIsInstance
<
ConsoleRvItem
>()
.
joinToString
(
"\n"
)
{
it
.
item
}
file
.
writeText
(
log
)
val
rawLog
=
logItems
.
toList
().
joinToString
(
"\n"
)
if
(
rawLog
.
isNotBlank
())
{
file
.
appendText
(
"\n=== LOG ===\n"
)
file
.
appendText
(
rawLog
)
file
.
bufferedWriter
().
use
{
writer
->
logItems
.
forEach
{
writer
.
write
(
it
)
writer
.
newLine
()
}
}
file
.
path
}
.
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