Skip to content

Commit f54b51d

Browse files
committed
WIP
1 parent 2225d84 commit f54b51d

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

openandroidinstaller/tooling.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def adb_twrp_wipe_and_install(
239239
yield True
240240

241241

242-
def adb_twrp_install_addons(bin_path: Path, addons: List[str]) -> bool:
242+
def adb_twrp_install_addons(bin_path: Path, config_path: Path, addons: List[str]) -> bool:
243243
"""Flash addons through adb and twrp.
244244
245245
Only works for twrp recovery.
@@ -265,10 +265,28 @@ def adb_twrp_install_addons(bin_path: Path, addons: List[str]) -> bool:
265265
# TODO: this might sometimes think it failed, but actually it's fine. So skip for now.
266266
# yield False
267267
# return
268+
# reboot into fastboot
269+
sleep(5)
270+
logger.info("Boot into fastboot")
271+
for line in run_command("adb", ["reboot", "bootloader"], bin_path):
272+
yield line
273+
if (type(line) == bool) and not line:
274+
logger.error("Booting to fastboot failed.")
275+
yield False
276+
return
277+
# switch active boot partition
278+
sleep(7)
279+
logger.info("Switch active boot partition")
280+
for line in run_command("fastboot", ["set_active", "other"], bin_path):
281+
yield line
282+
if (type(line) == bool) and not line:
283+
logger.error("Switching boot partition failed.")
284+
yield False
285+
return
268286
# finally reboot into os
269287
sleep(7)
270288
logger.info("Reboot into OS.")
271-
for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp",
289+
for line in run_command("fastboot", ["reboot"], bin_path):
272290
yield line
273291
if (type(line) == bool) and not line:
274292
logger.error("Rebooting failed.")

openandroidinstaller/views/install_addons_view.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def run_install_addons(self, e):
144144
"""
145145
# disable the call button while the command is running
146146
self.install_button.disabled = True
147-
self.install_addons_switch.disabled = True
147+
self.error_text.value = ""
148148
# reset the progress indicators
149149
self.progress_indicator.clear()
150150
# reset terminal output
@@ -156,11 +156,13 @@ def run_install_addons(self, e):
156156
for line in adb_twrp_install_addons(
157157
addons=self.state.addon_paths,
158158
bin_path=self.state.bin_path,
159+
config_path=self.state.config_path,
159160
):
160161
# write the line to advanced output terminal
161162
self.terminal_box.write_line(line)
162-
# in case the install command is run, we want to update progress ring for now
163-
self.progress_indicator.display_progress_ring()
163+
# in case the install command is run, we want to update the progress bar
164+
self.progress_indicator.display_progress_bar(line)
165+
self.progress_indicator.update()
164166
success = line # the last element of the iterable is a boolean encoding success/failure
165167

166168
# update the view accordingly
@@ -175,6 +177,4 @@ def run_install_addons(self, e):
175177
# enable the confirm button and disable the call button
176178
self.confirm_button.disabled = False
177179
self.install_button.disabled = True
178-
# reset the progress indicator
179-
self.progress_indicator.clear()
180180
self.view.update()

openandroidinstaller/views/install_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def run_install(self, e):
168168
# disable the call button while the command is running
169169
self.install_button.disabled = True
170170
self.install_addons_switch.disabled = True
171+
self.error_text.value = ""
171172
# reset the progress indicators
172173
self.progress_indicator.clear()
173174
# reset terminal output

openandroidinstaller/views/step_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def display_progress_bar(self, line: str):
323323
result = None
324324
# get the progress numbers from the output lines
325325
if (type(line) == str) and line.strip():
326-
result = re.search(r"\(\~(\d{1,3})\%\)|(Total xfer: 1\.00x)", line.strip())
326+
result = re.search(r"\(\~(\d{1,3})\%\)|(Total xfer: 1\.)", line.strip())
327327
if result:
328328
if result.group(1):
329329
percentage_done = int(result.group(1))

0 commit comments

Comments
 (0)