Skip to content

Commit 9531e67

Browse files
committed
Fix Wrong Kernel version Shown when Backup is done if fastboot boot is used
This works only on certain devices. Most devices stores fastboot booted kernel in RAM only. Still this code refactors that part of code to a better format.
1 parent 8b2afe1 commit 9531e67

File tree

1 file changed

+8
-6
lines changed
  • app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,16 @@ class SlotViewModel(
459459
return backupDir
460460
}
461461

462+
@OptIn(ExperimentalSerializationApi::class)
462463
fun backup(context: Context) {
463464
launch {
464465
_clearFlash()
465-
val currentKernelVersion = if (_slotInfo.value.bootImgInfo.kernelVersion != null) {
466-
_slotInfo.value.bootImgInfo.kernelVersion
467-
} else if (isActive) {
468-
System.getProperty("os.version")!!
469-
} else {
466+
467+
val currentKernelVersion = _slotInfo.value.bootImgInfo.kernelVersion ?: run {
470468
_getKernel(context)
471-
_slotInfo.value.bootImgInfo.kernelVersion
469+
_slotInfo.value.bootImgInfo.kernelVersion ?: System.getProperty("os.version")!!
472470
}
471+
473472
val now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd--HH-mm"))
474473
val backupDir = createBackupDir(context, now)
475474
addMessage("Saving backup $now")
@@ -484,9 +483,11 @@ class SlotViewModel(
484483
_backups[now] = backup
485484
addMessage("Backup $now saved")
486485
_wasFlashSuccess.value = true
486+
SharedViewModels.mainViewModel.markRefreshNeeded()
487487
}
488488
}
489489

490+
@OptIn(ExperimentalSerializationApi::class)
490491
fun backupZip(context: Context, callback: () -> Unit) {
491492
launch {
492493
val source = context.contentResolver.openInputStream(flashUri!!)
@@ -511,6 +512,7 @@ class SlotViewModel(
511512
} else {
512513
log(context, "AK3 zip is missing", shouldThrow = true)
513514
}
515+
SharedViewModels.mainViewModel.markRefreshNeeded()
514516
}
515517
}
516518

0 commit comments

Comments
 (0)