Skip to content

Commit

Permalink
Revert "manager: detect init_boot with Android version in uname (tian…
Browse files Browse the repository at this point in the history
…n#2142)"

This reverts commit 05a9054.
  • Loading branch information
selfmusing committed Oct 22, 2024
1 parent d47cfe8 commit 8f752a4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8f752a4

Please sign in to comment.