diff --git a/openandroidinstaller/tooling.py b/openandroidinstaller/tooling.py index 9bc0f4b3..aba01fea 100644 --- a/openandroidinstaller/tooling.py +++ b/openandroidinstaller/tooling.py @@ -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. @@ -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: diff --git a/openandroidinstaller/views/install_view.py b/openandroidinstaller/views/install_view.py index 327fa96c..8e1f88f8 100644 --- a/openandroidinstaller/views/install_view.py +++ b/openandroidinstaller/views/install_view.py @@ -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( @@ -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. """ @@ -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)