Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Jan 30, 2023
1 parent 2bb75d0 commit 03e50a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
30 changes: 21 additions & 9 deletions openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def adb_twrp_copy_partitions(bin_path: Path, config_path: Path):
return True


def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) -> bool:
def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path, install_addons=True) -> bool:
"""Wipe and format data with twrp, then flash os image with adb.
Only works for twrp recovery.
Expand Down Expand Up @@ -214,15 +214,27 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) ->
break
# finally reboot into os
sleep(7)
logger.info("Reboot into OS.")
for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp",
yield line
if (type(line) == bool) and not line:
logger.error("Rebooting failed.")
yield False
return
if install_addons:
# TODO: Fix the process for samsung devices
# reboot into the bootloader again
logger.info("Rebooting device into bootloader with adb.")
for line in run_command("adb", ["reboot", "bootloader"], bin_path):
yield line
if (type(line) == bool) and not line:
logger.error("Reboot into bootloader failed.")
yield False
return
sleep(7)
else:
yield True
logger.info("Reboot into OS.")
for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp",
yield line
if (type(line) == bool) and not line:
logger.error("Rebooting failed.")
yield False
return
else:
yield True


def fastboot_unlock_with_code(bin_path: Path, unlock_code: str) -> bool:
Expand Down
6 changes: 4 additions & 2 deletions openandroidinstaller/views/install_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ def check_addons_switch(e):
"""Check the switch to enable the addons installation process."""
if self.install_addons_switch.value:
logger.info("Enable flashing addons.")
# TODO: add the addons step here.
self.state.install_addons = True
self.state.steps.extend(self.state.config.flash_recovery)
else:
logger.info("Disable flashing addons.")
# TODO: empty the steps again
self.state.install_addons = False

self.install_addons_switch = Switch(
Expand Down Expand Up @@ -159,7 +160,7 @@ def check_addons_switch(e):

def run_install(self, e):
"""
Run the installation process trought twrp.
Run the installation process trough twrp.
Some parts of the command are changed by placeholders.
"""
Expand All @@ -178,6 +179,7 @@ def run_install(self, e):
target=self.state.image_path,
config_path=self.state.config_path,
bin_path=self.state.bin_path,
install_addons=self.state.install_addons,
):
# write the line to advanced output terminal
self.terminal_box.write_line(line)
Expand Down

0 comments on commit 03e50a7

Please sign in to comment.