From 8f752a4ffd199fd5657e783b35f3de16a85ed0b7 Mon Sep 17 00:00:00 2001 From: selfmusing Date: Wed, 23 Oct 2024 00:39:30 +0530 Subject: [PATCH] Revert "manager: detect init_boot with Android version in uname (#2142)" This reverts commit 05a90542c676b8751ff34e3a6adb248c1c32a18d. --- .../java/me/weishu/kernelsu/ui/util/KsuCli.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt index 2376876589e1..108e08f2a139 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt @@ -4,15 +4,16 @@ import android.content.ContentResolver import android.content.Context import android.database.Cursor import android.net.Uri +import android.os.Build import android.os.Environment import android.os.Parcelable import android.os.SystemClock import android.provider.OpenableColumns -import android.system.Os 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 kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import kotlinx.parcelize.Parcelize @@ -311,7 +312,18 @@ fun isAbDevice(): Boolean { } fun isInitBoot(): Boolean { - return !Os.uname().release.contains("android12-") + 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 } suspend fun getCurrentKmi(): String = withContext(Dispatchers.IO) {