Skip to content

Commit

Permalink
Release v0.3.3-alpha (#51)
Browse files Browse the repository at this point in the history
This PR adds:
- progress bar do show the progress of the flashing.
- force light mode to address (#54)
- a fix with alternative device code resolution (#56)
- support for new devices (#52) :
    - Motorola moto g6 plus
    - Motorola moto g 5G plus / one 5G
    - Motorola moto g 5G / one 5G ace
    - Motorola edge
  • Loading branch information
tsterbak authored Jan 19, 2023
2 parents 5330d1e + 30dd2c2 commit db206ed
Show file tree
Hide file tree
Showing 16 changed files with 715 additions and 205 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ Fairphone | Fairphone 4 | [FP4](https://wiki.lineageos.org/devices/FP4/) | | tes

Vendor | Device Name | CodeName | Models | Status
---|---|---|---|---
Motorola | moto G5 | [cedric](https://wiki.lineageos.org/devices/cedric/) | | tested
Motorola | moto G7 power | [ocean](https://wiki.lineageos.org/devices/ocean/) | | tested
Motorola | moto g5 | [cedric](https://wiki.lineageos.org/devices/cedric/) | | tested
Motorola | moto g6 plus | [evert](https://wiki.lineageos.org/devices/evert/) | | tested
Motorola | moto g7 power | [ocean](https://wiki.lineageos.org/devices/ocean/) | | tested
Motorola | moto g 5G plus / one 5G | [nairo](https://wiki.lineageos.org/devices/nairo/) | | tested
Motorola | moto g 5G / one 5G ace | [kiev](https://wiki.lineageos.org/devices/kiev/) | | tested
Motorola | edge | [racer](https://wiki.lineageos.org/devices/racer/) | | tested
</details>

<details><summary><b>OnePlus</b></summary>
Expand Down
63 changes: 63 additions & 0 deletions openandroidinstaller/assets/configs/evert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Motorola moto g6 plus
devicecode: evert
steps:
unlock_bootloader:
- type: call_button
command: adb_reboot_bootloader
content: >
As a first step, you need to unlock the bootloader of your device. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). You need to boot into fastboot mode by pressing the 'Confirm and run' button. Then continue.
- type: call_button
command: fastboot_get_unlock_data
content: >
Now you need to get your device ID to get an unlock code from Motorola. Press 'Confirm and run' to get the ID. (You need to toggle 'Advanced Output' here to see it.)
Copy it to a separate file to use it in the next step.
- type: link_button_with_confirm
content: >
Click on the button to open the instructions on Motorola's official unlocking website to generate an unlock code for your bootloader.
Copy the code from the last step to the website and follow the instructions there. Then continue here.
link: https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-a
- type: confirm_button
content: Connect the device to your PC via USB. And confirm to continue.
- type: call_button_with_input
content: >
Use your code to unlock the bootloader of your device. Type in the full 21 character code you received by email (Example: 5RTSQCYL7ZJKL4NN35MY). Then confirm an run. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button_with_input
content: >
You need to perform the last command again, so reenter the code and run again. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button
content: >
Press the button to reboot. Since the device resets completely, you will need to re-enable USB debugging to continue.
Connect your device to your PC via USB. Then confirm here to continue.
command: fastboot_reboot
flash_recovery:
- type: call_button
content: >
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
adapting and repairing of the operating system.
Make sure your device is turned on. You need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
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
- 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
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
63 changes: 63 additions & 0 deletions openandroidinstaller/assets/configs/kiev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Motorola moto g 5G / one 5G ace
devicecode: kiev
steps:
unlock_bootloader:
- type: call_button
command: adb_reboot_bootloader
content: >
As a first step, you need to unlock the bootloader of your device. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). You need to boot into fastboot mode by pressing the 'Confirm and run' button. Then continue.
- type: call_button
command: fastboot_get_unlock_data
content: >
Now you need to get your device ID to get an unlock code from Motorola. Press 'Confirm and run' to get the ID. (You need to toggle 'Advanced Output' here to see it.)
Copy it to a separate file to use it in the next step.
- type: link_button_with_confirm
content: >
Click on the button to open the instructions on Motorola's official unlocking website to generate an unlock code for your bootloader.
Copy the code from the last step to the website and follow the instructions there. Then continue here.
link: https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-a
- type: confirm_button
content: Connect the device to your PC via USB. And confirm to continue.
- type: call_button_with_input
content: >
Use your code to unlock the bootloader of your device. Type in the full 21 character code you received by email (Example: 5RTSQCYL7ZJKL4NN35MY). Then confirm an run. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button_with_input
content: >
You need to perform the last command again, so reenter the code and run again. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button
content: >
Press the button to reboot. Since the device resets completely, you will need to re-enable USB debugging to continue.
Connect your device to your PC via USB. Then confirm here to continue.
command: fastboot_reboot
flash_recovery:
- type: call_button
content: >
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
adapting and repairing of the operating system.
Make sure your device is turned on. You need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
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
- 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
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
63 changes: 63 additions & 0 deletions openandroidinstaller/assets/configs/nairo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Motorola moto g 5G plus / one 5G
devicecode: nairo
steps:
unlock_bootloader:
- type: call_button
command: adb_reboot_bootloader
content: >
As a first step, you need to unlock the bootloader of your device. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). You need to boot into fastboot mode by pressing the 'Confirm and run' button. Then continue.
- type: call_button
command: fastboot_get_unlock_data
content: >
Now you need to get your device ID to get an unlock code from Motorola. Press 'Confirm and run' to get the ID. (You need to toggle 'Advanced Output' here to see it.)
Copy it to a separate file to use it in the next step.
- type: link_button_with_confirm
content: >
Click on the button to open the instructions on Motorola's official unlocking website to generate an unlock code for your bootloader.
Copy the code from the last step to the website and follow the instructions there. Then continue here.
link: https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-a
- type: confirm_button
content: Connect the device to your PC via USB. And confirm to continue.
- type: call_button_with_input
content: >
Use your code to unlock the bootloader of your device. Type in the full 21 character code you received by email (Example: 5RTSQCYL7ZJKL4NN35MY). Then confirm an run. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button_with_input
content: >
You need to perform the last command again, so reenter the code and run again. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button
content: >
Press the button to reboot. Since the device resets completely, you will need to re-enable USB debugging to continue.
Connect your device to your PC via USB. Then confirm here to continue.
command: fastboot_reboot
flash_recovery:
- type: call_button
content: >
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
adapting and repairing of the operating system.
Make sure your device is turned on. You need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
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
- 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
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
63 changes: 63 additions & 0 deletions openandroidinstaller/assets/configs/racer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Motorola edge
devicecode: racer
steps:
unlock_bootloader:
- type: call_button
command: adb_reboot_bootloader
content: >
As a first step, you need to unlock the bootloader of your device. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). You need to boot into fastboot mode by pressing the 'Confirm and run' button. Then continue.
- type: call_button
command: fastboot_get_unlock_data
content: >
Now you need to get your device ID to get an unlock code from Motorola. Press 'Confirm and run' to get the ID. (You need to toggle 'Advanced Output' here to see it.)
Copy it to a separate file to use it in the next step.
- type: link_button_with_confirm
content: >
Click on the button to open the instructions on Motorola's official unlocking website to generate an unlock code for your bootloader.
Copy the code from the last step to the website and follow the instructions there. Then continue here.
link: https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-a
- type: confirm_button
content: Connect the device to your PC via USB. And confirm to continue.
- type: call_button_with_input
content: >
Use your code to unlock the bootloader of your device. Type in the full 21 character code you received by email (Example: 5RTSQCYL7ZJKL4NN35MY). Then confirm an run. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button_with_input
content: >
You need to perform the last command again, so reenter the code and run again. Afterwards you can continue.
command: fastboot_unlock_with_code
- type: call_button
content: >
Press the button to reboot. Since the device resets completely, you will need to re-enable USB debugging to continue.
Connect your device to your PC via USB. Then confirm here to continue.
command: fastboot_reboot
flash_recovery:
- type: call_button
content: >
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
adapting and repairing of the operating system.
Make sure your device is turned on. You need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
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
- 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
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
28 changes: 26 additions & 2 deletions openandroidinstaller/installer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ def __init__(


class InstallerConfig:

# map some detected device codes to their real code.
device_code_mapping = {
# Sony issues
"C6603": "yuga",
# OnePlus issues
"OnePlus6": "enchilada",
"OnePlus6T": "fajita",
"OnePlus7": "guacamoleb",
"OnePlus7Pro": "guacamole",
"OnePlus7T": "hotdogb",
"OnePlus7TPro": "hotdog",
"Nord": "avicii",
"NordN200": "dre",
}

def __init__(
self,
unlock_bootloader: List[Step],
Expand All @@ -62,6 +78,11 @@ def __init__(
self.install_os = install_os
self.metadata = metadata
self.requirements = requirements
self.device_code = metadata.get("devicecode")
inverted_mapping = dict(map(reversed, self.device_code_mapping.items()))
self.alternative_device_code = inverted_mapping.get(
self.device_code, self.device_code
)

@classmethod
def from_file(cls, path):
Expand Down Expand Up @@ -107,15 +128,18 @@ def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfi
Try to load local file in the same directory as the executable first, then load from assets.
"""
# try loading a custom local file first
custom_path = Path.cwd().joinpath(Path(f"{device_code}.yaml"))
mapped_device_code = InstallerConfig.device_code_mapping.get(
device_code, device_code
)
custom_path = Path.cwd().joinpath(Path(f"{mapped_device_code}.yaml"))
try:
config = InstallerConfig.from_file(custom_path)
logger.info(f"Loaded custom device config from {custom_path}.")
logger.info(f"Config metadata: {config.metadata}.")
return config
except FileNotFoundError:
# if no localfile, then try to load a config file from assets
path = config_path.joinpath(Path(f"{device_code}.yaml"))
path = config_path.joinpath(Path(f"{mapped_device_code}.yaml"))
try:
config = InstallerConfig.from_file(path)
logger.info(f"Loaded device config from {path}.")
Expand Down
1 change: 1 addition & 0 deletions openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def configure(page: Page):
"""Configure the application."""
# Configure the application base page
page.title = "OpenAndroidInstaller"
page.theme_mode = "light"
page.window_height = 900
page.window_width = int(1.5 * page.window_height)
page.window_top = 100
Expand Down
Loading

0 comments on commit db206ed

Please sign in to comment.