4646 image_works_with_device ,
4747 recovery_works_with_device ,
4848 image_sdk_level ,
49+ CheckResult ,
50+ CompatibilityStatus ,
4951)
5052
5153
@@ -145,6 +147,9 @@ def init_visuals(
145147 icon = icons .ARROW_BACK ,
146148 expand = True ,
147149 )
150+ # store image and recovery compatibility
151+ self .image_compatibility : CheckResult | None = None
152+ self .recovery_compatibility : CheckResult | None = None
148153
149154 def build (self ):
150155 self .clear ()
@@ -533,17 +538,21 @@ def pick_image_result(self, e: FilePickerResultEvent):
533538 logger .info ("No image selected." )
534539 # check if the image works with the device and show the filename in different colors accordingly
535540 if e .files :
536- if image_works_with_device (
541+ self . image_compatibility = image_works_with_device (
537542 supported_device_codes = self .state .config .supported_device_codes ,
538543 image_path = self .state .image_path ,
539- ):
544+ )
545+ if self .image_compatibility .status == CompatibilityStatus .COMPATIBLE :
540546 self .selected_image .color = colors .GREEN
547+ elif self .image_compatibility .status == CompatibilityStatus .UNKNOWN :
548+ self .selected_image .color = colors .ORANGE
541549 else :
542550 self .selected_image .color = colors .RED
551+ self .selected_image .value += f"\n > { self .image_compatibility .message } "
543552 # if the image works and the sdk level is 33 or higher, show the additional image selection
544553 if self .state .flash_recovery :
545554 if (
546- self .selected_image . color == colors . GREEN
555+ self .image_compatibility
547556 and image_sdk_level (self .state .image_path ) >= 33
548557 ):
549558 self .toggle_additional_image_selection ()
@@ -567,13 +576,17 @@ def pick_recovery_result(self, e: FilePickerResultEvent):
567576 logger .info ("No image selected." )
568577 # check if the recovery works with the device and show the filename in different colors accordingly
569578 if e .files :
570- if recovery_works_with_device (
579+ self . recovery_compatibility = recovery_works_with_device (
571580 supported_device_codes = self .state .config .supported_device_codes ,
572581 recovery_path = self .state .recovery_path ,
573- ):
582+ )
583+ if self .recovery_compatibility .status == CompatibilityStatus .COMPATIBLE :
574584 self .selected_recovery .color = colors .GREEN
585+ elif self .recovery_compatibility .status == CompatibilityStatus .UNKNOWN :
586+ self .selected_recovery .color = colors .ORANGE
575587 else :
576588 self .selected_recovery .color = colors .RED
589+ self .selected_recovery .value += f"\n > { self .recovery_compatibility .message } "
577590 # update
578591 self .selected_recovery .update ()
579592
@@ -654,23 +667,18 @@ def enable_button_if_ready(self, e):
654667 if (".zip" in self .selected_image .value ) and (
655668 ".img" in self .selected_recovery .value
656669 ):
657- if not (
658- image_works_with_device (
659- supported_device_codes = self .state .config .supported_device_codes ,
660- image_path = self .state .image_path ,
661- )
662- and recovery_works_with_device (
663- supported_device_codes = self .state .config .supported_device_codes ,
664- recovery_path = self .state .recovery_path ,
665- )
670+ if (
671+ self .image_compatibility .status == CompatibilityStatus .INCOMPATIBLE
672+ ) or (
673+ self .recovery_compatibility .status == CompatibilityStatus .INCOMPATIBLE
666674 ):
667675 # if image and recovery work for device allow to move on, otherwise display message
668676 logger .error (
669677 "Image and recovery don't work with the device. Please select different ones."
670678 )
671679 self .info_field .controls = [
672680 Text (
673- "Image and/or recovery don't work with the device. Make sure you use a TWRP-based recovery ." ,
681+ "Something is wrong with the selected files ." ,
674682 color = colors .RED ,
675683 weight = "bold" ,
676684 )
@@ -695,12 +703,10 @@ def enable_button_if_ready(self, e):
695703 or "vendor_boot" not in self .state .config .additional_steps ,
696704 ]
697705 ):
698- logger .error (
699- "Some additional images don't match or are missing. Please select different ones."
700- )
706+ logger .error ("Some additional images don't match or are missing." )
701707 self .info_field .controls = [
702708 Text (
703- "Some additional images don't match or are missing. Please select the right ones. " ,
709+ "Some additional images don't match or are missing." ,
704710 color = colors .RED ,
705711 weight = "bold" ,
706712 )
@@ -715,16 +721,9 @@ def enable_button_if_ready(self, e):
715721 self .continue_eitherway_button .disabled = True
716722 self .right_view .update ()
717723 elif (".zip" in self .selected_image .value ) and (not self .state .flash_recovery ):
718- if not (
719- image_works_with_device (
720- supported_device_codes = self .state .config .supported_device_codes ,
721- image_path = self .state .image_path ,
722- )
723- ):
724+ if self .image_compatibility .status != CompatibilityStatus .COMPATIBLE :
724725 # if image works for device allow to move on, otherwise display message
725- logger .error (
726- "Image doesn't work with the device. Please select a different one."
727- )
726+ logger .error ("Image doesn't work with the device." )
728727 self .info_field .controls = [
729728 Text (
730729 "Image doesn't work with the device." ,
0 commit comments