Skip to content

Commit 017d3ec

Browse files
committed
Allow flashing a custom recovery with a toggle switch
1 parent 439eec1 commit 017d3ec

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

openandroidinstaller/views/start_view.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ def check_bootloader_unlocked(e):
101101
"""Enable skipping unlocking the bootloader if selected."""
102102
if self.bootloader_switch.value:
103103
logger.info("Skipping bootloader unlocking.")
104-
self.state.steps = copy.deepcopy(self.state.config.boot_recovery)
105-
self.state.num_total_steps = len(self.state.steps)
104+
self.state.steps = []
106105
else:
107106
logger.info("Enabled unlocking the bootloader again.")
108107
self.state.steps = copy.deepcopy(
109108
self.state.config.unlock_bootloader
110-
) + copy.deepcopy(self.state.config.boot_recovery)
111-
self.state.num_total_steps = len(self.state.steps)
109+
)
110+
# if the recovery is already flashed, skip flashing it again
111+
if self.recovery_switch.value == False:
112+
self.state.steps += copy.deepcopy(self.state.config.boot_recovery)
112113

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

122+
# toggleswitch to allow skipping flashing recovery
123+
def check_recovery_already_flashed(e):
124+
"""Enable skipping flashing recovery if selected."""
125+
126+
# manage the bootloader unlocking switch
127+
if self.bootloader_switch.value == False:
128+
self.state.steps = copy.deepcopy(
129+
self.state.config.unlock_bootloader
130+
)
131+
else:
132+
self.state.steps = []
133+
134+
if self.recovery_switch.value:
135+
logger.info("Skipping flashing recovery.")
136+
else:
137+
logger.info("Enabled flashing recovery again.")
138+
self.state.steps += copy.deepcopy(self.state.config.boot_recovery)
139+
140+
self.recovery_switch = Switch(
141+
label="Custom recovery is already flashed.",
142+
on_change=check_recovery_already_flashed,
143+
disabled=False,
144+
inactive_thumb_color=colors.YELLOW,
145+
active_color=colors.GREEN,
146+
)
147+
121148
# inform the user about the device detection
122149
self.device_name = Text("", weight="bold")
123150
self.device_detection_infobox = Row(
@@ -179,11 +206,12 @@ def build(self):
179206
Divider(),
180207
Markdown(
181208
"""
182-
If you **already unlocked the bootloader** of your device, please toggle the switch below, to skip the procedure.
209+
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.
183210
If you don't know what this means, you most likely don't need to do anything and you can just continue.
184211
"""
185212
),
186213
Row([self.bootloader_switch]),
214+
Row([self.recovery_switch]),
187215
Divider(),
188216
self.device_infobox,
189217
Row(

0 commit comments

Comments
 (0)