manager: check init_boot more precisely
This commit is contained in:
@@ -8,6 +8,7 @@ import android.util.Log
|
|||||||
import com.topjohnwu.superuser.CallbackList
|
import com.topjohnwu.superuser.CallbackList
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import com.topjohnwu.superuser.ShellUtils
|
import com.topjohnwu.superuser.ShellUtils
|
||||||
|
import com.topjohnwu.superuser.io.SuFile
|
||||||
import me.weishu.kernelsu.BuildConfig
|
import me.weishu.kernelsu.BuildConfig
|
||||||
import me.weishu.kernelsu.Natives
|
import me.weishu.kernelsu.Natives
|
||||||
import me.weishu.kernelsu.ksuApp
|
import me.weishu.kernelsu.ksuApp
|
||||||
@@ -240,6 +241,14 @@ fun isAbDevice(): Boolean {
|
|||||||
|
|
||||||
fun isInitBoot(): Boolean {
|
fun isInitBoot(): Boolean {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
|
if (shell.isRoot) {
|
||||||
|
// if we have root, use /dev/block/by-name/init_boot to check
|
||||||
|
val abDevice = isAbDevice()
|
||||||
|
val initBootBlock = "/dev/block/by-name/init_boot${if (abDevice) "_a" else ""}"
|
||||||
|
val file = SuFile(initBootBlock)
|
||||||
|
file.shell = shell
|
||||||
|
return file.exists()
|
||||||
|
}
|
||||||
// https://source.android.com/docs/core/architecture/partitions/generic-boot
|
// https://source.android.com/docs/core/architecture/partitions/generic-boot
|
||||||
return ShellUtils.fastCmd(shell, "getprop ro.product.first_api_level").trim().toInt() >= Build.VERSION_CODES.TIRAMISU
|
return ShellUtils.fastCmd(shell, "getprop ro.product.first_api_level").trim().toInt() >= Build.VERSION_CODES.TIRAMISU
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user