@@ -195,24 +195,25 @@ def adb_twrp_wipe_and_install(
195195 sleep (5 )
196196 logger .info ("Sideload and install os image." )
197197 for line in adb_sideload (bin_path = bin_path , target = target ):
198- if line :
199- yield line
198+ yield line
200199 # wipe some cache partitions
201200 sleep (7 )
202201 for partition in ["dalvik" , "cache" ]:
203- for line in adb_twrp_wipe_partition ( bin_path = bin_path , partition = partition ):
202+ for line in run_command ( f"adb shell twrp wipe { partition } " , bin_path ):
204203 yield line
204+ sleep (1 )
205205 if (type (line ) == bool ) and not line :
206206 logger .error (f"Wiping { partition } failed." )
207207 # TODO: if this fails, a fix can be to just sideload something and then adb reboot
208- sleep (1 )
209- for line in adb_sideload (
210- bin_path = bin_path ,
211- target = f"{ config_path .parent .joinpath (Path ('helper.txt' ))} " ,
208+ for line in run_command (
209+ f"adb sideload { config_path .parent .joinpath (Path ('helper.txt' ))} " ,
210+ bin_path ,
212211 ):
213212 yield line
214- sleep (1 )
213+ if (type (line ) == bool ) and not line :
214+ yield False
215215 break
216+ sleep (2 )
216217 # finally reboot into os or to fastboot for flashing addons
217218 sleep (7 )
218219 if install_addons :
@@ -222,7 +223,9 @@ def adb_twrp_wipe_and_install(
222223 yield line
223224 sleep (3 )
224225 # boot to TWRP again
225- for line in fastboot_flash_boot (bin_path = bin_path , recovery = recovery ):
226+ for line in fastboot_flash_recovery (
227+ bin_path = bin_path , recovery = recovery , is_ab = is_ab
228+ ):
226229 yield line
227230 sleep (7 )
228231 else :
@@ -317,7 +320,10 @@ def fastboot_reboot(bin_path: Path) -> Union[str, bool]:
317320 yield line
318321
319322
320- def fastboot_flash_recovery (bin_path : Path , recovery : str , is_ab : bool = True ) -> bool :
323+ @add_logging ("Flash or boot custom recovery with fastboot." )
324+ def fastboot_flash_recovery (
325+ bin_path : Path , recovery : str , is_ab : bool = True
326+ ) -> Union [str , bool ]:
321327 """Temporarily, flash custom recovery with fastboot."""
322328 if is_ab :
323329 logger .info ("Boot custom recovery with fastboot." )
@@ -337,12 +343,6 @@ def fastboot_flash_recovery(bin_path: Path, recovery: str, is_ab: bool = True) -
337343 for line in run_command ("fastboot reboot recovery" , bin_path ):
338344 yield line
339345
340- if (type (line ) == bool ) and not line :
341- logger .error ("Booting recovery failed." )
342- yield False
343- else :
344- yield True
345-
346346
347347def fastboot_flash_boot (bin_path : Path , recovery : str ) -> bool :
348348 """Temporarily, flash custom recovery with fastboot to boot partition."""
0 commit comments