Use /data if possible
This commit is contained in:
@@ -157,12 +157,21 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
|
||||
}
|
||||
|
||||
val token2 = UUID.randomUUID().toString()
|
||||
val uuid by lazy {
|
||||
val persistence = File(context.codeCacheDir, ".librootkotlinx-uuid")
|
||||
val uuid = context.packageName + '@' + if (persistence.canRead()) persistence.readText() else {
|
||||
context.packageName + '@' + if (persistence.canRead()) persistence.readText() else {
|
||||
UUID.randomUUID().toString().also { persistence.writeText(it) }
|
||||
}
|
||||
}
|
||||
// to workaround Samsung's stupid kernel patch, we need to relocate outside of /data: https://github.com/Chainfire/librootjava/issues/19
|
||||
val (baseDir, relocated) = if (Build.VERSION.SDK_INT < 29) "/dev" to "/dev/app_process_$uuid" else {
|
||||
val cachePath = context.codeCacheDir.canonicalPath
|
||||
if (cachePath.startsWith("/data/")) {
|
||||
val relocated = File(context.codeCacheDir, "relocated")
|
||||
relocated.mkdir()
|
||||
check(relocated.isDirectory)
|
||||
relocated.absolutePath to File(relocated, "app_process").absolutePath
|
||||
} else {
|
||||
val apexPath = "/apex/$uuid"
|
||||
writer.writeBytes("[ -d $apexPath ] || " +
|
||||
"mkdir $apexPath && " +
|
||||
@@ -180,6 +189,7 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
|
||||
"cat $masterLdConfig >>$ldConfig || exit 1\n")
|
||||
"$apexPath/bin" to "$apexPath/bin/app_process"
|
||||
}
|
||||
}
|
||||
writer.writeBytes("[ -f $relocated ] || " +
|
||||
"mkdir -p $baseDir && " +
|
||||
"cp /proc/${android.os.Process.myPid()}/exe $relocated && " +
|
||||
|
||||
Reference in New Issue
Block a user