diff --git a/README.md b/README.md index 74c3310c..55ffa6db 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Linux is currently the best supported platform (tested with Ubuntu 20.04/22.04 L ## Officially supported devices -Currently, **we support 52 devices** by various vendors and working on adding more soon! +Currently, the **we support 56 devices** by various vendors and working on adding more soon! Support for these devices is provided as best effort, but things might still go wrong. @@ -82,9 +82,13 @@ Samsung | Galaxy S6 Edge | [zeroltexx](https://wiki.lineageos.org/devices/zerolt Samsung | Galaxy S7 | [herolte](https://wiki.lineageos.org/devices/herolte/) | SM-G930F | tested Samsung | Galaxy S7 Edge | [hero2lte](https://wiki.lineageos.org/devices/hero2lte/) | | tested Samsung | Galaxy S9 | [starlte](https://wiki.lineageos.org/devices/starlte/) | | tested +Samsung | Galaxy Note 8 | greatlte | SM-N950F | tested Samsung | Galaxy Note 9 | [crownlte](https://wiki.lineageos.org/devices/crownlte/) | | tested Samsung | Galaxy S10 | [beyond1lte](https://wiki.lineageos.org/devices/beyond1lte/) | | tested +Samsung | Galaxy S10e | [beyond0lte](https://wiki.lineageos.org/devices/beyond0lte/) | | tested +Samsung | Galaxy S10+ | [beyond2lte](https://wiki.lineageos.org/devices/beyond2lte/) | | tested Samsung | Galaxy Note 10 | [d1](https://wiki.lineageos.org/devices/d1/) | | tested +Samsung | Galaxy Note 10+ | [d2s](https://wiki.lineageos.org/devices/d2s/) | | tested Samsung | Galaxy Note 3 LTE | [hltetmo](https://wiki.lineageos.org/devices/hltetmo/) | N900T/V/W8 | tested diff --git a/openandroidinstaller/assets/configs/beyond0lte.yaml b/openandroidinstaller/assets/configs/beyond0lte.yaml new file mode 100644 index 00000000..01bf3524 --- /dev/null +++ b/openandroidinstaller/assets/configs/beyond0lte.yaml @@ -0,0 +1,38 @@ +metadata: + maintainer: Tobias Sterbak (tsterbak) + devicename: Samsung Galaxy S10e + devicecode: beyond0lte +requirements: + android: 12 +steps: + unlock_bootloader: + - type: call_button + content: > + As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone + how to start and run an operating system (like Android). Your device should be turned on. + Press 'Confirm and run' to reboot into download mode. Then continue. + command: adb_reboot_download + - type: confirm_button + content: > + Now, click the button that the onscreen instructions correlate to “Continue” and/or “Unlock Bootloader”. + Your device will reboot, you may now unplug the USB cable from your device. + The device will demand you format userdata, please follow the onscreen instructions to do so. + - type: confirm_button + content: > + The bootloader is now unlocked. Go through Android Setup skipping everything you can, then connect the device to a Wi-Fi network. + Since the device resets completely, you will need to re-enable Developer Options and USB debugging to continue. + flash_recovery: + - type: call_button + content: > + Now plug the USB-cable to your device. As a first step, you need to boot into download mode. Your device should be turned on. + Then press 'Confirm and run' to reboot into download mode. Continue once it's done. + command: adb_reboot_download + - type: call_button + content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. + command: heimdall_flash_recovery + - type: confirm_button + img: samsung-buttons-bixby.png + content: > + Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Bixby* for 8~10 seconds + until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, + hold *Volume Up* + *Bixby* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/beyond1lte.yaml b/openandroidinstaller/assets/configs/beyond1lte.yaml index 6deef617..914d178e 100644 --- a/openandroidinstaller/assets/configs/beyond1lte.yaml +++ b/openandroidinstaller/assets/configs/beyond1lte.yaml @@ -6,18 +6,32 @@ requirements: android: 12 steps: unlock_bootloader: + - type: call_button + content: > + As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone + how to start and run an operating system (like Android). Your device should be turned on. + Press 'Confirm and run' to reboot into download mode. Then continue. + command: adb_reboot_download + - type: confirm_button + content: > + Now, click the button that the onscreen instructions correlate to “Continue” and/or “Unlock Bootloader”. + Your device will reboot, you may now unplug the USB cable from your device. + The device will demand you format userdata, please follow the onscreen instructions to do so. + - type: confirm_button + content: > + The bootloader is now unlocked. Go through Android Setup skipping everything you can, then connect the device to a Wi-Fi network. + Since the device resets completely, you will need to re-enable Developer Options and USB debugging to continue. flash_recovery: - type: call_button content: > - As a first step, you need to boot into the bootloader. A bootloader is the piece of software, - that tells your phone who to start and run an operating system (like Android). Your device should be turned on. - Then press 'Confirm and run' to reboot into the bootloader. Continue once it's done. + Now plug the USB-cable to your device. As a first step, you need to boot into download mode. Your device should be turned on. + Then press 'Confirm and run' to reboot into download mode. Continue once it's done. command: adb_reboot_download - type: call_button content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. command: heimdall_flash_recovery - type: confirm_button - img: samsung-buttons.png + img: samsung-buttons-bixby.png content: > Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Bixby* for 8~10 seconds until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, diff --git a/openandroidinstaller/assets/configs/beyond2lte.yaml b/openandroidinstaller/assets/configs/beyond2lte.yaml new file mode 100644 index 00000000..ff8a529a --- /dev/null +++ b/openandroidinstaller/assets/configs/beyond2lte.yaml @@ -0,0 +1,38 @@ +metadata: + maintainer: Tobias Sterbak (tsterbak) + devicename: Samsung Galaxy S10+ + devicecode: beyond2lte +requirements: + android: 12 +steps: + unlock_bootloader: + - type: call_button + content: > + As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone + how to start and run an operating system (like Android). Your device should be turned on. + Press 'Confirm and run' to reboot into download mode. Then continue. + command: adb_reboot_download + - type: confirm_button + content: > + Now, click the button that the onscreen instructions correlate to “Continue” and/or “Unlock Bootloader”. + Your device will reboot, you may now unplug the USB cable from your device. + The device will demand you format userdata, please follow the onscreen instructions to do so. + - type: confirm_button + content: > + The bootloader is now unlocked. Go through Android Setup skipping everything you can, then connect the device to a Wi-Fi network. + Since the device resets completely, you will need to re-enable Developer Options and USB debugging to continue. + flash_recovery: + - type: call_button + content: > + Now plug the USB-cable to your device. As a first step, you need to boot into download mode. Your device should be turned on. + Then press 'Confirm and run' to reboot into download mode. Continue once it's done. + command: adb_reboot_download + - type: call_button + content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. + command: heimdall_flash_recovery + - type: confirm_button + img: samsung-buttons-bixby.png + content: > + Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Bixby* for 8~10 seconds + until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, + hold *Volume Up* + *Bixby* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/crownlte.yaml b/openandroidinstaller/assets/configs/crownlte.yaml index 38a922c4..8b759e6b 100644 --- a/openandroidinstaller/assets/configs/crownlte.yaml +++ b/openandroidinstaller/assets/configs/crownlte.yaml @@ -17,7 +17,7 @@ steps: content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. command: heimdall_flash_recovery - type: confirm_button - img: samsung-buttons.png + img: samsung-buttons-bixby.png content: > Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Bixby* for 8~10 seconds until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, diff --git a/openandroidinstaller/assets/configs/d1.yaml b/openandroidinstaller/assets/configs/d1.yaml index 431d49a0..8ae30aeb 100644 --- a/openandroidinstaller/assets/configs/d1.yaml +++ b/openandroidinstaller/assets/configs/d1.yaml @@ -6,18 +6,32 @@ requirements: android: 12 steps: unlock_bootloader: + - type: call_button + content: > + As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone + how to start and run an operating system (like Android). Your device should be turned on. + Press 'Confirm and run' to reboot into download mode. Then continue. + command: adb_reboot_download + - type: confirm_button + content: > + Now, click the button that the onscreen instructions correlate to “Continue” and/or “Unlock Bootloader”. + Your device will reboot, you may now unplug the USB cable from your device. + The device will demand you format userdata, please follow the onscreen instructions to do so. + - type: confirm_button + content: > + The bootloader is now unlocked. Go through Android Setup skipping everything you can, then connect the device to a Wi-Fi network. + Since the device resets completely, you will need to re-enable Developer Options and USB debugging to continue. flash_recovery: - type: call_button content: > - As a first step, you need to boot into the bootloader. A bootloader is the piece of software, - that tells your phone who to start and run an operating system (like Android). Your device should be turned on. - Then press 'Confirm and run' to reboot into the bootloader. Continue once it's done. + Now plug the USB-cable to your device. As a first step, you need to boot into download mode. Your device should be turned on. + Then press 'Confirm and run' to reboot into download mode. Continue once it's done. command: adb_reboot_download - type: call_button content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. command: heimdall_flash_recovery - type: confirm_button - img: samsung-buttons.png + img: samsung-buttons-bixby.png content: > Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Bixby* for 8~10 seconds until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, diff --git a/openandroidinstaller/assets/configs/d2s.yaml b/openandroidinstaller/assets/configs/d2s.yaml new file mode 100644 index 00000000..07bd6819 --- /dev/null +++ b/openandroidinstaller/assets/configs/d2s.yaml @@ -0,0 +1,38 @@ +metadata: + maintainer: Tobias Sterbak (tsterbak) + devicename: Samsung Galaxy Note 10+ + devicecode: d2s +requirements: + android: 12 +steps: + unlock_bootloader: + - type: call_button + content: > + As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone + how to start and run an operating system (like Android). Your device should be turned on. + Press 'Confirm and run' to reboot into download mode. Then continue. + command: adb_reboot_download + - type: confirm_button + content: > + Now, click the button that the onscreen instructions correlate to “Continue” and/or “Unlock Bootloader”. + Your device will reboot, you may now unplug the USB cable from your device. + The device will demand you format userdata, please follow the onscreen instructions to do so. + - type: confirm_button + content: > + The bootloader is now unlocked. Go through Android Setup skipping everything you can, then connect the device to a Wi-Fi network. + Since the device resets completely, you will need to re-enable Developer Options and USB debugging to continue. + flash_recovery: + - type: call_button + content: > + Now plug the USB-cable to your device. As a first step, you need to boot into download mode. Your device should be turned on. + Then press 'Confirm and run' to reboot into download mode. Continue once it's done. + command: adb_reboot_download + - type: call_button + content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. + command: heimdall_flash_recovery + - type: confirm_button + img: samsung-buttons-bixby.png + content: > + Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Bixby* for 8~10 seconds + until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, + hold *Volume Up* + *Bixby* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/greatlte.yaml b/openandroidinstaller/assets/configs/greatlte.yaml new file mode 100644 index 00000000..01e54325 --- /dev/null +++ b/openandroidinstaller/assets/configs/greatlte.yaml @@ -0,0 +1,21 @@ +metadata: + maintainer: Michel Memeteau (freechelmi) + devicename: Samsung Galaxy note 8 + devicecode: greatlte +steps: + unlock_bootloader: + flash_recovery: + - type: call_button + content: > + As a first step, you need to boot into the bootloader. A bootloader is the piece of software, + that tells your phone who to start and run an operating system (like Android). Your device should be turned on. + Then press 'Confirm and run' to reboot into the bootloader. Continue once it's done. + command: adb_reboot_download + - type: call_button + content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue. + command: heimdall_flash_recovery + - type: confirm_button + img: samsung-buttons-bixby.png + content: > + Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Power buttons* for 8~10 seconds + until the screen turns black to reboot & release the buttons immediately when it does, then immediately hold *Volume Up* + *Bixby* + *Power button* until you are in recovery mode. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/taimen.yaml b/openandroidinstaller/assets/configs/taimen.yaml index 64382154..8bed3bbf 100644 --- a/openandroidinstaller/assets/configs/taimen.yaml +++ b/openandroidinstaller/assets/configs/taimen.yaml @@ -3,7 +3,7 @@ metadata: devicename: Google Pixel 2 XL devicecode: taimen requirements: - android: 12 + android: 11 steps: unlock_bootloader: - type: call_button diff --git a/openandroidinstaller/assets/configs/walleye.yaml b/openandroidinstaller/assets/configs/walleye.yaml index 7b95c9ba..1daae392 100644 --- a/openandroidinstaller/assets/configs/walleye.yaml +++ b/openandroidinstaller/assets/configs/walleye.yaml @@ -3,7 +3,7 @@ metadata: devicename: Google Pixel 2 devicecode: walleye requirements: - android: 12 + android: 11 steps: unlock_bootloader: - type: call_button diff --git a/openandroidinstaller/assets/imgs/samsung-buttons-bixby.png b/openandroidinstaller/assets/imgs/samsung-buttons-bixby.png new file mode 100644 index 00000000..33364051 Binary files /dev/null and b/openandroidinstaller/assets/imgs/samsung-buttons-bixby.png differ diff --git a/openandroidinstaller/openandroidinstaller.py b/openandroidinstaller/openandroidinstaller.py index a24c5f8f..f6b26431 100644 --- a/openandroidinstaller/openandroidinstaller.py +++ b/openandroidinstaller/openandroidinstaller.py @@ -57,7 +57,7 @@ logger.add("openandroidinstaller.log") # VERSION number -VERSION = "0.4.0-beta" +VERSION = "0.4.1-beta" # detect platform PLATFORM = sys.platform @@ -210,7 +210,10 @@ def log_version_infos(bin_path): hdversion = [ line for line in run_command("heimdall info", bin_path, enable_logging=False) ] - logger.info(f"Heimdall version: {hdversion[1].strip()}") + try: + logger.info(f"Heimdall version: {hdversion[1].strip()}") + except: + logger.info(f"Issue with heimdall: {hdversion}") def main(page: Page, test: bool = False, test_config: str = "sargo"): @@ -233,6 +236,17 @@ def main(page: Page, test: bool = False, test_config: str = "sargo"): center_title=False, bgcolor="#00d886", actions=[ + Container( + content=ElevatedButton( + icon=icons.QUESTION_MARK_ROUNDED, + text="FAQ", + on_click=lambda _: webbrowser.open( + "https://openandroidinstaller.org/faq.html" + ), + ), + padding=15, + tooltip="Frequently asked questions and encountered issues.", + ), Container( content=ElevatedButton( icon=icons.BUG_REPORT_OUTLINED, @@ -243,7 +257,7 @@ def main(page: Page, test: bool = False, test_config: str = "sargo"): ), padding=15, tooltip="Report an issue on github", - ) + ), ], ) diff --git a/openandroidinstaller/tooling.py b/openandroidinstaller/tooling.py index da438efe..fc16e7e8 100644 --- a/openandroidinstaller/tooling.py +++ b/openandroidinstaller/tooling.py @@ -36,7 +36,10 @@ def run_command( - full_command: str, bin_path: Path, enable_logging: bool = True + full_command: str, + bin_path: Path, + target: Optional[Union[str, Path]] = None, + enable_logging: bool = True, ) -> TerminalResponse: """Run a command with a tool (adb, fastboot, heimdall).""" yield f"${full_command}" @@ -54,6 +57,8 @@ def run_command( si = None if enable_logging: logger.info(f"Run command: {command_list}") + if target: + command_list.append(f"{target}") # run the command with subprocess.Popen( command_list, @@ -106,7 +111,9 @@ def adb_reboot_bootloader(bin_path: Path) -> TerminalResponse: """Reboot the device into bootloader and return success.""" for line in run_command("adb reboot bootloader", bin_path): yield line - sleep(1) + # wait for the bootloader to become available + for line in fastboot_wait_for_bootloader(bin_path=bin_path): + yield line @add_logging("Rebooting device into download mode with adb.") @@ -114,12 +121,13 @@ def adb_reboot_download(bin_path: Path) -> TerminalResponse: """Reboot the device into download mode of samsung devices and return success.""" for line in run_command("adb reboot download", bin_path): yield line + yield heimdall_wait_for_download_available(bin_path=bin_path) @add_logging("Sideload the target to device with adb.") def adb_sideload(bin_path: Path, target: str) -> TerminalResponse: """Sideload the target to device and return success.""" - for line in run_command(f"adb sideload {target}", bin_path): + for line in run_command("adb sideload", target=target, bin_path=bin_path): yield line @@ -128,6 +136,22 @@ def activate_sideload(bin_path: Path) -> TerminalResponse: """Activate sideload with adb shell in twrp.""" for line in run_command("adb shell twrp sideload", bin_path): yield line + for line in adb_wait_for_sideload(bin_path=bin_path): + yield line + + +@add_logging("Wait for recovery") +def adb_wait_for_recovery(bin_path: Path) -> TerminalResponse: + """Use adb to wait for the recovery to become available.""" + for line in run_command("adb wait-for-recovery", bin_path): + yield line + + +@add_logging("Wait for sideload") +def adb_wait_for_sideload(bin_path: Path) -> TerminalResponse: + """Use adb to wait for the sideload to become available.""" + for line in run_command("adb wait-for-sideload", bin_path): + yield line def adb_twrp_copy_partitions(bin_path: Path, config_path: Path) -> TerminalResponse: @@ -137,7 +161,6 @@ def adb_twrp_copy_partitions(bin_path: Path, config_path: Path) -> TerminalRespo for line in activate_sideload(bin_path): yield line # now sideload the script - sleep(5) logger.info("Sideload the copy_partitions script") for line in adb_sideload( bin_path=bin_path, @@ -148,7 +171,6 @@ def adb_twrp_copy_partitions(bin_path: Path, config_path: Path) -> TerminalRespo # reboot into the bootloader again for line in adb_reboot_bootloader(bin_path): yield line - sleep(7) # Copy partitions end # yield True @@ -180,7 +202,9 @@ def adb_twrp_wipe_and_install( Only works for twrp recovery. """ logger.info("Wipe and format data with twrp, then install os image.") - sleep(7) + for line in adb_wait_for_recovery(bin_path): + yield line + # now perform a factory reset for line in adb_twrp_format_data(bin_path): yield line @@ -197,7 +221,6 @@ def adb_twrp_wipe_and_install( for line in activate_sideload(bin_path=bin_path): yield line # now flash os image - sleep(5) logger.info("Sideload and install os image.") for line in adb_sideload(bin_path=bin_path, target=target): yield line @@ -210,9 +233,9 @@ def adb_twrp_wipe_and_install( if (type(line) == bool) and not line: logger.error(f"Wiping {partition} failed.") # TODO: if this fails, a fix can be to just sideload something and then adb reboot - for line in run_command( - f"adb sideload {config_path.parent.joinpath(Path('helper.txt'))}", - bin_path, + for line in adb_sideload( + target=f"{config_path.parent.joinpath(Path('helper.txt'))}", + bin_path=bin_path, ): yield line if (type(line) == bool) and not line: @@ -226,13 +249,11 @@ def adb_twrp_wipe_and_install( # reboot into the bootloader again for line in adb_reboot_bootloader(bin_path): yield line - sleep(3) # boot to TWRP again for line in fastboot_flash_recovery( bin_path=bin_path, recovery=recovery, is_ab=is_ab ): yield line - sleep(7) else: # if not an a/b-device just stay in twrp pass @@ -249,14 +270,13 @@ def adb_twrp_install_addons( Only works for twrp recovery. """ logger.info("Install addons with twrp.") - sleep(5) + sleep(0.5) logger.info("Sideload and install addons.") for addon in addons: # activate sideload logger.info("Activate sideload.") for line in activate_sideload(bin_path=bin_path): yield line - sleep(5) # now flash os image for line in adb_sideload(bin_path=bin_path, target=addon): yield line @@ -267,7 +287,6 @@ def adb_twrp_install_addons( # reboot into the bootloader again for line in adb_reboot_bootloader(bin_path=bin_path): yield line - sleep(3) # switch active boot partition for line in fastboot_switch_partition(bin_path=bin_path): yield line @@ -285,6 +304,13 @@ def adb_twrp_install_addons( yield line +@add_logging("Wait for bootloader") +def fastboot_wait_for_bootloader(bin_path: Path) -> TerminalResponse: + """Use adb to wait for the bootloader to become available.""" + for line in run_command("fastboot devices", bin_path): + yield line + + @add_logging("Switch active boot partitions.", return_if_fail=True) def fastboot_switch_partition(bin_path: Path) -> TerminalResponse: """Switch the active boot partition with fastboot.""" @@ -334,11 +360,19 @@ def fastboot_flash_recovery( """Temporarily, flash custom recovery with fastboot.""" if is_ab: logger.info("Boot custom recovery with fastboot.") - for line in run_command(f"fastboot boot {recovery}", bin_path): + for line in run_command( + "fastboot boot", target=f"{recovery}", bin_path=bin_path + ): + yield line + for line in adb_wait_for_recovery(bin_path=bin_path): yield line else: logger.info("Flash custom recovery with fastboot.") - for line in run_command(f"fastboot flash recovery {recovery}", bin_path): + for line in run_command( + "fastboot flash recovery", target=f"{recovery}", bin_path=bin_path + ): + yield line + for line in adb_wait_for_recovery(bin_path=bin_path): yield line if (type(line) == bool) and not line: logger.error("Flashing recovery failed.") @@ -349,12 +383,16 @@ def fastboot_flash_recovery( logger.info("Boot into TWRP with fastboot.") for line in run_command("fastboot reboot recovery", bin_path): yield line + for line in adb_wait_for_recovery(bin_path=bin_path): + yield line def fastboot_flash_boot(bin_path: Path, recovery: str) -> TerminalResponse: """Temporarily, flash custom recovery with fastboot to boot partition.""" logger.info("Flash custom recovery with fastboot.") - for line in run_command(f"fastboot flash boot {recovery}", bin_path): + for line in run_command( + "fastboot flash boot", target="f{recovery}", bin_path=bin_path + ): yield line if (type(line) == bool) and not line: logger.error("Flashing recovery failed.") @@ -365,6 +403,8 @@ def fastboot_flash_boot(bin_path: Path, recovery: str) -> TerminalResponse: logger.info("Boot into TWRP with fastboot.") for line in run_command("fastboot reboot", bin_path): yield line + for line in adb_wait_for_recovery(bin_path=bin_path): + yield line if (type(line) == bool) and not line: logger.error("Booting recovery failed.") yield False @@ -372,11 +412,21 @@ def fastboot_flash_boot(bin_path: Path, recovery: str) -> TerminalResponse: yield True +def heimdall_wait_for_download_available(bin_path: Path) -> bool: + """Use heimdall detect to wait for download mode to become available on the device.""" + logger.info("Wait for download mode to become available.") + while True: + sleep(1) + for line in run_command("heimdall detect", bin_path=bin_path): + if (type(line) == bool) and line: + return True + + @add_logging("Flash custom recovery with heimdall.") def heimdall_flash_recovery(bin_path: Path, recovery: str) -> TerminalResponse: """Temporarily, flash custom recovery with heimdall.""" for line in run_command( - f"heimdall flash --no-reboot --RECOVERY {recovery}", bin_path + "heimdall flash --no-reboot --RECOVERY", target=f"{recovery}", bin_path=bin_path ): yield line diff --git a/openandroidinstaller/widgets.py b/openandroidinstaller/widgets.py index fe479767..d57c006f 100644 --- a/openandroidinstaller/widgets.py +++ b/openandroidinstaller/widgets.py @@ -42,7 +42,12 @@ def __init__(self, expand: bool = True, visible: bool = False): def build(self): self._box = Container( - content=Column(scroll="auto", expand=True, auto_scroll=True), + content=Column( + controls=[Text("", selectable=True)], + scroll="auto", + expand=True, + auto_scroll=True, + ), margin=10, padding=10, alignment=alignment.top_left, @@ -61,7 +66,10 @@ def write_line(self, line: str): Ignores empty lines. """ if (type(line) == str) and line.strip(): - self._box.content.controls.append(Text(f">{line.strip()}", selectable=True)) + self._box.content.controls[0].value += f"\n>{line.strip()}" + self._box.content.controls[0].value = self._box.content.controls[ + 0 + ].value.strip("\n") self.update() def toggle_visibility(self): @@ -72,7 +80,7 @@ def toggle_visibility(self): def clear(self): """Clear terminal output.""" - self._box.content.controls = [] + self._box.content.controls[0].value = "" self.update() def update(self): diff --git a/pyproject.toml b/pyproject.toml index 87963e9f..e3b7166a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "openandroidinstaller" -version = "0.4.0-beta" +version = "0.4.1-beta" description = "Install lineage OS in a nice and easy way." authors = ["Tobias Sterbak "] license = "GPLv3" diff --git a/tests/test_app.py b/tests/test_app.py index 93d25509..cb11a16e 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -34,7 +34,7 @@ def send_commands(self, command, other): return MockResult() -def test_app(): +def test_app_sargo(): page = ft.Page(conn=MockConn(), session_id=1) # test if it would start up main(page=page, test=True, test_config="sargo") @@ -47,3 +47,18 @@ def test_app(): for _ in range(number_of_steps): page.controls[0].to_next_view(None) assert "SuccessView" in str(page.controls[0].view.controls[0]) + + +def test_app_beyond2lte(): + page = ft.Page(conn=MockConn(), session_id=1) + # test if it would start up + main(page=page, test=True, test_config="beyond2lte") + + # test if you can go through all views + state = page.controls[0].state + state.load_config(device_code="sargo") + state.default_views.extend(state.addon_views) + number_of_steps = 14 + for _ in range(number_of_steps): + page.controls[0].to_next_view(None) + assert "SuccessView" in str(page.controls[0].view.controls[0]) diff --git a/tests/test_terminal_box.py b/tests/test_terminal_box.py index 526254c5..6a530e50 100644 --- a/tests/test_terminal_box.py +++ b/tests/test_terminal_box.py @@ -42,8 +42,8 @@ def test_write_lines(mocker): for line in ["test", "test_line2", True]: terminal_box.write_line(line) - # two text elements should appear - assert len(terminal_box._box.content.controls) == 2 + # two lines of text should appear + assert len(terminal_box._box.content.controls[0].value.split("\n")) == 2 def test_toggle_visibility(mocker): @@ -87,5 +87,5 @@ def test_clear_terminal(mocker): # now clear terminal_box.clear() - # two text elements should appear - assert len(terminal_box._box.content.controls) == 0 + # text element should be empty + assert terminal_box._box.content.controls[0].value == "" diff --git a/tests/test_tooling.py b/tests/test_tooling.py index c2195d67..c66f6e97 100644 --- a/tests/test_tooling.py +++ b/tests/test_tooling.py @@ -16,7 +16,11 @@ from pathlib import Path from subprocess import CalledProcessError -from openandroidinstaller.tooling import adb_reboot, search_device, check_ab_partition +from openandroidinstaller.tooling import ( + adb_reboot, + search_device, + check_ab_partition, +) def test_adb_reboot_success(fp):