Skip to content

Commit

Permalink
Allow flashing a custom recovery with a toggle switch
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Aug 8, 2023
1 parent 439eec1 commit 017d3ec
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions openandroidinstaller/views/start_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ def check_bootloader_unlocked(e):
"""Enable skipping unlocking the bootloader if selected."""
if self.bootloader_switch.value:
logger.info("Skipping bootloader unlocking.")
self.state.steps = copy.deepcopy(self.state.config.boot_recovery)
self.state.num_total_steps = len(self.state.steps)
self.state.steps = []
else:
logger.info("Enabled unlocking the bootloader again.")
self.state.steps = copy.deepcopy(
self.state.config.unlock_bootloader
) + copy.deepcopy(self.state.config.boot_recovery)
self.state.num_total_steps = len(self.state.steps)
)
# if the recovery is already flashed, skip flashing it again
if self.recovery_switch.value == False:
self.state.steps += copy.deepcopy(self.state.config.boot_recovery)

self.bootloader_switch = Switch(
label="Bootloader is already unlocked.",
Expand All @@ -118,6 +119,32 @@ def check_bootloader_unlocked(e):
active_color=colors.GREEN,
)

# toggleswitch to allow skipping flashing recovery
def check_recovery_already_flashed(e):
"""Enable skipping flashing recovery if selected."""

# manage the bootloader unlocking switch
if self.bootloader_switch.value == False:
self.state.steps = copy.deepcopy(
self.state.config.unlock_bootloader
)
else:
self.state.steps = []

if self.recovery_switch.value:
logger.info("Skipping flashing recovery.")
else:
logger.info("Enabled flashing recovery again.")
self.state.steps += copy.deepcopy(self.state.config.boot_recovery)

self.recovery_switch = Switch(
label="Custom recovery is already flashed.",
on_change=check_recovery_already_flashed,
disabled=False,
inactive_thumb_color=colors.YELLOW,
active_color=colors.GREEN,
)

# inform the user about the device detection
self.device_name = Text("", weight="bold")
self.device_detection_infobox = Row(
Expand Down Expand Up @@ -179,11 +206,12 @@ def build(self):
Divider(),
Markdown(
"""
If you **already unlocked the bootloader** of your device, please toggle the switch below, to skip the procedure.
If you **already unlocked the bootloader** of your device or already **flashed a custom recovery**, please toggle the respective switch below, to skip the procedure.
If you don't know what this means, you most likely don't need to do anything and you can just continue.
"""
),
Row([self.bootloader_switch]),
Row([self.recovery_switch]),
Divider(),
self.device_infobox,
Row(
Expand Down

0 comments on commit 017d3ec

Please sign in to comment.