Skip to content

Commit

Permalink
manager: check init_boot more precisely
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Mar 17, 2024
1 parent f6d552c commit 117b4dc
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.util.Log
import com.topjohnwu.superuser.CallbackList
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ShellUtils
import com.topjohnwu.superuser.io.SuFile
import me.weishu.kernelsu.BuildConfig
import me.weishu.kernelsu.Natives
import me.weishu.kernelsu.ksuApp
Expand Down Expand Up @@ -240,6 +241,14 @@ fun isAbDevice(): Boolean {

fun isInitBoot(): Boolean {
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
return ShellUtils.fastCmd(shell, "getprop ro.product.first_api_level").trim().toInt() >= Build.VERSION_CODES.TIRAMISU
}
Expand Down

0 comments on commit 117b4dc

Please sign in to comment.