@@ -531,17 +531,41 @@ class SlotViewModel(
531
531
} finally {
532
532
uiPrint(" " )
533
533
if (wasSlotReset) {
534
- uiPrint(" CAUTION: You have flashed AnyKernel Zip to inactive slot!" )
535
- uiPrint(" But the active slot is not changed after flashing." )
536
- uiPrint(" Use bootctl to change active slot or Return to System Updater to complete OTA." )
537
- uiPrint(" Do not reboot from here, unless you know what you are doing." )
534
+ // uiPrint("CAUTION: You have flashed AnyKernel Zip to inactive slot!")
535
+ // uiPrint("But the active slot is not changed after flashing.")
536
+ // uiPrint("Use bootctl to change active slot or Return to System Updater to complete OTA.")
537
+ // uiPrint("Do not reboot from here, unless you know what you are doing.")
538
538
resetSlot()
539
539
viewModelScope.launch(Dispatchers .Main ) {
540
540
showCautionDialog() // Show dialog instead of uiPrint
541
541
}
542
542
}
543
543
}
544
544
}
545
+
546
+ fun switchSlot (context : Context ) {
547
+ viewModelScope.launch(Dispatchers .IO ) {
548
+ try {
549
+ // Get current slot
550
+ val currentSlot = Shell .cmd(" getprop ro.boot.slot_suffix" ).exec().out .firstOrNull() ? : " _a"
551
+ val targetSlot = if (currentSlot == " _a" ) " b" else " a"
552
+
553
+ // Execute bootctl command
554
+ val result = Shell .cmd(" bootctl set-active-boot-slot $targetSlot " ).exec()
555
+
556
+ if (result.isSuccess) {
557
+ log(context, " Slot was successfully switched to $targetSlot " , shouldThrow = false )
558
+ } else {
559
+ log(context, " Failed to switch slot" , shouldThrow = false )
560
+ }
561
+ } catch (e: Exception ) {
562
+ withContext(Dispatchers .Main ) {
563
+ Toast .makeText(context, " Error: ${e.message} " , Toast .LENGTH_SHORT ).show()
564
+ }
565
+ throw e
566
+ }
567
+ }
568
+ }
545
569
546
570
fun flashAk3 (context : Context , currentBackup : String , filename : String ) {
547
571
launch {
0 commit comments