Skip to content

Commit ed5ec0c

Browse files
committed
added fallback check for kernel when no ramdisk
1 parent f5f270c commit ed5ec0c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "com.github.capntrips.kernelflasher"
1313
minSdk 29
1414
targetSdk 34
15-
versionCode 15
16-
versionName "1.0.0-alpha15"
15+
versionCode 16
16+
versionName "1.0.0-alpha16"
1717

1818
javaCompileOptions {
1919
annotationProcessorOptions {

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotViewModel.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class SlotViewModel(
9999
Shell.cmd("$magiskboot unpack $boot").exec()
100100

101101
val ramdisk = File(context.filesDir, "ramdisk.cpio")
102+
val kernel = File(context.filesDir, "kernel")
102103

103104
var vendorDlkm = PartitionUtil.findPartitionBlockDevice(context, "vendor_dlkm", slotSuffix)
104105
hasVendorDlkm = vendorDlkm != null
@@ -121,10 +122,12 @@ class SlotViewModel(
121122
when (Shell.cmd("$magiskboot cpio ramdisk.cpio test").exec().code) {
122123
0 -> _sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
123124
1 -> _sha1 = Shell.cmd("$magiskboot cpio ramdisk.cpio sha1").exec().out.firstOrNull()
124-
else -> log(context, "Invalid boot.img", shouldThrow = true)
125+
else -> log(context, "Invalid ramdisk in boot.img", shouldThrow = true)
125126
}
127+
} else if (kernel.exists()) {
128+
_sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
126129
} else {
127-
log(context, "Invalid boot.img", shouldThrow = true)
130+
log(context, "Invalid boot.img, no ramdisk or kernel found", shouldThrow = true)
128131
}
129132
Shell.cmd("$magiskboot cleanup").exec()
130133
} else {

0 commit comments

Comments
 (0)