Skip to content

Commit ab737e8

Browse files
committed
Only support twrp recoveries in tool now
1 parent c708dd3 commit ab737e8

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

openandroidinstaller/tool_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run_command(tool: str, command: List[str], bin_path: Path) -> CompletedProce
4545
logger.info(f"Run command: {full_command}")
4646
with Popen(full_command, stdout=PIPE, stderr=STDOUT, bufsize=1, universal_newlines=True) as p:
4747
for line in p.stdout:
48-
logger.info(line)
48+
logger.info(line.strip())
4949
yield line
5050

5151
yield p.returncode == 0
@@ -149,8 +149,8 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str) -> bool:
149149
yield False
150150
return
151151
# wipe some cache partitions
152-
sleep(5)
153-
for partition in ["cache", "dalvik"]:
152+
sleep(7)
153+
for partition in ["dalvik", "cache"]:
154154
for line in run_command("adb", ["shell", "twrp", "wipe", partition], bin_path):
155155
yield line
156156
sleep(1)

openandroidinstaller/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ def image_recovery_works_with_device(
5555
supported_devices = str(metadata[-1]).split("=")[-1][:-3].split(",")
5656
logger.info(f"Image works with device: {supported_devices}")
5757

58+
recovery_file_name = recovery_path.split("/")[-1]
5859
if (device_code in supported_devices) and (
59-
device_code in recovery_path.split("/")[-1]
60-
):
60+
device_code in recovery_file_name
61+
) and ("twrp" in recovery_file_name):
6162
logger.info("Device supported by the image and recovery.")
6263
return True
64+
else:
65+
logger.info(f"Recovery {recovery_file_name} and/or image {image_path.split('/')[-1]} are not supported or don't match.")
66+
6367
return False

openandroidinstaller/views.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,25 +313,32 @@ def build(self):
313313
Column(
314314
[
315315
Text(
316-
"You can bring your own image and recovery or you download the officially supported image and recovery file for your device here:"
316+
"You can bring your own image and recovery or you download the officially supported image file for your device here:"
317317
),
318318
Row(
319319
[
320320
ElevatedButton(
321-
"Download",
321+
"Download LineageOS image",
322322
icon=icons.DOWNLOAD_OUTLINED,
323323
on_click=lambda _: webbrowser.open(
324324
self.download_link
325325
),
326326
expand=True,
327327
),
328+
ElevatedButton(
329+
"Download TWRP recovery",
330+
icon=icons.DOWNLOAD_OUTLINED,
331+
on_click=lambda _: webbrowser.open(
332+
f"https://dl.twrp.me/{self.state.config.metadata.get('devicecode')}"
333+
),
334+
expand=True,
335+
),
328336
]
329337
),
330338
Markdown(
331339
f"""
332340
The image file should look something like `lineage-19.1-20221101-nightly-{self.state.config.metadata.get('devicecode')}-signed.zip`
333-
and the recovery like `lineage-19.1-20221101-recovery-{self.state.config.metadata.get('devicecode')}.img`
334-
or `twrp-3.6.2_9-0-{self.state.config.metadata.get('devicecode')}.img`.
341+
and the recovery like `twrp-3.6.2_9-0-{self.state.config.metadata.get('devicecode')}.img`. Note that this tool only supports TWRP recoveries for now.
335342
"""
336343
),
337344
Divider(),
@@ -341,7 +348,7 @@ def build(self):
341348
# attach the controls for uploading image and recovery
342349
self.right_view.controls.extend(
343350
[
344-
Text("Now select the operating system image and recovery:"),
351+
Text("Now select the operating system image and recovery (note, that only TWRP recoveries are supported):"),
345352
Row(
346353
[
347354
ElevatedButton(
@@ -530,7 +537,7 @@ def call_to_phone(self, e, command: str):
530537
# display a progress bar to show something is happening
531538
self.right_view.controls.append(
532539
Row(
533-
[ProgressBar(color="#00d886")],
540+
[ProgressBar(width=600, color="#00d886", bgcolor="#eeeeee", bar_height=16)],
534541
alignment="center",
535542
),
536543
)
@@ -549,37 +556,37 @@ def call_to_phone(self, e, command: str):
549556
if command in cmd_mapping.keys():
550557
for line in cmd_mapping.get(command)(bin_path=self.state.bin_path):
551558
if self.state.advanced and (type(line) == str) and line.strip():
552-
self.terminal_box.content.controls.append(Text(f">{line}"))
559+
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
553560
self.terminal_box.update()
554561
success = line
555562
elif command == "adb_sideload":
556563
for line in adb_sideload(bin_path=self.state.bin_path, target=self.state.image_path):
557564
if self.state.advanced and (type(line) == str) and line.strip():
558-
self.terminal_box.content.controls.append(Text(f">{line}"))
565+
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
559566
self.terminal_box.update()
560567
success = line
561568
elif command == "adb_twrp_wipe_and_install":
562569
for line in adb_twrp_wipe_and_install(bin_path=self.state.bin_path, target=self.state.image_path):
563570
if self.state.advanced and (type(line) == str) and line.strip():
564-
self.terminal_box.content.controls.append(Text(f">{line}"))
571+
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
565572
self.terminal_box.update()
566573
success = line
567574
elif command == "fastboot_flash_recovery":
568575
for line in fastboot_flash_recovery(bin_path=self.state.bin_path, recovery=self.state.recovery_path):
569576
if self.state.advanced and (type(line) == str) and line.strip():
570-
self.terminal_box.content.controls.append(Text(f">{line}"))
577+
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
571578
self.terminal_box.update()
572579
success = line
573580
elif command == "fastboot_unlock_with_code":
574581
for line in fastboot_unlock_with_code(bin_path=self.state.bin_path, unlock_code=self.inputtext.value):
575582
if self.state.advanced and (type(line) == str) and line.strip():
576-
self.terminal_box.content.controls.append(Text(f">{line}"))
583+
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
577584
self.terminal_box.update()
578585
success = line
579586
elif command == "heimdall_flash_recovery":
580587
for line in heimdall_flash_recovery(bin_path=self.state.bin_path, recovery=self.state.recovery_path):
581588
if self.state.advanced and (type(line) == str) and line.strip():
582-
self.terminal_box.content.controls.append(Text(f">{line}"))
589+
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
583590
self.terminal_box.update()
584591
success = line
585592
else:

0 commit comments

Comments
 (0)