Skip to content

Commit 3789f82

Browse files
committed
Fix vbmeta selection bug and update recovery checks on device codes
1 parent 08fa43f commit 3789f82

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

openandroidinstaller/assets/configs/Mi439.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ metadata:
1010
- super_empty
1111
supported_device_codes:
1212
- Mi439
13+
- mi439
1314
- pine
1415
- olive
1516
- olivelite

openandroidinstaller/utils.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ def get_download_link(devicecode: str) -> Optional[str]:
4141

4242

4343
def image_works_with_device(supported_device_codes: List[str], image_path: str) -> bool:
44-
"""Determine if an image works for the given device."""
44+
"""Determine if an image works for the given device.
45+
46+
Args:
47+
supported_device_codes: List of supported device codes from the config file.
48+
image_path: Path to the image file.
49+
50+
Returns:
51+
True if the image works with the device, False otherwise.
52+
"""
4553
with zipfile.ZipFile(image_path) as image_zip:
4654
with image_zip.open(
4755
"META-INF/com/android/metadata", mode="r"
@@ -77,13 +85,24 @@ def image_sdk_level(image_path: str) -> int:
7785
return 0
7886

7987

80-
def recovery_works_with_device(device_code: str, recovery_path: str) -> bool:
88+
def recovery_works_with_device(
89+
supported_device_codes: List[str], recovery_path: str
90+
) -> bool:
8191
"""Determine if a recovery works for the given device.
8292
8393
BEWARE: THE RECOVERY PART IS STILL VERY BASIC!
94+
95+
Args:
96+
supported_device_codes: List of supported device codes from the config file.
97+
recovery_path: Path to the recovery file.
98+
99+
Returns:
100+
True if the recovery works with the device, False otherwise.
84101
"""
85102
recovery_file_name = recovery_path.split("/")[-1]
86-
if (device_code in recovery_file_name) and ("twrp" in recovery_file_name):
103+
if any(code in recovery_file_name for code in supported_device_codes) and (
104+
"twrp" in recovery_file_name
105+
):
87106
logger.success("Device supported by the selected recovery.")
88107
return True
89108
else:

openandroidinstaller/views/select_view.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ def get_notes(self) -> str:
296296
notes = []
297297

298298
brand = self.state.config.metadata.get("brand", "")
299-
if brand in ["xiaomi", "poco"]:
299+
if brand in "xiaomi":
300+
notes.append(
301+
"- If something goes wrong, you can reinstall MiUI here:\n<https://xiaomifirmwareupdater.com/>\n"
302+
)
303+
elif brand in "poco":
300304
notes.append(
301305
f"- If something goes wrong, you can reinstall MiUI here:\n<https://xiaomifirmwareupdater.com/miui/{self.state.config.device_code}/>\n"
302306
)
@@ -552,6 +556,7 @@ def pick_vbmeta_result(self, e: FilePickerResultEvent):
552556
# check if the vbmeta works with the device and show the filename in different colors accordingly
553557
if path == "vbmeta.img":
554558
self.selected_vbmeta.color = colors.GREEN
559+
self.selected_vbmeta.value = True
555560
self.state.vbmeta_path = e.files[0].path
556561
logger.info(f"Selected vbmeta from {self.state.vbmeta_path}")
557562
else:

0 commit comments

Comments
 (0)