Skip to content

Commit a4aa74d

Browse files
committed
If adb twrp format data fails, retry with adb twrp wipe data
1 parent 3b75594 commit a4aa74d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

openandroidinstaller/tooling.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,19 @@ def adb_twrp_format_data(bin_path: Path) -> TerminalResponse:
184184

185185
@add_logging("Wipe the selected partition with adb and twrp.", return_if_fail=True)
186186
def adb_twrp_wipe_partition(bin_path: Path, partition: str) -> TerminalResponse:
187-
"""Perform a factory reset with twrp and adb."""
187+
"""Perform a factory reset with twrp and adb.
188+
189+
If `format data` fails (for example because of old TWRP versions) we fall back to `wipe data`.
190+
"""
188191
for line in run_command(f"adb shell twrp wipe {partition}", bin_path):
189192
yield line
193+
if (type(line) == bool) and not line:
194+
logger.info(
195+
"Factory reset with `adb twrp format data` failed. Trying `adb twrp wipe data` now."
196+
)
197+
sleep(1)
198+
for line in adb_twrp_wipe_partition(bin_path=bin_path, partition="data"):
199+
yield line
190200

191201

192202
def adb_twrp_wipe_and_install(

0 commit comments

Comments
 (0)