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
3d3bfb42
Commit
3d3bfb42
authored
Nov 07, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't copy ApplicationInfo
parent
6dbd8baa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
24 deletions
+21
-24
AppProcessInfo.kt
.../main/java/com/topjohnwu/magisk/ui/deny/AppProcessInfo.kt
+19
-13
DenyListViewModel.kt
...in/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
+2
-11
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/deny/AppProcessInfo.kt
View file @
3d3bfb42
...
...
@@ -8,6 +8,7 @@ import android.content.pm.PackageManager.*
import
android.content.pm.ServiceInfo
import
android.graphics.drawable.Drawable
import
android.os.Build.VERSION.SDK_INT
import
android.os.Process
import
com.topjohnwu.magisk.core.utils.currentLocale
import
com.topjohnwu.magisk.ktx.getLabel
import
java.util.*
...
...
@@ -27,22 +28,27 @@ const val ISOLATED_MAGIC = "isolated"
@SuppressLint
(
"InlinedApi"
)
class
AppProcessInfo
(
info
:
ApplicationInfo
,
private
val
info
:
ApplicationInfo
,
pm
:
PackageManager
,
denyList
:
List
<
CmdlineListItem
>
)
:
ApplicationInfo
(
info
),
Comparable
<
AppProcessInfo
>
{
)
:
Comparable
<
AppProcessInfo
>
{
private
val
denyList
=
denyList
.
filter
{
it
.
packageName
==
packageName
||
it
.
packageName
==
ISOLATED_MAGIC
it
.
packageName
==
info
.
packageName
||
it
.
packageName
==
ISOLATED_MAGIC
}
val
label
=
getLabel
(
pm
)
val
iconImage
:
Drawable
=
loadIcon
(
pm
)
val
label
=
info
.
getLabel
(
pm
)
val
iconImage
:
Drawable
=
info
.
loadIcon
(
pm
)
val
packageName
:
String
get
()
=
info
.
packageName
val
processes
=
fetchProcesses
(
pm
)
override
fun
compareTo
(
other
:
AppProcessInfo
)
=
comparator
.
compare
(
this
,
other
)
private
fun
createProcess
(
name
:
String
,
pkg
:
String
=
packageName
)
=
fun
isSystemApp
()
=
info
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
!=
0
fun
isApp
()
=
Process
.
isApplicationUid
(
info
.
uid
)
private
fun
createProcess
(
name
:
String
,
pkg
:
String
=
info
.
packageName
)
=
ProcessInfo
(
name
,
pkg
,
denyList
.
any
{
it
.
process
==
name
&&
it
.
packageName
==
pkg
})
private
fun
ComponentInfo
.
getProcName
():
String
=
processName
...
...
@@ -53,12 +59,12 @@ class AppProcessInfo(
private
val
ServiceInfo
.
useAppZygote
get
()
=
(
flags
and
ServiceInfo
.
FLAG_USE_APP_ZYGOTE
)
!=
0
private
fun
Array
<
out
ComponentInfo
>
?.
toProcessList
()
=
this
?.
map
{
createProcess
(
it
.
getProcName
())
}.
orEmpty
()
orEmpty
().
map
{
createProcess
(
it
.
getProcName
())
}
private
fun
Array
<
ServiceInfo
>
?.
toProcessList
()
=
this
?
.
map
{
private
fun
Array
<
ServiceInfo
>
?.
toProcessList
()
=
orEmpty
()
.
map
{
if
(
it
.
isIsolated
)
{
if
(
it
.
useAppZygote
)
{
val
proc
=
processName
?:
packageName
val
proc
=
info
.
processName
?:
info
.
packageName
createProcess
(
"${proc}_zygote"
)
}
else
{
val
proc
=
if
(
SDK_INT
>=
29
)
"${it.getProcName()}:${it.name}"
else
it
.
getProcName
()
...
...
@@ -67,16 +73,16 @@ class AppProcessInfo(
}
else
{
createProcess
(
it
.
getProcName
())
}
}
.
orEmpty
()
}
private
fun
fetchProcesses
(
pm
:
PackageManager
):
Collection
<
ProcessInfo
>
{
val
flag
=
MATCH_DISABLED_COMPONENTS
or
MATCH_UNINSTALLED_PACKAGES
or
GET_ACTIVITIES
or
GET_SERVICES
or
GET_RECEIVERS
or
GET_PROVIDERS
val
packageInfo
=
try
{
pm
.
getPackageInfo
(
packageName
,
flag
)
pm
.
getPackageInfo
(
info
.
packageName
,
flag
)
}
catch
(
e
:
Exception
)
{
// Exceed binder data transfer limit, parse the package locally
pm
.
getPackageArchiveInfo
(
sourceDir
,
flag
)
?:
return
emptyList
()
pm
.
getPackageArchiveInfo
(
info
.
sourceDir
,
flag
)
?:
return
emptyList
()
}
val
processSet
=
TreeSet
<
ProcessInfo
>(
compareBy
{
it
.
name
})
...
...
@@ -90,7 +96,7 @@ class AppProcessInfo(
companion
object
{
private
val
comparator
=
compareBy
<
AppProcessInfo
>(
{
it
.
label
.
lowercase
(
currentLocale
)
},
{
it
.
packageName
}
{
it
.
info
.
packageName
}
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
View file @
3d3bfb42
package
com.topjohnwu.magisk.ui.deny
import
android.annotation.SuppressLint
import
android.content.pm.ApplicationInfo
import
android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES
import
android.os.Process
import
androidx.lifecycle.viewModelScope
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.arch.BaseViewModel
...
...
@@ -75,17 +73,10 @@ class DenyListViewModel : BaseViewModel(), Queryable {
}
override
fun
query
()
{
fun
isApp
(
uid
:
Int
)
=
run
{
val
appId
:
Int
=
uid
%
100000
appId
>=
Process
.
FIRST_APPLICATION_UID
&&
appId
<=
Process
.
LAST_APPLICATION_UID
}
fun
isSystemApp
(
flag
:
Int
)
=
flag
and
ApplicationInfo
.
FLAG_SYSTEM
!=
0
items
.
filter
{
fun
filterSystem
()
=
isShowSystem
||
!
i
sSystemApp
(
it
.
info
.
flags
)
fun
filterSystem
()
=
isShowSystem
||
!
i
t
.
info
.
isSystemApp
(
)
fun
filterOS
()
=
(
isShowSystem
&&
isShowOS
)
||
i
sApp
(
it
.
info
.
uid
)
fun
filterOS
()
=
(
isShowSystem
&&
isShowOS
)
||
i
t
.
info
.
isApp
(
)
fun
filterQuery
():
Boolean
{
fun
inName
()
=
it
.
info
.
label
.
contains
(
query
,
true
)
...
...
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