2121import flet
2222from flet import (
2323 AlertDialog ,
24+ alignment ,
2425 AppBar ,
2526 Banner ,
2627 Checkbox ,
@@ -501,17 +502,22 @@ def call_to_phone(self, e, command: str):
501502 Row (
502503 [ProgressRing (color = "#00d886" )],
503504 alignment = "center" ,
504- )
505+ ),
505506 )
506507 self .right_view .update ()
507508
509+ cmd_mapping = {
510+ "adb_reboot" : adb_reboot ,
511+ "adb_reboot_bootloader" : adb_reboot_bootloader ,
512+ "adb_reboot_download" : adb_reboot_download ,
513+ "fastboot_unlock" : fastboot_unlock ,
514+ "fastboot_oem_unlock" : fastboot_oem_unlock ,
515+ "fastboot_reboot" : fastboot_reboot ,
516+ }
517+
508518 # run the right command
509- if command == "adb_reboot" :
510- success = adb_reboot (bin_path = self .state .bin_path )
511- elif command == "adb_reboot_bootloader" :
512- success = adb_reboot_bootloader (bin_path = self .state .bin_path )
513- elif command == "adb_reboot_download" :
514- success = adb_reboot_download (bin_path = self .state .bin_path )
519+ if command in cmd_mapping .keys ():
520+ success = cmd_mapping .get (command )(bin_path = self .state .bin_path )
515521 elif command == "adb_sideload" :
516522 success = adb_sideload (
517523 bin_path = self .state .bin_path , target = self .state .image_path
@@ -528,12 +534,6 @@ def call_to_phone(self, e, command: str):
528534 success = fastboot_unlock_with_code (
529535 bin_path = self .state .bin_path , unlock_code = self .inputtext .value
530536 )
531- elif command == "fastboot_unlock" :
532- success = fastboot_unlock (bin_path = self .state .bin_path )
533- elif command == "fastboot_oem_unlock" :
534- success = fastboot_oem_unlock (bin_path = self .state .bin_path )
535- elif command == "fastboot_reboot" :
536- success = fastboot_reboot (bin_path = self .state .bin_path )
537537 elif command == "heimdall_flash_recovery" :
538538 success = heimdall_flash_recovery (
539539 bin_path = self .state .bin_path , recovery = self .state .recovery_path
0 commit comments