Skip to content

Commit b206e0f

Browse files
shatyukabackslashxx
authored andcommitted
manager: detect init_boot with Android version in uname (tiann#2142)
Redmi Note 12 Turbo (marble) comes shipped with Android 13, but the baseline/kernel target version is Android 12. ``` # getprop | grep api_level [ro.board.api_level]: [31] [ro.board.first_api_level]: [31] [ro.product.first_api_level]: [33] [ro.vendor.api_level]: [31] # uname -a Linux localhost 5.10.198-android12-9-00085-g226a9632f13d-ab11136126 #1 SMP PREEMPT Wed Nov 22 14:16:37 UTC 2023 aarch64 Toybox ``` Maybe we should use `ro.board.first_api_level` instead of `ro.product.first_api_level`, or the minimum value. But anyway, it's better to be consistent with ksud. https://github.com/tiann/KernelSU/blob/2f9210b2e79338e7e7b1eb91878cada2b9a37ed6/userspace/ksud/src/boot_patch.rs#L407
1 parent 4ae5a9c commit b206e0f

File tree

1 file changed

+2
-14
lines changed
  • manager/app/src/main/java/me/weishu/kernelsu/ui/util

1 file changed

+2
-14
lines changed

manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import android.content.ContentResolver
44
import android.content.Context
55
import android.database.Cursor
66
import android.net.Uri
7-
import android.os.Build
87
import android.os.Environment
98
import android.os.Parcelable
109
import android.os.SystemClock
1110
import android.provider.OpenableColumns
11+
import android.system.Os
1212
import android.util.Log
1313
import com.topjohnwu.superuser.CallbackList
1414
import com.topjohnwu.superuser.Shell
1515
import com.topjohnwu.superuser.ShellUtils
16-
import com.topjohnwu.superuser.io.SuFile
1716
import kotlinx.coroutines.Dispatchers
1817
import kotlinx.coroutines.withContext
1918
import kotlinx.parcelize.Parcelize
@@ -312,18 +311,7 @@ fun isAbDevice(): Boolean {
312311
}
313312

314313
fun isInitBoot(): Boolean {
315-
val shell = getRootShell()
316-
if (shell.isRoot) {
317-
// if we have root, use /dev/block/by-name/init_boot to check
318-
val abDevice = isAbDevice()
319-
val initBootBlock = "/dev/block/by-name/init_boot${if (abDevice) "_a" else ""}"
320-
val file = SuFile(initBootBlock)
321-
file.shell = shell
322-
return file.exists()
323-
}
324-
// https://source.android.com/docs/core/architecture/partitions/generic-boot
325-
return ShellUtils.fastCmd(shell, "getprop ro.product.first_api_level").trim()
326-
.toInt() >= Build.VERSION_CODES.TIRAMISU
314+
return !Os.uname().release.contains("android12-")
327315
}
328316

329317
suspend fun getCurrentKmi(): String = withContext(Dispatchers.IO) {

0 commit comments

Comments
 (0)