Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If adb twrp format data fails, retry with adb twrp wipe data #142

Merged
merged 5 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,25 @@ def adb_twrp_copy_partitions(bin_path: Path, config_path: Path) -> TerminalRespo

@add_logging("Perform a factory reset with adb and twrp.", return_if_fail=True)
def adb_twrp_format_data(bin_path: Path) -> TerminalResponse:
"""Perform a factory reset with twrp and adb."""
"""Perform a factory reset with twrp and adb.

If `format data` fails (for example because of old TWRP versions) we fall back to `wipe data`.
"""
unknown_command = False
for line in run_command("adb shell twrp format data", bin_path):
if (type(line) == str) and ("Unrecognized script command" in line):
unknown_command = True
yield line

# if it fails because the command is unknown, retry with wipe data.
if unknown_command:
logger.info(
"Factory reset with `adb twrp format data` failed. Trying `adb twrp wipe data` now."
)
sleep(1)
for line in adb_twrp_wipe_partition(bin_path=bin_path, partition="data"):
yield line


@add_logging("Wipe the selected partition with adb and twrp.", return_if_fail=True)
def adb_twrp_wipe_partition(bin_path: Path, partition: str) -> TerminalResponse:
Expand Down
1 change: 0 additions & 1 deletion openandroidinstaller/views/addon_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def build(self):
F-Droid is an installable catalogue of libre software apps for Android. The F-Droid client app makes it easy to browse, install, and keep track of updates on your device.
You can get the zip file to install this addon here: [https://f-droid.org/en/packages/org.fdroid.fdroid.privileged.ota](https://f-droid.org/en/packages/org.fdroid.fdroid.privileged.ota).
""",
on_tap_link=lambda e: self.page.launch_url(e.data),
),
actions=[
TextButton("Close", on_click=self.close_close_explain_addons_dlg),
Expand Down
1 change: 0 additions & 1 deletion openandroidinstaller/views/success_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def close_window(e):

[How to contribute]({contribute_link})
""",
on_tap_link=lambda e: self.page.launch_url(e.data),
),
Row(
[
Expand Down