Skip to content

Commit

Permalink
added fallback check for kernel when no ramdisk
Browse files Browse the repository at this point in the history
  • Loading branch information
capntrips committed Oct 11, 2023
1 parent f5f270c commit ed5ec0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.github.capntrips.kernelflasher"
minSdk 29
targetSdk 34
versionCode 15
versionName "1.0.0-alpha15"
versionCode 16
versionName "1.0.0-alpha16"

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class SlotViewModel(
Shell.cmd("$magiskboot unpack $boot").exec()

val ramdisk = File(context.filesDir, "ramdisk.cpio")
val kernel = File(context.filesDir, "kernel")

var vendorDlkm = PartitionUtil.findPartitionBlockDevice(context, "vendor_dlkm", slotSuffix)
hasVendorDlkm = vendorDlkm != null
Expand All @@ -121,10 +122,12 @@ class SlotViewModel(
when (Shell.cmd("$magiskboot cpio ramdisk.cpio test").exec().code) {
0 -> _sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
1 -> _sha1 = Shell.cmd("$magiskboot cpio ramdisk.cpio sha1").exec().out.firstOrNull()
else -> log(context, "Invalid boot.img", shouldThrow = true)
else -> log(context, "Invalid ramdisk in boot.img", shouldThrow = true)
}
} else if (kernel.exists()) {
_sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
} else {
log(context, "Invalid boot.img", shouldThrow = true)
log(context, "Invalid boot.img, no ramdisk or kernel found", shouldThrow = true)
}
Shell.cmd("$magiskboot cleanup").exec()
} else {
Expand Down

0 comments on commit ed5ec0c

Please sign in to comment.