Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Jan 31, 2023
1 parent 2225d84 commit f54b51d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
22 changes: 20 additions & 2 deletions openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.")
Expand Down
10 changes: 5 additions & 5 deletions openandroidinstaller/views/install_addons_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
1 change: 1 addition & 0 deletions openandroidinstaller/views/install_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openandroidinstaller/views/step_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f54b51d

Please sign in to comment.