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
35853871
Unverified
Commit
35853871
authored
May 10, 2022
by
南宫雪珊
Committed by
GitHub
May 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce number of loop
parent
24603b3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
RootUtils.kt
...rc/main/java/com/topjohnwu/magisk/core/utils/RootUtils.kt
+11
-9
No files found.
app/src/main/java/com/topjohnwu/magisk/core/utils/RootUtils.kt
View file @
35853871
...
...
@@ -5,6 +5,7 @@ import android.content.ComponentName
import
android.content.Intent
import
android.content.ServiceConnection
import
android.os.IBinder
import
android.system.Os
import
androidx.core.content.getSystemService
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.superuser.Shell
...
...
@@ -13,7 +14,6 @@ import com.topjohnwu.superuser.ipc.RootService
import
com.topjohnwu.superuser.nio.FileSystemManager
import
timber.log.Timber
import
java.io.File
import
java.io.IOException
import
java.util.concurrent.locks.AbstractQueuedSynchronizer
class
RootUtils
(
stub
:
Any
?)
:
RootService
()
{
...
...
@@ -48,6 +48,7 @@ class RootUtils(stub: Any?) : RootService() {
return
try
{
block
()
}
catch
(
e
:
Throwable
)
{
// The process died unexpectedly
Timber
.
e
(
e
)
default
}
...
...
@@ -60,16 +61,17 @@ class RootUtils(stub: Any?) : RootService() {
val
proc
=
procList
.
find
{
it
.
pid
==
pid
}
if
(
proc
!=
null
)
return
proc
// Find PPID
try
{
File
(
"/proc/$pid/status"
).
useLines
{
val
line
=
it
.
find
{
l
->
l
.
startsWith
(
"PPid:"
)
}
?:
return
null
pid
=
line
.
substring
(
5
).
trim
().
toInt
()
}
}
catch
(
e
:
IOException
)
{
// The process died unexpectedly
// Stop find when root process
if
(
Os
.
stat
(
"/proc/$pid"
).
st_uid
==
0
)
{
return
null
}
// Find PPID
File
(
"/proc/$pid/status"
).
useLines
{
val
line
=
it
.
find
{
l
->
l
.
startsWith
(
"PPid:"
)
}
?:
return
null
pid
=
line
.
substring
(
5
).
trim
().
toInt
()
}
}
return
null
}
...
...
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