Skip to content

Commit

Permalink
Add function to know image sdk (mainly Android version+20)
Browse files Browse the repository at this point in the history
  • Loading branch information
anon1892 committed Aug 4, 2023
1 parent 0604ff1 commit f464396
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions openandroidinstaller/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ def image_works_with_device(supported_device_codes: List[str], image_path: str)
)
return False

def image_sdk_level(image_path: str) -> int:
"""
Determine Android version of the selected image.
Android 13 : 33
"""
with zipfile.ZipFile(image_path) as image_zip:
with image_zip.open(
"META-INF/com/android/metadata", mode="r"
) as image_metadata:
metadata = image_metadata.readlines()
for line in metadata:
if b"sdk-level" in line:
return int(line[line.find(b'=')+1:-1].decode("utf-8"))
return 0

def recovery_works_with_device(device_code: str, recovery_path: str) -> bool:
"""Determine if a recovery works for the given device.
Expand Down

0 comments on commit f464396

Please sign in to comment.