diff --git a/openandroidinstaller/tooling.py b/openandroidinstaller/tooling.py index 54fea04b..e3d2e8c4 100644 --- a/openandroidinstaller/tooling.py +++ b/openandroidinstaller/tooling.py @@ -239,7 +239,7 @@ def adb_twrp_wipe_and_install( yield True -def adb_twrp_install_addons(bin_path: Path, addons: List[str]) -> bool: +def adb_twrp_install_addons(bin_path: Path, config_path: Path, addons: List[str]) -> bool: """Flash addons through adb and twrp. Only works for twrp recovery. @@ -265,10 +265,28 @@ def adb_twrp_install_addons(bin_path: Path, addons: List[str]) -> bool: # TODO: this might sometimes think it failed, but actually it's fine. So skip for now. # yield False # return + # reboot into fastboot + sleep(5) + logger.info("Boot into fastboot") + for line in run_command("adb", ["reboot", "bootloader"], bin_path): + yield line + if (type(line) == bool) and not line: + logger.error("Booting to fastboot failed.") + yield False + return + # switch active boot partition + sleep(7) + logger.info("Switch active boot partition") + for line in run_command("fastboot", ["set_active", "other"], bin_path): + yield line + if (type(line) == bool) and not line: + logger.error("Switching boot partition failed.") + yield False + return # finally reboot into os sleep(7) logger.info("Reboot into OS.") - for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp", + for line in run_command("fastboot", ["reboot"], bin_path): yield line if (type(line) == bool) and not line: logger.error("Rebooting failed.") diff --git a/openandroidinstaller/views/install_addons_view.py b/openandroidinstaller/views/install_addons_view.py index d46b8e85..78ba5b86 100644 --- a/openandroidinstaller/views/install_addons_view.py +++ b/openandroidinstaller/views/install_addons_view.py @@ -144,7 +144,7 @@ def run_install_addons(self, e): """ # disable the call button while the command is running self.install_button.disabled = True - self.install_addons_switch.disabled = True + self.error_text.value = "" # reset the progress indicators self.progress_indicator.clear() # reset terminal output @@ -156,11 +156,13 @@ def run_install_addons(self, e): for line in adb_twrp_install_addons( addons=self.state.addon_paths, bin_path=self.state.bin_path, + config_path=self.state.config_path, ): # write the line to advanced output terminal self.terminal_box.write_line(line) - # in case the install command is run, we want to update progress ring for now - self.progress_indicator.display_progress_ring() + # in case the install command is run, we want to update the progress bar + self.progress_indicator.display_progress_bar(line) + self.progress_indicator.update() success = line # the last element of the iterable is a boolean encoding success/failure # update the view accordingly @@ -175,6 +177,4 @@ def run_install_addons(self, e): # enable the confirm button and disable the call button self.confirm_button.disabled = False self.install_button.disabled = True - # reset the progress indicator - self.progress_indicator.clear() self.view.update() diff --git a/openandroidinstaller/views/install_view.py b/openandroidinstaller/views/install_view.py index ca766d19..6a31a0fa 100644 --- a/openandroidinstaller/views/install_view.py +++ b/openandroidinstaller/views/install_view.py @@ -168,6 +168,7 @@ def run_install(self, e): # disable the call button while the command is running self.install_button.disabled = True self.install_addons_switch.disabled = True + self.error_text.value = "" # reset the progress indicators self.progress_indicator.clear() # reset terminal output diff --git a/openandroidinstaller/views/step_view.py b/openandroidinstaller/views/step_view.py index ea54874f..9f888fc3 100644 --- a/openandroidinstaller/views/step_view.py +++ b/openandroidinstaller/views/step_view.py @@ -323,7 +323,7 @@ def display_progress_bar(self, line: str): result = None # get the progress numbers from the output lines if (type(line) == str) and line.strip(): - result = re.search(r"\(\~(\d{1,3})\%\)|(Total xfer: 1\.00x)", line.strip()) + result = re.search(r"\(\~(\d{1,3})\%\)|(Total xfer: 1\.)", line.strip()) if result: if result.group(1): percentage_done = int(result.group(1))