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
0469f0b5
Commit
0469f0b5
authored
May 07, 2022
by
vvb2060
Committed by
John Wu
May 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add uid check for getAppProcess
parent
0b8577d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
XAndroid.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XAndroid.kt
+16
-9
No files found.
app/src/main/java/com/topjohnwu/magisk/ktx/XAndroid.kt
View file @
0469f0b5
...
@@ -269,20 +269,27 @@ fun getProperty(key: String, def: String): String {
...
@@ -269,20 +269,27 @@ fun getProperty(key: String, def: String): String {
fun
PackageManager
.
getPackageInfo
(
uid
:
Int
,
pid
:
Int
):
PackageInfo
?
{
fun
PackageManager
.
getPackageInfo
(
uid
:
Int
,
pid
:
Int
):
PackageInfo
?
{
val
flag
=
PackageManager
.
MATCH_UNINSTALLED_PACKAGES
val
flag
=
PackageManager
.
MATCH_UNINSTALLED_PACKAGES
val
pkgs
=
getPackagesForUid
(
uid
)
?:
throw
PackageManager
.
NameNotFoundException
()
val
pkgs
=
getPackagesForUid
(
uid
)
?:
throw
PackageManager
.
NameNotFoundException
()
return
if
(
pkgs
.
size
>
1
)
{
if
(
pkgs
.
size
>
1
)
{
if
(
pid
<=
0
)
if
(
pid
<=
0
)
{
return
null
return
null
}
// Try to find package name from PID
// Try to find package name from PID
val
proc
=
RootUtils
.
obj
?.
getAppProcess
(
pid
)
val
proc
=
RootUtils
.
obj
?.
getAppProcess
(
pid
)
?:
return
if
(
uid
==
Process
.
SHELL_UID
)
{
if
(
proc
==
null
)
{
if
(
uid
==
Process
.
SHELL_UID
)
{
// It is possible that some apps installed are sharing UID with shell.
// It is possible that some apps installed are sharing UID with shell.
// We will not be able to find a package from the active process list,
// We will not be able to find a package from the active process list,
// because the client is forked from ADB shell, not any app process.
// because the client is forked from ADB shell, not any app process.
getPackageInfo
(
"com.android.shell"
,
flag
)
return
getPackageInfo
(
"com.android.shell"
,
flag
)
}
else
null
}
val
pkg
=
proc
.
pkgList
[
0
]
}
else
if
(
uid
==
proc
.
uid
)
{
getPackageInfo
(
pkg
,
flag
)
return
getPackageInfo
(
proc
.
pkgList
[
0
],
flag
)
}
else
{
}
getPackageInfo
(
pkgs
[
0
],
flag
)
return
null
}
if
(
pkgs
.
size
==
1
)
{
return
getPackageInfo
(
pkgs
[
0
],
flag
)
}
}
throw
PackageManager
.
NameNotFoundException
()
}
}
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