You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val slot_inactive_state =if(isActive) "active"else"inactive"
511
-
val result =Shell.Builder.create().setFlags(Shell.FLAG_MOUNT_MASTERorShell.FLAG_REDIRECT_STDERR).build().newJob().add("F=$files Z=\"$zip\"S=\"$slot_inactive_state\" P=\"$slotSuffix\"/system/bin/sh $flashScript").to(flashOutput).exec()
522
+
val result =Shell.Builder.create().setFlags(Shell.FLAG_MOUNT_MASTERorShell.FLAG_REDIRECT_STDERR).build().newJob().add("F=$files Z=\"$zip\" /system/bin/sh $flashScript").to(flashOutput).exec()
512
523
if (result.isSuccess) {
513
524
log(context, "Kernel flashed successfully")
514
525
_wasFlashSuccess.value =true
@@ -525,24 +536,55 @@ class SlotViewModel(
525
536
} finally {
526
537
uiPrint("")
527
538
if (wasSlotReset) {
539
+
// uiPrint("CAUTION: You have flashed AnyKernel Zip to inactive slot!")
540
+
// uiPrint("But the active slot is not changed after flashing.")
541
+
// uiPrint("Use bootctl to change active slot or Return to System Updater to complete OTA.")
542
+
// uiPrint("Do not reboot from here, unless you know what you are doing.")
528
543
resetSlot()
544
+
viewModelScope.launch(Dispatchers.Main) {
545
+
showCautionDialog() // Show dialog instead of uiPrint
546
+
}
529
547
}
530
548
}
531
549
}
550
+
551
+
funswitchSlot(context:Context) {
552
+
viewModelScope.launch(Dispatchers.IO) {
553
+
try {
554
+
// Get current slot
555
+
val currentSlot =Shell.cmd("getprop ro.boot.slot_suffix").exec().out.firstOrNull() ?:"_a"
556
+
val targetSlot =if (currentSlot =="_a") "b"else"a"
557
+
558
+
// Execute bootctl command
559
+
val result =Shell.cmd("bootctl set-active-boot-slot $targetSlot").exec()
560
+
561
+
if (result.isSuccess) {
562
+
log(context, "Slot was successfully switched to $targetSlot", shouldThrow =false)
563
+
} else {
564
+
log(context, "Failed to switch slot", shouldThrow =false)
0 commit comments