|
17 | 17 | from time import sleep |
18 | 18 | from typing import Callable |
19 | 19 | from pathlib import Path |
| 20 | +from functools import partial |
20 | 21 |
|
21 | 22 | from flet import ( |
22 | 23 | UserControl, |
@@ -182,46 +183,25 @@ def call_to_phone(self, e, command: str): |
182 | 183 | self.right_view.controls.append(progress_bar) |
183 | 184 | self.right_view.update() |
184 | 185 |
|
| 186 | + # get the appropriate function to run for every possible command. |
185 | 187 | cmd_mapping = { |
186 | 188 | "adb_reboot": adb_reboot, |
187 | 189 | "adb_reboot_bootloader": adb_reboot_bootloader, |
188 | 190 | "adb_reboot_download": adb_reboot_download, |
| 191 | + "adb_sideload": partial(adb_sideload, target=self.state.image_path), |
| 192 | + "adb_twrp_wipe_and_install": partial(adb_twrp_wipe_and_install, target=self.state.image_path, config_path=self.state.config_path), |
189 | 193 | "fastboot_unlock": fastboot_unlock, |
| 194 | + "fastboot_unlock_with_code": partial(fastboot_unlock_with_code, unlock_code=self.inputtext.value), |
190 | 195 | "fastboot_oem_unlock": fastboot_oem_unlock, |
| 196 | + "fastboot_flash_recovery": partial(fastboot_flash_recovery, recovery=self.state.recovery_path), |
191 | 197 | "fastboot_reboot": fastboot_reboot, |
| 198 | + "heimdall_flash_recovery": partial(heimdall_flash_recovery, recovery=self.state.recovery_path), |
192 | 199 | } |
193 | 200 |
|
194 | 201 | # run the right command |
195 | 202 | if command in cmd_mapping.keys(): |
196 | 203 | for line in cmd_mapping.get(command)(bin_path=self.state.bin_path): |
197 | 204 | self.terminal_box.write_line(line) |
198 | | - elif command == "adb_sideload": |
199 | | - for line in adb_sideload( |
200 | | - bin_path=self.state.bin_path, target=self.state.image_path |
201 | | - ): |
202 | | - self.terminal_box.write_line(line) |
203 | | - elif command == "adb_twrp_wipe_and_install": |
204 | | - for line in adb_twrp_wipe_and_install( |
205 | | - bin_path=self.state.bin_path, |
206 | | - target=self.state.image_path, |
207 | | - config_path=self.state.config_path, |
208 | | - ): |
209 | | - self.terminal_box.write_line(line) |
210 | | - elif command == "fastboot_flash_recovery": |
211 | | - for line in fastboot_flash_recovery( |
212 | | - bin_path=self.state.bin_path, recovery=self.state.recovery_path |
213 | | - ): |
214 | | - self.terminal_box.write_line(line) |
215 | | - elif command == "fastboot_unlock_with_code": |
216 | | - for line in fastboot_unlock_with_code( |
217 | | - bin_path=self.state.bin_path, unlock_code=self.inputtext.value |
218 | | - ): |
219 | | - self.terminal_box.write_line(line) |
220 | | - elif command == "heimdall_flash_recovery": |
221 | | - for line in heimdall_flash_recovery( |
222 | | - bin_path=self.state.bin_path, recovery=self.state.recovery_path |
223 | | - ): |
224 | | - self.terminal_box.write_line(line) |
225 | 205 | else: |
226 | 206 | msg = f"Unknown command type: {command}. Stopping." |
227 | 207 | logger.error(msg) |
|
0 commit comments