Skip to content

Commit

Permalink
If no addon is selected just reboot to OS at installation time (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed May 1, 2023
2 parents 574516c + 0b54802 commit be8d660
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions openandroidinstaller/app_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
# placeholders
self.advanced = False
self.install_addons = False
self.addon_paths = None
self.config = None
self.image_path = None
self.recovery_path = None
Expand Down
30 changes: 18 additions & 12 deletions openandroidinstaller/views/install_addons_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from views import BaseView
from app_state import AppState
from tooling import adb_twrp_install_addons
from tooling import adb_twrp_install_addons, adb_reboot
from widgets import (
confirm_button,
get_title,
Expand Down Expand Up @@ -158,16 +158,22 @@ def run_install_addons(self, e):
self.right_view.update()

# run the install script
for line in adb_twrp_install_addons(
addons=self.state.addon_paths,
bin_path=self.state.bin_path,
is_ab=self.state.config.is_ab,
):
# write the line to advanced output terminal
self.terminal_box.write_line(line)
# 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()
if self.state.addon_paths:
for line in adb_twrp_install_addons(
addons=self.state.addon_paths,
bin_path=self.state.bin_path,
is_ab=self.state.config.is_ab,
):
# write the line to advanced output terminal
self.terminal_box.write_line(line)
# 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()
else:
logger.info("No addons selected. Rebooting to OS.")
for line in adb_reboot(bin_path=self.state.bin_path):
# write the line to advanced output terminal
self.terminal_box.write_line(line)
success = line # the last element of the iterable is a boolean encoding success/failure

# update the view accordingly
Expand All @@ -177,7 +183,7 @@ def run_install_addons(self, e):
# also remove the last error text if it happened
self.error_text.value = "Installation failed! Try again or make sure everything is setup correctly."
else:
sleep(5) # wait to make sure everything is fine
sleep(4) # wait to make sure everything is fine
logger.success("Installation process was successful. Allow to continue.")
# enable the confirm button and disable the call button
self.confirm_button.disabled = False
Expand Down

0 comments on commit be8d660

Please sign in to comment.