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
a3695cc6
Commit
a3695cc6
authored
Nov 05, 2021
by
topjohnwu
Committed by
John Wu
Nov 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Kotlin coroutine instead of Java parallelStream
parent
6723d206
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
DenyListViewModel.kt
...in/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
+12
-10
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
View file @
a3695cc6
...
@@ -13,10 +13,10 @@ import com.topjohnwu.magisk.databinding.itemBindingOf
...
@@ -13,10 +13,10 @@ import com.topjohnwu.magisk.databinding.itemBindingOf
import
com.topjohnwu.magisk.di.AppContext
import
com.topjohnwu.magisk.di.AppContext
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
kotlinx.coroutines.
Dispatchers
import
kotlinx.coroutines.
*
import
kotlinx.coroutines.
launch
import
kotlinx.coroutines.
flow.*
import
kotlinx.coroutines.withContext
import
java.util.*
import
java.util.stream.Collectors
import
kotlin.collections.ArrayList
class
DenyListViewModel
:
BaseViewModel
(),
Queryable
{
class
DenyListViewModel
:
BaseViewModel
(),
Queryable
{
...
@@ -55,17 +55,19 @@ class DenyListViewModel : BaseViewModel(), Queryable {
...
@@ -55,17 +55,19 @@ class DenyListViewModel : BaseViewModel(), Queryable {
return
@launch
return
@launch
}
}
state
=
State
.
LOADING
state
=
State
.
LOADING
val
(
apps
,
diff
)
=
withContext
(
Dispatchers
.
Default
)
{
val
(
apps
,
diff
)
=
withContext
(
Dispatchers
.
IO
)
{
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
).
parallelStream
()
val
apps
=
pm
.
getInstalledApplications
(
MATCH_UNINSTALLED_PACKAGES
).
asFlow
()
.
filter
{
AppContext
.
packageName
!=
it
.
packageName
}
.
filter
{
AppContext
.
packageName
!=
it
.
packageName
}
.
map
{
AppProcessInfo
(
it
,
pm
,
denyList
)
}
.
map
{
async
{
AppProcessInfo
(
it
,
pm
,
denyList
)
}
}
.
map
{
it
.
await
()
}
.
filter
{
it
.
processes
.
isNotEmpty
()
}
.
filter
{
it
.
processes
.
isNotEmpty
()
}
.
map
{
DenyListRvItem
(
it
)
}
.
map
{
async
{
DenyListRvItem
(
it
)
}
}
.
sorted
()
.
map
{
it
.
await
()
}
.
collect
(
Collectors
.
toList
())
.
toCollection
(
ArrayList
())
apps
.
sort
()
apps
to
items
.
calculateDiff
(
apps
)
apps
to
items
.
calculateDiff
(
apps
)
}
}
items
.
update
(
apps
,
diff
)
items
.
update
(
apps
,
diff
)
...
...
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