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
b6affe06
Commit
b6affe06
authored
Nov 12, 2021
by
LoveSy
Committed by
John Wu
Nov 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix flow parallel
parent
1e05f8c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
DenyListViewModel.kt
...in/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
+17
-9
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
View file @
b6affe06
...
@@ -46,6 +46,14 @@ class DenyListViewModel : BaseViewModel(), Queryable {
...
@@ -46,6 +46,14 @@ class DenyListViewModel : BaseViewModel(), Queryable {
it
.
bindExtra
(
BR
.
viewModel
,
this
)
it
.
bindExtra
(
BR
.
viewModel
,
this
)
}
}
@FlowPreview
private
inline
fun
<
T
,
R
>
Flow
<
T
>.
concurrentMap
(
crossinline
transform
:
suspend
(
T
)
->
R
):
Flow
<
R
>
{
return
flatMapMerge
{
value
->
flow
{
emit
(
transform
(
value
))
}
}
}
@FlowPreview
@SuppressLint
(
"InlinedApi"
)
@SuppressLint
(
"InlinedApi"
)
override
fun
refresh
()
=
viewModelScope
.
launch
{
override
fun
refresh
()
=
viewModelScope
.
launch
{
if
(!
Utils
.
showSuperUser
())
{
if
(!
Utils
.
showSuperUser
())
{
...
@@ -53,18 +61,18 @@ class DenyListViewModel : BaseViewModel(), Queryable {
...
@@ -53,18 +61,18 @@ class DenyListViewModel : BaseViewModel(), Queryable {
return
@launch
return
@launch
}
}
state
=
State
.
LOADING
state
=
State
.
LOADING
val
(
apps
,
diff
)
=
withContext
(
Dispatchers
.
IO
)
{
val
(
apps
,
diff
)
=
withContext
(
Dispatchers
.
Default
)
{
val
pm
=
AppContext
.
packageManager
val
pm
=
AppContext
.
packageManager
val
denyList
=
Shell
.
su
(
"magisk --denylist ls"
).
exec
().
out
val
denyList
=
Shell
.
su
(
"magisk --denylist ls"
).
exec
().
out
.
map
{
CmdlineListItem
(
it
)
}
.
map
{
CmdlineListItem
(
it
)
}
val
apps
=
pm
.
getInstalledApplications
(
MATCH_UNINSTALLED_PACKAGES
).
asFlow
()
val
apps
=
pm
.
getInstalledApplications
(
MATCH_UNINSTALLED_PACKAGES
).
run
{
asFlow
()
.
filter
{
AppContext
.
packageName
!=
it
.
packageName
}
.
filter
{
AppContext
.
packageName
!=
it
.
packageName
}
.
map
{
async
{
AppProcessInfo
(
it
,
pm
,
denyList
)
}
}
.
concurrentMap
{
AppProcessInfo
(
it
,
pm
,
denyList
)
}
.
map
{
it
.
await
()
}
.
filter
{
it
.
processes
.
isNotEmpty
()
}
.
filter
{
it
.
processes
.
isNotEmpty
()
}
.
map
{
async
{
DenyListRvItem
(
it
)
}
}
.
concurrentMap
{
DenyListRvItem
(
it
)
}
.
map
{
it
.
await
()
}
.
toCollection
(
ArrayList
(
size
))
.
toCollection
(
ArrayList
())
}
apps
.
sort
()
apps
.
sort
()
apps
to
items
.
calculateDiff
(
apps
)
apps
to
items
.
calculateDiff
(
apps
)
}
}
...
...
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