Skip to content

Commit 9dd8671

Browse files
committed
Fix the crap TWRP loading with sargo
1 parent a95b93b commit 9dd8671

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

openandroidinstaller/assets/configs/sargo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ steps:
4444
- type: call_button
4545
content: >
4646
In the next steps, you finally flash the selected OS image.
47-
Connect your device with your computer with the USB-Cable.
47+
Wait until the TWRP screen appears. Then run the command.
4848
This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored
4949
in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS.
5050
command: adb_twrp_wipe_and_install

openandroidinstaller/tool_utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def adb_sideload(bin_path: Path, target: str) -> bool:
108108
yield True
109109

110110

111-
def adb_twrp_wipe_and_install(bin_path: Path, target: str) -> bool:
111+
def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) -> bool:
112112
"""Wipe and format data with twrp, then flash os image with adb.
113113
114114
Only works for twrp recovery.
@@ -156,15 +156,21 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str) -> bool:
156156
sleep(1)
157157
if (type(line) == bool) and not line:
158158
logger.error(f"Wiping {partition} failed.")
159-
yield False
160-
return
159+
# TODO: if this fails, a fix can be to just sideload something and then adb reboot
160+
for line in run_command("adb", ["sideload", str(config_path)], bin_path):
161+
yield line
162+
sleep(1)
163+
if (type(line) == bool) and not line:
164+
yield False
165+
return
166+
break
161167
# finally reboot into os
162168
sleep(5)
163169
logger.info("Reboot into OS.")
164-
for line in run_command("adb", ["shell", "twrp", "reboot"], bin_path):
170+
for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp",
165171
yield line
166172
if (type(line) == bool) and not line:
167-
logger.error("Rebooting with twrp failed.")
173+
logger.error("Rebooting failed.")
168174
yield False
169175
return
170176
else:

openandroidinstaller/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import webbrowser
1717
from time import sleep
1818
from typing import Callable
19+
from pathlib import Path
1920
from loguru import logger
2021

2122
import flet
@@ -571,7 +572,11 @@ def call_to_phone(self, e, command: str):
571572
self.terminal_box.update()
572573
success = line
573574
elif command == "adb_twrp_wipe_and_install":
574-
for line in adb_twrp_wipe_and_install(bin_path=self.state.bin_path, target=self.state.image_path):
575+
for line in adb_twrp_wipe_and_install(
576+
bin_path=self.state.bin_path,
577+
target=self.state.image_path,
578+
config_path=self.state.config_path.joinpath(Path(f"{self.state.config.metadata.get('devicecode')}.yaml"))
579+
):
575580
if self.state.advanced and (type(line) == str) and line.strip():
576581
self.terminal_box.content.controls.append(Text(f">{line.strip()}"))
577582
self.terminal_box.update()

0 commit comments

Comments
 (0)