Skip to content

Commit

Permalink
If adb twrp format data fails, retry with adb twrp wipe data
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Apr 19, 2023
1 parent 3b75594 commit a4aa74d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,19 @@ def adb_twrp_format_data(bin_path: Path) -> TerminalResponse:

@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:
"""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`.
"""
for line in run_command(f"adb shell twrp wipe {partition}", bin_path):
yield line
if (type(line) == bool) and not line:
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


def adb_twrp_wipe_and_install(
Expand Down

0 comments on commit a4aa74d

Please sign in to comment.