diff --git a/Makefile b/Makefile index e219737e..4b7aeae7 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ format: lint: poetry run ruff openandroidinstaller/ --ignore E501 +typing: + poetry run mypy openandroidinstaller/. --ignore-missing-imports + test: format lint PYTHONPATH=openandroidinstaller:$(PYTHONPATH) poetry run pytest --cov=openandroidinstaller tests/ diff --git a/README.md b/README.md index 2d7e904d..f73e9314 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@

-> **Warning**: This application is currently in alpha state, so use at your own risk! While many people tested the application so far and we heard of no bricked devices, thinks might still go wrong. +> **Warning**: This application is currently in beta state, so use at your own risk! While many people tested the application so far and we heard of no bricked devices, thinks might still go wrong. > **Note**: Unlocking the bootloader will erase all data on your device! This also includes your DRM keys, which are stored in the Trim Area partition (also called TA). @@ -40,16 +40,23 @@ Linux is currently the best supported platform (tested with Ubuntu 20.04/22.04 L 1. Download the AppImage, .exe or appropriate executable file for your OS. You might need to change permissions to run the executable. - On Windows also [install the Universal USB Drivers](https://adb.clockworkmod.com/) and other potentially drivers needed for your device. -2. Download the custom ROM image and the TWRP recovery image for your device. A source for files can be found on the following websites: - - some custom ROMs: - - [LineageOS](https://wiki.lineageos.org/devices/) - - [/e/OS](https://doc.e.foundation/devices) - - [LineageOS for microg](https://download.lineage.microg.org/) - - [BlissRoms](https://blissroms.org/) - - [PixelExperience](https://download.pixelexperience.org/) - - TWRP Recovery: - - [TWRP recovery](https://twrp.me/Devices/) - - or you can just search the web or the [xda-developers forum](https://forum.xda-developers.com) for an appropriate version for your device. +2. Download the custom ROM image and the TWRP recovery image for your device and optionally some addons. A source for files can be found on the following websites: + - some custom ROMs: + - [LineageOS](https://wiki.lineageos.org/devices/) + - [/e/OS](https://doc.e.foundation/devices) + - [LineageOS for microg](https://download.lineage.microg.org/) + - [BlissRoms](https://blissroms.org/) + - [PixelExperience](https://download.pixelexperience.org/) + - TWRP Recovery: + - [TWRP recovery](https://twrp.me/Devices/) + - Optional Addons: + - There are different packages of *Google Apps* available. + - [MindTheGapps](https://wiki.lineageos.org/gapps#downloads) + - [NikGApps](https://nikgapps.com/) + - [MicroG](https://microg.org/) + - The recommended way to install MicroG is to use the zip file provided here: [https://github.com/FriendlyNeighborhoodShane/MinMicroG_releases/releases](https://github.com/FriendlyNeighborhoodShane/MinMicroG_releases/releases). + - [F-Droid App-Store](https://f-droid.org/en/packages/org.fdroid.fdroid.privileged.ota/). + - or you can just search the web or the [xda-developers forum](https://forum.xda-developers.com) for an appropriate version for your device. 3. Start the desktop app and follow the instructions. @@ -218,7 +225,7 @@ If you build the application for your platform and want to contribute the build, #### On unlocking the bootloader Devices by *Samsung*, *Google* and *Fairphone* make it fairly easy to unlock the bootloader and receive good support in the installer. -Some devices with require manual steps to unlock the bootloader. In general you will need to create an account at a vendor website and receive some code from there. OpenAndroidInstaller will try to guide you as far as possible. These vendors include *Sony, Motorola, Xiaomi* among others. +Some devices with require manual steps to unlock the bootloader. In general you will need to create an account at a vendor website and receive some code from there. OpenAndroidInstaller will try to guide you as far as possible. These vendors include *Sony, Motorola, Xiaomi* and *OnePlus* among others. Other phone vendors stops allowing to unlock the bootloader all together. There is nothing to be done if you didn't unlock your device in time. These vendors include *Huawei and LG* among others. Support for these vendors will always be very limited. diff --git a/openandroidinstaller/app_state.py b/openandroidinstaller/app_state.py index ed0b8eae..e81cedd3 100644 --- a/openandroidinstaller/app_state.py +++ b/openandroidinstaller/app_state.py @@ -13,7 +13,9 @@ # If not, see .""" # Author: Tobias Sterbak +import copy from pathlib import Path +from typing import List, Optional from installer_config import _load_config @@ -27,7 +29,7 @@ def __init__( config_path: Path, bin_path: Path, test: bool = False, - test_config: str = None, + test_config: Optional[str] = None, ): self.platform = platform self.config_path = config_path @@ -37,19 +39,33 @@ def __init__( # placeholders self.advanced = False + self.install_addons = False self.config = None self.image_path = None self.recovery_path = None + self.is_ab = None - # is this still needed? - self.steps = None + # store views + self.default_views: List = [] + self.addon_views: List = [] + self.final_default_views: List = [] + + def add_default_views(self, views: List): + """Add default views to store""" + self.default_views.extend(views) + + def add_addon_views(self, views: List): + """Add addon views to store""" + self.addon_views.extend(views) + + def add_final_default_views(self, views: List): + """Add final default views to store""" + self.final_default_views.extend(views) def load_config(self, device_code: str): """Load the config from file to state by device code.""" self.config = _load_config(device_code, self.config_path) if self.config: - self.steps = ( - self.config.unlock_bootloader - + self.config.flash_recovery - + self.config.install_os + self.steps = copy.deepcopy(self.config.unlock_bootloader) + copy.deepcopy( + self.config.flash_recovery ) diff --git a/openandroidinstaller/assets/configs/FP2.yaml b/openandroidinstaller/assets/configs/FP2.yaml index 19f1ded4..8149c8b4 100644 --- a/openandroidinstaller/assets/configs/FP2.yaml +++ b/openandroidinstaller/assets/configs/FP2.yaml @@ -18,12 +18,4 @@ steps: - type: confirm_button content: > Now reboot into recovery to verify the installation. Do not reboot into the existing OS, since it will overwrite the recovery you just installed! - With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/FP3.yaml b/openandroidinstaller/assets/configs/FP3.yaml index 31810217..5fc45c57 100644 --- a/openandroidinstaller/assets/configs/FP3.yaml +++ b/openandroidinstaller/assets/configs/FP3.yaml @@ -43,12 +43,4 @@ steps: - type: confirm_button content: > Now reboot into recovery to verify the installation. Do not reboot into the existing OS, since it will overwrite the recovery you just installed! - With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/FP4.yaml b/openandroidinstaller/assets/configs/FP4.yaml index 59e5e6ff..a5f5c436 100644 --- a/openandroidinstaller/assets/configs/FP4.yaml +++ b/openandroidinstaller/assets/configs/FP4.yaml @@ -43,12 +43,4 @@ steps: - type: confirm_button content: > Now reboot into recovery to verify the installation. Do not reboot into the existing OS, since it will overwrite the recovery you just installed! - With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/a3y17lte.yaml b/openandroidinstaller/assets/configs/a3y17lte.yaml index d21410b1..940746dc 100644 --- a/openandroidinstaller/assets/configs/a3y17lte.yaml +++ b/openandroidinstaller/assets/configs/a3y17lte.yaml @@ -21,12 +21,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/a5xelte.yaml b/openandroidinstaller/assets/configs/a5xelte.yaml index 617b7657..4d4d40bb 100644 --- a/openandroidinstaller/assets/configs/a5xelte.yaml +++ b/openandroidinstaller/assets/configs/a5xelte.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/a72q.yaml b/openandroidinstaller/assets/configs/a72q.yaml index ef470a10..3d1290a0 100644 --- a/openandroidinstaller/assets/configs/a72q.yaml +++ b/openandroidinstaller/assets/configs/a72q.yaml @@ -19,12 +19,4 @@ steps: content: > Unplug the USB cable from your device. Then manually reboot into recovery by pressing the *Volume Down* + *Power* 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* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/a7xelte.yaml b/openandroidinstaller/assets/configs/a7xelte.yaml index 6b3e383b..4f680c97 100644 --- a/openandroidinstaller/assets/configs/a7xelte.yaml +++ b/openandroidinstaller/assets/configs/a7xelte.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/akari.yaml b/openandroidinstaller/assets/configs/akari.yaml index cc4ff41b..8e971d37 100644 --- a/openandroidinstaller/assets/configs/akari.yaml +++ b/openandroidinstaller/assets/configs/akari.yaml @@ -42,21 +42,13 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery + command: fastboot_flash_boot - type: call_button command: adb_twrp_copy_partitions content: > In some cases, the inactive slot can be unpopulated or contain much older firmware than the active slot, leading to various issues including a potential hard-brick. We can ensure none of that will happen by copying the contents of the active slot to the inactive slot. Press 'confirm and run' to to this. Once you are in the bootloader again, continue. - type: call_button - command: fastboot_flash_recovery + command: fastboot_flash_boot content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/akatsuki.yaml b/openandroidinstaller/assets/configs/akatsuki.yaml index ca23c998..ecafe733 100644 --- a/openandroidinstaller/assets/configs/akatsuki.yaml +++ b/openandroidinstaller/assets/configs/akatsuki.yaml @@ -42,21 +42,13 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery + command: fastboot_flash_boot - type: call_button command: adb_twrp_copy_partitions content: > In some cases, the inactive slot can be unpopulated or contain much older firmware than the active slot, leading to various issues including a potential hard-brick. We can ensure none of that will happen by copying the contents of the active slot to the inactive slot. Press 'confirm and run' to to this. Once you are in the bootloader again, continue. - type: call_button - command: fastboot_flash_recovery + command: fastboot_flash_boot content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/avicii.yaml b/openandroidinstaller/assets/configs/avicii.yaml index 4f849e07..99cc545f 100644 --- a/openandroidinstaller/assets/configs/avicii.yaml +++ b/openandroidinstaller/assets/configs/avicii.yaml @@ -42,12 +42,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/barbet.yaml b/openandroidinstaller/assets/configs/barbet.yaml index 94b4dc9e..8471f0de 100644 --- a/openandroidinstaller/assets/configs/barbet.yaml +++ b/openandroidinstaller/assets/configs/barbet.yaml @@ -41,12 +41,4 @@ steps: content: Select 'Restart bootloader' on your smartphone screen. Then confirm to continue. - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/beyond1lte.yaml b/openandroidinstaller/assets/configs/beyond1lte.yaml index 57d9cb45..6deef617 100644 --- a/openandroidinstaller/assets/configs/beyond1lte.yaml +++ b/openandroidinstaller/assets/configs/beyond1lte.yaml @@ -21,12 +21,4 @@ steps: 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*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Bixby* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/blueline.yaml b/openandroidinstaller/assets/configs/blueline.yaml index e6570860..680d63c5 100644 --- a/openandroidinstaller/assets/configs/blueline.yaml +++ b/openandroidinstaller/assets/configs/blueline.yaml @@ -34,12 +34,4 @@ steps: - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. command: fastboot_flash_recovery - img: twrp-start.jpeg - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + img: twrp-start.jpeg \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/bonito.yaml b/openandroidinstaller/assets/configs/bonito.yaml index 5c42f26b..694ce1cc 100644 --- a/openandroidinstaller/assets/configs/bonito.yaml +++ b/openandroidinstaller/assets/configs/bonito.yaml @@ -34,12 +34,4 @@ steps: - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. command: fastboot_flash_recovery - img: twrp-start.jpeg - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + img: twrp-start.jpeg \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/cedric.yaml b/openandroidinstaller/assets/configs/cedric.yaml index 2f391028..bb260c21 100644 --- a/openandroidinstaller/assets/configs/cedric.yaml +++ b/openandroidinstaller/assets/configs/cedric.yaml @@ -43,12 +43,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/cheeseburger.yaml b/openandroidinstaller/assets/configs/cheeseburger.yaml index 2c708d41..6a825fa9 100644 --- a/openandroidinstaller/assets/configs/cheeseburger.yaml +++ b/openandroidinstaller/assets/configs/cheeseburger.yaml @@ -32,12 +32,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/coral.yaml b/openandroidinstaller/assets/configs/coral.yaml index ccf2dc03..e9647828 100644 --- a/openandroidinstaller/assets/configs/coral.yaml +++ b/openandroidinstaller/assets/configs/coral.yaml @@ -41,12 +41,4 @@ steps: content: Select 'Restart bootloader' on your smartphone screen. Then confirm to continue. - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/crosshatch.yaml b/openandroidinstaller/assets/configs/crosshatch.yaml index 21176ce1..a4a485a2 100644 --- a/openandroidinstaller/assets/configs/crosshatch.yaml +++ b/openandroidinstaller/assets/configs/crosshatch.yaml @@ -34,12 +34,4 @@ steps: - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. command: fastboot_flash_recovery - img: twrp-start.jpeg - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + img: twrp-start.jpeg \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/crownlte.yaml b/openandroidinstaller/assets/configs/crownlte.yaml index 5084849b..38a922c4 100644 --- a/openandroidinstaller/assets/configs/crownlte.yaml +++ b/openandroidinstaller/assets/configs/crownlte.yaml @@ -21,12 +21,4 @@ steps: 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*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Bixby* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/d1.yaml b/openandroidinstaller/assets/configs/d1.yaml index 60bde268..431d49a0 100644 --- a/openandroidinstaller/assets/configs/d1.yaml +++ b/openandroidinstaller/assets/configs/d1.yaml @@ -21,12 +21,4 @@ steps: 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*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Bixby* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/dre.yaml b/openandroidinstaller/assets/configs/dre.yaml index dc4858ab..1b8be02a 100644 --- a/openandroidinstaller/assets/configs/dre.yaml +++ b/openandroidinstaller/assets/configs/dre.yaml @@ -42,12 +42,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/dumpling.yaml b/openandroidinstaller/assets/configs/dumpling.yaml index 78626267..a2324245 100644 --- a/openandroidinstaller/assets/configs/dumpling.yaml +++ b/openandroidinstaller/assets/configs/dumpling.yaml @@ -32,12 +32,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/enchilada.yaml b/openandroidinstaller/assets/configs/enchilada.yaml index a55bcb32..e1da4282 100644 --- a/openandroidinstaller/assets/configs/enchilada.yaml +++ b/openandroidinstaller/assets/configs/enchilada.yaml @@ -42,12 +42,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/evert.yaml b/openandroidinstaller/assets/configs/evert.yaml index 88c9bbf7..790c1e0f 100644 --- a/openandroidinstaller/assets/configs/evert.yaml +++ b/openandroidinstaller/assets/configs/evert.yaml @@ -52,12 +52,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/fajita.yaml b/openandroidinstaller/assets/configs/fajita.yaml index 1660ed4f..8ce4c1a2 100644 --- a/openandroidinstaller/assets/configs/fajita.yaml +++ b/openandroidinstaller/assets/configs/fajita.yaml @@ -42,12 +42,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/flame.yaml b/openandroidinstaller/assets/configs/flame.yaml index 08437fad..2bbd5d31 100644 --- a/openandroidinstaller/assets/configs/flame.yaml +++ b/openandroidinstaller/assets/configs/flame.yaml @@ -41,12 +41,4 @@ steps: content: Select 'Restart bootloader' on your smartphone screen. Then confirm to continue. - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/griffin.yaml b/openandroidinstaller/assets/configs/griffin.yaml index 1f321c9a..36d18192 100644 --- a/openandroidinstaller/assets/configs/griffin.yaml +++ b/openandroidinstaller/assets/configs/griffin.yaml @@ -43,12 +43,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/guacamole.yaml b/openandroidinstaller/assets/configs/guacamole.yaml index a85c5e6e..129d7b98 100644 --- a/openandroidinstaller/assets/configs/guacamole.yaml +++ b/openandroidinstaller/assets/configs/guacamole.yaml @@ -33,12 +33,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/guacamoleb.yaml b/openandroidinstaller/assets/configs/guacamoleb.yaml index 8c8f35d0..e39c9378 100644 --- a/openandroidinstaller/assets/configs/guacamoleb.yaml +++ b/openandroidinstaller/assets/configs/guacamoleb.yaml @@ -33,12 +33,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/hero2lte.yaml b/openandroidinstaller/assets/configs/hero2lte.yaml index 5d411923..4ec35346 100644 --- a/openandroidinstaller/assets/configs/hero2lte.yaml +++ b/openandroidinstaller/assets/configs/hero2lte.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/herolte.yaml b/openandroidinstaller/assets/configs/herolte.yaml index a14f2028..4dcf7f8b 100644 --- a/openandroidinstaller/assets/configs/herolte.yaml +++ b/openandroidinstaller/assets/configs/herolte.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/heroltexx.yaml b/openandroidinstaller/assets/configs/heroltexx.yaml new file mode 100644 index 00000000..4dcf7f8b --- /dev/null +++ b/openandroidinstaller/assets/configs/heroltexx.yaml @@ -0,0 +1,22 @@ +metadata: + maintainer: Tobias Sterbak (tsterbak) + devicename: Samsung Galaxy S7 + devicecode: herolte +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.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 & release the buttons immediately when it does, then boot to recovery with the device powered off, + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/hltetmo.yaml b/openandroidinstaller/assets/configs/hltetmo.yaml index fc492ae9..dc5c6eb1 100644 --- a/openandroidinstaller/assets/configs/hltetmo.yaml +++ b/openandroidinstaller/assets/configs/hltetmo.yaml @@ -21,12 +21,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/hotdog.yaml b/openandroidinstaller/assets/configs/hotdog.yaml index 763b8bc0..15cc7015 100644 --- a/openandroidinstaller/assets/configs/hotdog.yaml +++ b/openandroidinstaller/assets/configs/hotdog.yaml @@ -33,12 +33,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/hotdogb.yaml b/openandroidinstaller/assets/configs/hotdogb.yaml index 879e81e1..da1c487a 100644 --- a/openandroidinstaller/assets/configs/hotdogb.yaml +++ b/openandroidinstaller/assets/configs/hotdogb.yaml @@ -33,12 +33,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/j7elte.yaml b/openandroidinstaller/assets/configs/j7elte.yaml index 8d540b0c..99390c17 100644 --- a/openandroidinstaller/assets/configs/j7elte.yaml +++ b/openandroidinstaller/assets/configs/j7elte.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/kiev.yaml b/openandroidinstaller/assets/configs/kiev.yaml index bf306f68..607a16a4 100644 --- a/openandroidinstaller/assets/configs/kiev.yaml +++ b/openandroidinstaller/assets/configs/kiev.yaml @@ -52,12 +52,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/kirin.yaml b/openandroidinstaller/assets/configs/kirin.yaml index 60f7db1f..6418fbaf 100644 --- a/openandroidinstaller/assets/configs/kirin.yaml +++ b/openandroidinstaller/assets/configs/kirin.yaml @@ -40,21 +40,13 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery + command: fastboot_flash_boot - type: call_button command: adb_twrp_copy_partitions content: > In some cases, the inactive slot can be unpopulated or contain much older firmware than the active slot, leading to various issues including a potential hard-brick. We can ensure none of that will happen by copying the contents of the active slot to the inactive slot. Press 'confirm and run' to to this. Once you are in the bootloader again, continue. - type: call_button - command: fastboot_flash_recovery + command: fastboot_flash_boot content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/mermaid.yaml b/openandroidinstaller/assets/configs/mermaid.yaml index 80fd8a04..8a0861ef 100644 --- a/openandroidinstaller/assets/configs/mermaid.yaml +++ b/openandroidinstaller/assets/configs/mermaid.yaml @@ -40,21 +40,13 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery + command: fastboot_flash_boot - type: call_button command: adb_twrp_copy_partitions content: > In some cases, the inactive slot can be unpopulated or contain much older firmware than the active slot, leading to various issues including a potential hard-brick. We can ensure none of that will happen by copying the contents of the active slot to the inactive slot. Press 'confirm and run' to to this. Once you are in the bootloader again, continue. - type: call_button - command: fastboot_flash_recovery + command: fastboot_flash_boot content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/nairo.yaml b/openandroidinstaller/assets/configs/nairo.yaml index 8fc46111..968aafef 100644 --- a/openandroidinstaller/assets/configs/nairo.yaml +++ b/openandroidinstaller/assets/configs/nairo.yaml @@ -52,12 +52,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/ocean.yaml b/openandroidinstaller/assets/configs/ocean.yaml index ee5df871..0d9dceee 100644 --- a/openandroidinstaller/assets/configs/ocean.yaml +++ b/openandroidinstaller/assets/configs/ocean.yaml @@ -52,12 +52,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/pioneer.yaml b/openandroidinstaller/assets/configs/pioneer.yaml index 85303ed6..a5ea1fbc 100644 --- a/openandroidinstaller/assets/configs/pioneer.yaml +++ b/openandroidinstaller/assets/configs/pioneer.yaml @@ -42,21 +42,13 @@ steps: command: adb_reboot_bootloader - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery + command: fastboot_flash_boot - type: call_button command: adb_twrp_copy_partitions content: > In some cases, the inactive slot can be unpopulated or contain much older firmware than the active slot, leading to various issues including a potential hard-brick. We can ensure none of that will happen by copying the contents of the active slot to the inactive slot. Press 'confirm and run' to to this. Once you are in the bootloader again, continue. - type: call_button - command: fastboot_flash_recovery + command: fastboot_flash_boot content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/racer.yaml b/openandroidinstaller/assets/configs/racer.yaml index 81f98251..50d888d8 100644 --- a/openandroidinstaller/assets/configs/racer.yaml +++ b/openandroidinstaller/assets/configs/racer.yaml @@ -52,12 +52,4 @@ steps: - type: call_button command: fastboot_flash_recovery content: > - Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. - install_os: - - type: call_button - content: > - In this last step, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/redfin.yaml b/openandroidinstaller/assets/configs/redfin.yaml index bbf6807a..df12f3b4 100644 --- a/openandroidinstaller/assets/configs/redfin.yaml +++ b/openandroidinstaller/assets/configs/redfin.yaml @@ -41,12 +41,4 @@ steps: content: Select 'Restart bootloader' on your smartphone screen. Then confirm to continue. - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/s3ve3g.yaml b/openandroidinstaller/assets/configs/s3ve3g.yaml index c0e753d1..c7c1d67d 100644 --- a/openandroidinstaller/assets/configs/s3ve3g.yaml +++ b/openandroidinstaller/assets/configs/s3ve3g.yaml @@ -34,12 +34,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/sargo.yaml b/openandroidinstaller/assets/configs/sargo.yaml index ed40f9ac..2e19de38 100644 --- a/openandroidinstaller/assets/configs/sargo.yaml +++ b/openandroidinstaller/assets/configs/sargo.yaml @@ -34,12 +34,4 @@ steps: - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. command: fastboot_flash_recovery - img: twrp-start.jpeg - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + img: twrp-start.jpeg \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/starlte.yaml b/openandroidinstaller/assets/configs/starlte.yaml index e3e8b77f..3b09a481 100644 --- a/openandroidinstaller/assets/configs/starlte.yaml +++ b/openandroidinstaller/assets/configs/starlte.yaml @@ -20,12 +20,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold Volume Up + Bixby + Power. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold Volume Up + Bixby + Power. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/sunfish.yaml b/openandroidinstaller/assets/configs/sunfish.yaml index 75d7b326..b91a734d 100644 --- a/openandroidinstaller/assets/configs/sunfish.yaml +++ b/openandroidinstaller/assets/configs/sunfish.yaml @@ -41,12 +41,4 @@ steps: content: Select 'Restart bootloader' on your smartphone screen. Then confirm to continue. - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_recovery \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/taimen.yaml b/openandroidinstaller/assets/configs/taimen.yaml index 7c03eca2..64382154 100644 --- a/openandroidinstaller/assets/configs/taimen.yaml +++ b/openandroidinstaller/assets/configs/taimen.yaml @@ -34,12 +34,4 @@ steps: - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. command: fastboot_flash_recovery - img: twrp-start.jpeg - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + img: twrp-start.jpeg \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/walleye.yaml b/openandroidinstaller/assets/configs/walleye.yaml index f32be2a1..7b95c9ba 100644 --- a/openandroidinstaller/assets/configs/walleye.yaml +++ b/openandroidinstaller/assets/configs/walleye.yaml @@ -34,12 +34,4 @@ steps: - type: call_button content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once your phone screen looks like the picture on the left, continue. command: fastboot_flash_recovery - img: twrp-start.jpeg - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Wait until the TWRP screen appears. Then run the command. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + img: twrp-start.jpeg \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/yuga.yaml b/openandroidinstaller/assets/configs/yuga.yaml index d7b3a30b..16409933 100644 --- a/openandroidinstaller/assets/configs/yuga.yaml +++ b/openandroidinstaller/assets/configs/yuga.yaml @@ -37,12 +37,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Next, you need to flash a custom recovery image. Press the button to flash the selected image. Then continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_boot \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/z3.yaml b/openandroidinstaller/assets/configs/z3.yaml index 54eb3553..e9f5c797 100644 --- a/openandroidinstaller/assets/configs/z3.yaml +++ b/openandroidinstaller/assets/configs/z3.yaml @@ -39,12 +39,4 @@ steps: command: adb_reboot_bootloader - type: call_button content: Next, you need to flash a custom recovery image. Press the button to flash the selected image. Then continue. - command: fastboot_flash_recovery - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + command: fastboot_flash_boot \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/zerofltexx.yaml b/openandroidinstaller/assets/configs/zerofltexx.yaml index 736839d7..ad084e4f 100644 --- a/openandroidinstaller/assets/configs/zerofltexx.yaml +++ b/openandroidinstaller/assets/configs/zerofltexx.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/assets/configs/zeroltexx.yaml b/openandroidinstaller/assets/configs/zeroltexx.yaml index d16d27d4..0830241c 100644 --- a/openandroidinstaller/assets/configs/zeroltexx.yaml +++ b/openandroidinstaller/assets/configs/zeroltexx.yaml @@ -19,12 +19,4 @@ steps: 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 & release the buttons immediately when it does, then boot to recovery with the device powered off, - hold *Volume Up* + *Home* + *Power button*. - install_os: - - type: call_button - content: > - In the next steps, you finally flash the selected OS image. - Connect your device with your computer with the USB-Cable. - This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored - in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS. - command: adb_twrp_wipe_and_install \ No newline at end of file + hold *Volume Up* + *Home* + *Power button*. \ No newline at end of file diff --git a/openandroidinstaller/installer_config.py b/openandroidinstaller/installer_config.py index 4fb8580c..62aa1a01 100644 --- a/openandroidinstaller/installer_config.py +++ b/openandroidinstaller/installer_config.py @@ -14,7 +14,7 @@ # Author: Tobias Sterbak from pathlib import Path -from typing import List, Optional +from typing import List, Optional, Dict import schema import yaml @@ -34,10 +34,10 @@ def __init__( title: str, type: str, content: str, - command: str = None, - img: str = None, allow_skip: bool = False, - link: str = None, + command: Optional[str] = None, + img: Optional[str] = None, + link: Optional[str] = None, ): self.title = title self.type = type @@ -51,7 +51,7 @@ def __init__( class InstallerConfig: # map some detected device codes to their real code. - device_code_mapping = { + device_code_mapping: Dict[str, str] = { # Sony issues "C6603": "yuga", # OnePlus issues @@ -71,20 +71,20 @@ def __init__( self, unlock_bootloader: List[Step], flash_recovery: List[Step], - install_os: List[Step], metadata: dict, requirements: dict, ): self.unlock_bootloader = unlock_bootloader self.flash_recovery = flash_recovery - self.install_os = install_os self.metadata = metadata self.requirements = requirements self.device_code = metadata.get("devicecode") self.twrp_link = metadata.get("twrp-link") - inverted_mapping = dict(map(reversed, self.device_code_mapping.items())) + + # manage device codes and alternative device codes/names + inverted_mapping: Dict[str, str] = dict(map(reversed, self.device_code_mapping.items())) # type: ignore self.alternative_device_code = inverted_mapping.get( - self.device_code, self.device_code + self.device_code, self.device_code # type: ignore ) @classmethod @@ -115,13 +115,7 @@ def from_file(cls, path): Step(**raw_step, title="Flash custom recovery") for raw_step in raw_steps.get("flash_recovery", []) ] - install_os = [ - Step(**raw_step, title="Install OS") - for raw_step in raw_steps.get("install_os", []) - ] - return cls( - unlock_bootloader, flash_recovery, install_os, metadata, requirements - ) + return cls(unlock_bootloader, flash_recovery, metadata, requirements) def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfig]: @@ -163,7 +157,7 @@ def validate_config(config: str) -> bool: ), "content": str, schema.Optional("command"): Regex( - r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|adb_twrp_copy_partitions|fastboot_flash_recovery|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery" + r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|adb_twrp_copy_partitions|fastboot_flash_recovery|fastboot_flash_boot|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery" ), schema.Optional("allow_skip"): bool, schema.Optional("img"): str, @@ -185,7 +179,6 @@ def validate_config(config: str) -> bool: "steps": { "unlock_bootloader": schema.Or(None, [step_schema]), "flash_recovery": [step_schema], - "install_os": [step_schema], }, } ) diff --git a/openandroidinstaller/openandroidinstaller.py b/openandroidinstaller/openandroidinstaller.py index 142c6a1c..a24c5f8f 100644 --- a/openandroidinstaller/openandroidinstaller.py +++ b/openandroidinstaller/openandroidinstaller.py @@ -19,6 +19,7 @@ import click import functools from pathlib import Path +from typing import List import flet as ft from flet import ( @@ -45,7 +46,10 @@ SuccessView, StartView, RequirementsView, + InstallView, WelcomeView, + AddonsView, + InstallAddonsView, ) from tooling import run_command @@ -53,7 +57,7 @@ logger.add("openandroidinstaller.log") # VERSION number -VERSION = "0.3.5-alpha" +VERSION = "0.4.0-beta" # detect platform PLATFORM = sys.platform @@ -91,27 +95,56 @@ def __init__(self, state: AppState): on_back=self.to_previous_view, state=self.state, ) - # ordered to allow for pop - self.default_views = [ - select_files_view, - requirements_view, - start_view, - welcome_view, - ] + + # create the install view + self.install_view = InstallView(on_confirm=self.to_next_view, state=self.state) + # create the final success view self.final_view = SuccessView(state=self.state) + # initialize the addon view + self.select_addon_view = AddonsView( + on_confirm=self.to_next_view, state=self.state + ) + self.install_addons_view = InstallAddonsView( + on_confirm=self.to_next_view, state=self.state + ) + + # attach some views to the state to modify and reuse later + # ordered to allow for pop + self.state.add_default_views( + views=[ + select_files_view, + requirements_view, + start_view, + welcome_view, + ] + ) + self.state.add_addon_views( + views=[ + self.install_addons_view, + self.select_addon_view, + ] + ) + # final default views, ordered to allow to pop + self.state.add_final_default_views( + views=[ + self.final_view, + self.install_view, + ] + ) + # stack of previous default views for the back-button - self.previous_views = [] + self.previous_views: List = [] def build(self): - self.view.controls.append(self.default_views.pop()) + self.view.controls.append(self.state.default_views.pop()) return self.view def to_previous_view(self, e): """Method to display the previous view.""" # store the current view - self.default_views.append(self.view.controls[-1]) + self.state.default_views.append(self.view.controls[-1]) # clear the current view self.view.controls = [] # retrieve the new view and update @@ -126,8 +159,8 @@ def to_next_view(self, e): # remove all elements from column view self.view.controls = [] # if there are default views left, display them first - if self.default_views: - self.view.controls.append(self.default_views.pop()) + if self.state.default_views: + self.view.controls.append(self.state.default_views.pop()) elif self.state.steps: self.view.controls.append( StepView( @@ -136,9 +169,13 @@ def to_next_view(self, e): on_confirm=self.to_next_view, ) ) - else: - # display the final view - self.view.controls.append(self.final_view) + elif self.state.final_default_views: + # here we expect the install view to populate the step views again if necessary + self.view.controls.append(self.state.final_default_views.pop()) + + # else: + # # display the final view + # self.view.controls.append(self.final_view) logger.info("Confirmed and moved to next step.") self.view.update() @@ -160,21 +197,18 @@ def log_version_infos(bin_path): """Log the version infos of adb, fastboot and heimdall.""" # adb adbversion = [ - line for line in run_command("adb", ["version"], bin_path, enable_logging=False) + line for line in run_command("adb version", bin_path, enable_logging=False) ] logger.info(f"{adbversion[1].strip()}") # fastboot fbversion = [ line - for line in run_command( - "fastboot", ["--version"], bin_path, enable_logging=False - ) + for line in run_command("fastboot --version", bin_path, enable_logging=False) ] logger.info(f"{fbversion[1].strip()}") # heimdall hdversion = [ - line - for line in run_command("heimdall", ["info"], bin_path, enable_logging=False) + line for line in run_command("heimdall info", bin_path, enable_logging=False) ] logger.info(f"Heimdall version: {hdversion[1].strip()}") diff --git a/openandroidinstaller/py.typed b/openandroidinstaller/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/openandroidinstaller/tooling.py b/openandroidinstaller/tooling.py index 3ecdc936..40162b19 100644 --- a/openandroidinstaller/tooling.py +++ b/openandroidinstaller/tooling.py @@ -17,144 +17,164 @@ from pathlib import Path import subprocess from subprocess import ( - Popen, PIPE, STDOUT, CalledProcessError, - CompletedProcess, check_output, ) +import shlex from time import sleep -from typing import List, Optional +from typing import List, Optional, Union, Generator, Callable from loguru import logger + +TerminalResponse = Generator[Union[str, bool], None, None] + + PLATFORM = sys.platform def run_command( - tool: str, command: List[str], bin_path: Path, enable_logging: bool = True -) -> CompletedProcess: + full_command: str, bin_path: Path, enable_logging: bool = True +) -> TerminalResponse: """Run a command with a tool (adb, fastboot, heimdall).""" - yield f"${' '.join([tool] + command )}" + yield f"${full_command}" + # split the command and extract the tool part + tool, *command = shlex.split(full_command) if tool not in ["adb", "fastboot", "heimdall"]: raise Exception(f"Unknown tool {tool}. Use adb, fastboot or heimdall.") if PLATFORM == "win32": - full_command = [str(bin_path.joinpath(Path(f"{tool}"))) + ".exe"] + command + command_list = [str(bin_path.joinpath(Path(f"{tool}"))) + ".exe"] + command # prevent Windows from opening terminal windows - si = subprocess.STARTUPINFO() - si.dwFlags |= subprocess.STARTF_USESHOWWINDOW + si = subprocess.STARTUPINFO() # type: ignore + si.dwFlags |= subprocess.STARTF_USESHOWWINDOW # type: ignore else: - full_command = [str(bin_path.joinpath(Path(f"{tool}")))] + command + command_list = [str(bin_path.joinpath(Path(f"{tool}")))] + command si = None if enable_logging: - logger.info(f"Run command: {full_command}") + logger.info(f"Run command: {command_list}") # run the command - with Popen( - full_command, + with subprocess.Popen( + command_list, stdout=PIPE, stderr=STDOUT, bufsize=1, universal_newlines=True, startupinfo=si, ) as p: - for line in p.stdout: + for line in p.stdout: # type: ignore if enable_logging: logger.info(line.strip()) - yield line + yield line.strip() + # finally return if the command was successful yield p.returncode == 0 -def adb_reboot(bin_path: Path) -> bool: +def add_logging(step_desc: str, return_if_fail: bool = False) -> Callable: + """Logging decorator to wrap functions that yield lines. + + Logs the `step_desc`. + """ + + def logging_decorator(func) -> Callable: + def logging(*args, **kwargs) -> TerminalResponse: + logger.info(f"{step_desc} - Paramters: {kwargs}") + for line in func(*args, **kwargs): + if (type(line) == bool) and not line: + logger.error(f"{step_desc} Failed!") + if return_if_fail: + yield False + return + yield line + + return logging + + return logging_decorator + + +@add_logging("Rebooting device with adb.") +def adb_reboot(bin_path: Path) -> TerminalResponse: """Run adb reboot on the device and return success.""" - logger.info("Rebooting device with adb.") - for line in run_command("adb", ["reboot"], bin_path): + for line in run_command("adb reboot", bin_path): yield line - if (type(line) == bool) and line: - logger.debug("Reboot failed.") - yield False - else: - yield True -def adb_reboot_bootloader(bin_path: Path) -> bool: +@add_logging("Rebooting device into bootloader with adb.", return_if_fail=True) +def adb_reboot_bootloader(bin_path: Path) -> TerminalResponse: """Reboot the device into bootloader and return success.""" - logger.info("Rebooting device into bootloader with adb.") - for line in run_command("adb", ["reboot", "bootloader"], bin_path): + for line in run_command("adb reboot bootloader", bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Reboot into bootloader failed.") - yield False - return sleep(1) - yield True -def adb_reboot_download(bin_path: Path) -> bool: +@add_logging("Rebooting device into download mode with adb.") +def adb_reboot_download(bin_path: Path) -> TerminalResponse: """Reboot the device into download mode of samsung devices and return success.""" - logger.info("Rebooting device into download mode with adb.") - for line in run_command("adb", ["reboot", "download"], bin_path): + for line in run_command("adb reboot download", bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Reboot into download mode failed.") - yield False - else: - # check if in download mode with heimdall? - yield True -def adb_sideload(bin_path: Path, target: str) -> bool: +@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.""" - logger.info("Rebooting device into bootloader with adb.") - for line in run_command("adb", ["sideload", target], bin_path): + for line in run_command(f"adb sideload {target}", bin_path): yield line - if (type(line) == bool) and line: - logger.info(f"Sideloading {target} failed.") - yield False - else: - yield True -def adb_twrp_copy_partitions(bin_path: Path, config_path: Path): +@add_logging("Activate sideloading in TWRP.", return_if_fail=True) +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 + + +def adb_twrp_copy_partitions(bin_path: Path, config_path: Path) -> TerminalResponse: # some devices like one plus 6t or motorola moto g7 power need the partitions copied to prevent a hard brick logger.info("Sideload copy_partitions script with adb.") # activate sideload - for line in run_command("adb", ["shell", "twrp", "sideload"], bin_path): + for line in activate_sideload(bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Activating sideload failed.") - yield False - return # now sideload the script sleep(5) logger.info("Sideload the copy_partitions script") - for line in run_command( - "adb", - [ - "sideload", - f"{config_path.parent.joinpath(Path('copy-partitions-20220613-signed.zip'))}", - ], - bin_path, + for line in adb_sideload( + bin_path=bin_path, + target=f"{config_path.parent.joinpath(Path('copy-partitions-20220613-signed.zip'))}", ): yield line - if (type(line) == bool) and not line: - logger.error("Sideloading copy-partitions-20220613-signed.zip failed.") sleep(10) # reboot into the bootloader again - logger.info("Rebooting device into bootloader with adb.") - for line in run_command("adb", ["reboot", "bootloader"], bin_path): + for line in adb_reboot_bootloader(bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Reboot into bootloader failed.") - yield False - return sleep(7) # Copy partitions end # - return True + yield True + + +@add_logging("Perform a factory reset with adb and twrp.", return_if_fail=True) +def adb_twrp_format_data(bin_path: Path) -> TerminalResponse: + """Perform a factory reset with twrp and adb.""" + for line in run_command("adb shell twrp format data", bin_path): + yield line -def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) -> bool: +@add_logging("Wipe the selected partition with adb and twrp.", return_if_fail=True) +def adb_twrp_wipe_partition(bin_path: Path, partition: str) -> TerminalResponse: + """Perform a factory reset with twrp and adb.""" + for line in run_command(f"adb shell twrp wipe {partition}", bin_path): + yield line + + +def adb_twrp_wipe_and_install( + bin_path: Path, + target: str, + config_path: Path, + is_ab: bool, + install_addons=True, + recovery: Optional[str] = None, +) -> TerminalResponse: """Wipe and format data with twrp, then flash os image with adb. Only works for twrp recovery. @@ -162,164 +182,210 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) -> logger.info("Wipe and format data with twrp, then install os image.") sleep(7) # now perform a factory reset - for line in run_command("adb", ["shell", "twrp", "format", "data"], bin_path): + for line in adb_twrp_format_data(bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Formatting data failed.") - yield False - return + sleep(1) # wipe some partitions for partition in ["cache", "system"]: - for line in run_command("adb", ["shell", "twrp", "wipe", partition], bin_path): - yield not line + for line in adb_twrp_wipe_partition(bin_path=bin_path, partition=partition): + yield line sleep(1) - if (type(line) == bool) and not line: - logger.error(f"Wiping {partition} failed.") - yield False - return + # activate sideload logger.info("Wiping is done, now activate sideload.") - for line in run_command("adb", ["shell", "twrp", "sideload"], bin_path): + for line in activate_sideload(bin_path=bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Activating sideload failed.") - yield False - return # now flash os image sleep(5) logger.info("Sideload and install os image.") - for line in run_command("adb", ["sideload", f"{target}"], bin_path): + for line in adb_sideload(bin_path=bin_path, target=target): yield line - if (type(line) == bool) and not line: - logger.error(f"Sideloading {target} failed.") - # TODO: this might sometimes think it failed, but actually it's fine. So skip for now. - # yield False - # return # wipe some cache partitions sleep(7) for partition in ["dalvik", "cache"]: - for line in run_command("adb", ["shell", "twrp", "wipe", partition], bin_path): + for line in run_command(f"adb shell twrp wipe {partition}", bin_path): yield line sleep(1) 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( - "adb", - ["sideload", f"{config_path.parent.joinpath(Path('helper.txt'))}"], + f"adb sideload {config_path.parent.joinpath(Path('helper.txt'))}", bin_path, ): yield line - sleep(1) if (type(line) == bool) and not line: yield False - return break - # finally reboot into os + sleep(2) + # finally reboot into os or to fastboot for flashing addons sleep(7) - logger.info("Reboot into OS.") - for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp", - yield line - if (type(line) == bool) and not line: - logger.error("Rebooting failed.") - yield False - return + if install_addons: + if is_ab: + # 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 else: - yield True + for line in adb_reboot(bin_path=bin_path): + yield line -def fastboot_unlock_with_code(bin_path: Path, unlock_code: str) -> bool: +def adb_twrp_install_addons( + bin_path: Path, addons: List[str], is_ab: bool +) -> TerminalResponse: + """Flash addons through adb and twrp. + + Only works for twrp recovery. + """ + logger.info("Install addons with twrp.") + sleep(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 + sleep(7) + sleep(3) + # finally reboot into os + if is_ab: + # 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 + sleep(1) + for line in fastboot_switch_partition(bin_path=bin_path): + yield line + sleep(1) + # reboot with fastboot + logger.info("Reboot into OS.") + for line in fastboot_reboot(bin_path=bin_path): + yield line + else: + # reboot with adb + for line in adb_reboot(bin_path=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.""" + for line in run_command("fastboot set_active other", bin_path): + yield line + + +@add_logging("Unlock the device with fastboot and code.") +def fastboot_unlock_with_code(bin_path: Path, unlock_code: str) -> TerminalResponse: """Unlock the device with fastboot and code given.""" - logger.info(f"Unlock the device with fastboot and code: {unlock_code}.") - for line in run_command("fastboot", ["oem", "unlock", f"{unlock_code}"], bin_path): + for line in run_command(f"fastboot oem unlock {unlock_code}", bin_path): yield line - if (type(line) == bool) and not line: - logger.error(f"Unlocking with code {unlock_code} failed.") - yield False - else: - yield True -def fastboot_unlock(bin_path: Path) -> bool: +@add_logging("Unlock the device with fastboot without code.") +def fastboot_unlock(bin_path: Path) -> TerminalResponse: """Unlock the device with fastboot and without code.""" - logger.info("Unlock the device with fastboot.") - for line in run_command("fastboot", ["flashing", "unlock"], bin_path): + for line in run_command("fastboot flashing unlock", bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Unlocking failed.") - yield False - else: - yield True -def fastboot_oem_unlock(bin_path: Path) -> bool: +@add_logging("OEM unlocking the device with fastboot.") +def fastboot_oem_unlock(bin_path: Path) -> TerminalResponse: """OEM unlock the device with fastboot and without code.""" - logger.info("OEM unlocking the device with fastboot.") - for line in run_command("fastboot", ["oem", "unlock"], bin_path): + for line in run_command("fastboot oem unlock", bin_path): yield line - if (type(line) == bool) and not line: - logger.error("OEM unlocking failed.") - yield False - else: - yield True -def fastboot_get_unlock_data(bin_path: Path) -> bool: +@add_logging("Get unlock data with fastboot") +def fastboot_get_unlock_data(bin_path: Path) -> TerminalResponse: """Get the unlock data with fastboot""" - logger.info("Get unlock data with fastboot") - for line in run_command("fastboot", ["oem", "get_unlock_data"], bin_path): + for line in run_command("fastboot oem get_unlock_data", bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Getting unlock data failed.") - yield False - else: - yield True -def fastboot_reboot(bin_path: Path) -> bool: +@add_logging("Rebooting device with fastboot.") +def fastboot_reboot(bin_path: Path) -> TerminalResponse: """Reboot with fastboot""" - logger.info("Rebooting device with fastboot.") - for line in run_command("fastboot", ["reboot"], bin_path): + for line in run_command("fastboot reboot", bin_path): yield line - if (type(line) == bool) and not line: - logger.error("Rebooting with fastboot failed.") - yield False - else: - yield True -def fastboot_flash_recovery(bin_path: Path, recovery: str) -> bool: +@add_logging("Flash or boot custom recovery with fastboot.") +def fastboot_flash_recovery( + bin_path: Path, recovery: str, is_ab: bool = True +) -> TerminalResponse: """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): + yield line + else: + logger.info("Flash custom recovery with fastboot.") + for line in run_command(f"fastboot flash recovery {recovery}", bin_path): + yield line + if (type(line) == bool) and not line: + logger.error("Flashing recovery failed.") + yield False + else: + yield True + # reboot + logger.info("Boot into TWRP with fastboot.") + for line in run_command("fastboot reboot recovery", 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("fastboot", ["boot", f"{recovery}"], bin_path): + for line in run_command(f"fastboot flash boot {recovery}", bin_path): yield line if (type(line) == bool) and not line: logger.error("Flashing recovery failed.") yield False else: yield True + # reboot + logger.info("Boot into TWRP with fastboot.") + for line in run_command("fastboot reboot", bin_path): + yield line + if (type(line) == bool) and not line: + logger.error("Booting recovery failed.") + yield False + else: + yield True -def heimdall_flash_recovery(bin_path: Path, recovery: str) -> bool: +@add_logging("Flash custom recovery with heimdall.") +def heimdall_flash_recovery(bin_path: Path, recovery: str) -> TerminalResponse: """Temporarily, flash custom recovery with heimdall.""" - logger.info("Flash custom recovery with heimdall.") for line in run_command( - "heimdall", ["flash", "--no-reboot", "--RECOVERY", f"{recovery}"], bin_path + f"heimdall flash --no-reboot --RECOVERY {recovery}", bin_path ): yield line - if (type(line) == bool) and not line: - logger.error("Flashing recovery with heimdall failed.") - yield False - else: - yield True def search_device(platform: str, bin_path: Path) -> Optional[str]: """Search for a connected device.""" logger.info(f"Search devices on {platform} with {bin_path}...") try: - # read device properties + # read device code if platform in ("linux", "darwin"): output = check_output( [ @@ -353,3 +419,43 @@ def search_device(platform: str, bin_path: Path) -> Optional[str]: except CalledProcessError: logger.error("Failed to detect a device.") return None + + +def check_ab_partition(platform: str, bin_path: Path) -> Optional[bool]: + """Figure out, if its an a/b-partitioned device.""" + logger.info(f"Run on {platform} with {bin_path}...") + try: + # check if ab device + if platform in ("linux", "darwin"): + output = check_output( + [ + str(bin_path.joinpath(Path("adb"))), + "shell", + "getprop", + "|", + "grep", + "ro.boot.slot_suffix", + ], + stderr=STDOUT, + ).decode() + elif platform in ("windows", "win32"): + output = check_output( + [ + str(bin_path.joinpath(Path("adb.exe"))), + "shell", + "getprop", + "|", + "findstr", + "ro.boot.slot_suffix", + ], + stderr=STDOUT, + shell=True, + ).decode() + else: + raise Exception(f"Unknown platform {platform}.") + logger.info(output) + logger.info("This is an a/b-partitioned device.") + return True + except CalledProcessError: + logger.info("This is not an a/b-partitioned device.") + return False diff --git a/openandroidinstaller/utils.py b/openandroidinstaller/utils.py index 3fa9fd17..7a83cb83 100644 --- a/openandroidinstaller/utils.py +++ b/openandroidinstaller/utils.py @@ -33,10 +33,10 @@ def get_download_link(devicecode: str) -> Optional[str]: return url else: logger.info(f"{url} doesn't exist, status_code: {res.status_code}") - return + return None except requests.exceptions.RequestException as e: logger.error(f"{url} doesn't exist, error: {e}") - return + return None def image_works_with_device( diff --git a/openandroidinstaller/views/__init__.py b/openandroidinstaller/views/__init__.py index 6c564c44..93d8d460 100644 --- a/openandroidinstaller/views/__init__.py +++ b/openandroidinstaller/views/__init__.py @@ -4,4 +4,7 @@ from .requirements_view import RequirementsView # noqa from .select_view import SelectFilesView # noqa from .step_view import StepView # noqa +from .install_view import InstallView # noqa +from .addon_view import AddonsView # noqa +from .install_addons_view import InstallAddonsView # noqa from .success_view import SuccessView # noqa diff --git a/openandroidinstaller/views/addon_view.py b/openandroidinstaller/views/addon_view.py new file mode 100644 index 00000000..d9d89333 --- /dev/null +++ b/openandroidinstaller/views/addon_view.py @@ -0,0 +1,230 @@ +"""Contains the select addons view.""" + +# This file is part of OpenAndroidInstaller. +# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of +# the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. + +# OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along with OpenAndroidInstaller. +# If not, see .""" +# Author: Tobias Sterbak + +import webbrowser +from loguru import logger +from typing import Callable + +from flet import ( + Column, + Divider, + ElevatedButton, + OutlinedButton, + FilledButton, + Markdown, + Row, + Text, + colors, + icons, + TextButton, + AlertDialog, + FilePicker, + FilePickerResultEvent, +) +from flet.buttons import CountinuosRectangleBorder + +from views import BaseView +from app_state import AppState +from widgets import get_title, confirm_button + + +class AddonsView(BaseView): + def __init__( + self, + state: AppState, + on_confirm: Callable, + ): + super().__init__(state=state) + self.on_confirm = on_confirm + + def build(self): + # dialog box to explain OS images and recovery + self.dlg_explain_addons = AlertDialog( + modal=True, + title=Text("What kind of addons are supported?"), + content=Markdown( + """## Google Apps: +There are different packages of Google Apps available. Most notable +- [MindTheGapps](https://wiki.lineageos.org/gapps#downloads) and +- [NikGApps](https://nikgapps.com/). + +These packages are only dependent on your OS version and processor architecture, which can be found on each device specific info page. +Filenames on MindTheGApps are of the format `MindTheGapps---_