Skip to content

Commit 872a727

Browse files
committed
Config for Motorola moto g7 power
1 parent 37ae9cc commit 872a727

6 files changed

Lines changed: 85 additions & 53 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Samsung | Galaxy S7 | [herolte](https://wiki.lineageos.org/devices/herolte/) | S
4444
Samsung | Galaxy S9 | [starlte](https://wiki.lineageos.org/devices/starlte/) | | tested
4545
Samsung | Galaxy S10 | beyond1lte | | tested
4646
Google | Pixel 3a | [sargo](https://wiki.lineageos.org/devices/sargo/) | sargo | tested
47-
Google | Pixel 4 | flame | flame | tested
47+
Google | Pixel 4 | [flame](https://wiki.lineageos.org/devices/flame/) | flame | tested
4848
Google | Pixel 4a | sunfish | sunfish | tested
4949
Google | Pixel 5 | redfin | redfin | tested
5050
Google | Pixel 5a | barbet | barbet | tested
@@ -54,7 +54,7 @@ Sony | Xperia ZX | kagura | | planned
5454
Fairphone | Fairphone 2 | [FP2](https://wiki.lineageos.org/devices/FP2/) | | tested
5555
Fairphone | Fairphone 3 | [FP3](https://wiki.lineageos.org/devices/FP3/) | | tested
5656
Motorola | moto G5 | cedric | | planned
57-
Motorola | moto g7 power | ocean | | under development
57+
Motorola | moto g7 power | [ocean](https://wiki.lineageos.org/devices/ocean/) | | tested
5858
OnePlus | 6 | enchilada | | under development
5959
OnePlus | 6T | fajita | | under development
6060
OnePlus | 7T | hotdogb | | under development
@@ -105,7 +105,7 @@ Every step in the config file corresponds to one view in the application. These
105105
- `call_button_with_input`: Display the content text, an input field and a button that runs a given command. The inputtext, can be used in the command by using the `<inputtext>` placeholder in the command field. After the command is run, a confirm button is displayed to allow the user to move to the next step.
106106
- `link_button_with_confirm`: Display a button that opens a browser with a given link, confirm afterwards. Link is given in `link`.
107107
- `content`: str; The content text displayed alongside the action of the step. Used to inform the user about whats going on.
108-
- `command`: [ONLY for call_button* steps] str; The command to run. One of `adb_reboot`, `adb_reboot_bootloader`, `adb_reboot_download`, `adb_sideload`, `adb_twrp_wipe_and_install`, `fastboot_flash_recovery`, `fastboot_unlock_with_code`, `fastboot_unlock`, `fastboot_oem_unlock`, `fastboot_reboot`, `heimdall_flash_recovery`.
108+
- `command`: [ONLY for call_button* steps] str; The command to run. One of `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_unlock`, `fastboot_oem_unlock`, `fastboot_get_unlock_data`, `fastboot_reboot`, `heimdall_flash_recovery`.
109109
- `img`: [OPTIONAL] Display an image on the left pane of the step view. Images are loaded from `openandroidinstaller/assets/imgs/`.
110110
- `allow_skip`: [OPTIONAL] boolean; If a skip button should be displayed to allow skipping this step. Can be useful when the bootloader is already unlocked.
111111
- `link`: [OPTIONAL] Link to use for the link button if type is `link_button_with_confirm`.

openandroidinstaller/assets/configs/ocean.yaml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
metadata:
22
maintainer: Tobias Sterbak (tsterbak)
33
devicename: Moto G7 power
4-
devicecode: Ocean
5-
requirements:
6-
copy_partitions: True
4+
devicecode: ocean
75
steps:
86
unlock_bootloader:
9-
- type: confirm_button
7+
- type: call_button
8+
command: adb_reboot_bootloader
109
content: >
1110
As a first step, you need to unlock the bootloader of your device. A bootloader is the piece of software, that tells your phone
12-
how to start and run an operating system (like Android). On the device, dial *#06# to launch the service menu.
13-
- type: confirm_button
14-
content: Go to service info > configuration and check rooting status - you can only continue if it says 'Bootloader unlock allowed":" Yes.'
15-
- type: confirm_button
11+
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.
12+
- type: call_button
13+
command: fastboot_get_unlock_data
1614
content: >
17-
Now go to Settings 'About the phone' and then Status. Write down the IMEI of your device. You will need it in the next step.
15+
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.)
16+
Copy it to a separate file to use it in the next step.
1817
- type: link_button_with_confirm
1918
content: >
2019
Click on the button to open the instructions on Motorola's official unlocking website to generate an unlock code for your bootloader.
21-
Once you got the code write it down somewhere and continue to input the code.
20+
Copy the code from the last step to the website and follow the instructions there. Then continue here.
2221
link: https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-a
2322
- type: confirm_button
2423
content: Connect the device to your PC via USB. And confirm to continue.
25-
- type: call_button
26-
content: Press the button to reboot into the bootloader now. When the notification light turns blue, confirm to continue.
27-
command: adb_reboot_bootloader
2824
- type: call_button_with_input
2925
content: >
30-
Use your code to unlock the bootloader of your device. Type in the full 18 character code starting with 0x (Example: 0x3EC4F7AD6E0B32B6).
31-
If you already did that, you can skip this step.
26+
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.
27+
command: fastboot_unlock_with_code
28+
- type: call_button_with_input
29+
content: >
30+
You need to perform the last command again, so reenter the code and run again. Afterwards you can continue.
3231
command: fastboot_unlock_with_code
3332
- type: call_button
3433
content: >
@@ -45,10 +44,19 @@ steps:
4544
- type: call_button
4645
content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue.
4746
command: fastboot_flash_recovery
47+
- type: call_button
48+
command: adb_twrp_copy_partitions
49+
content: >
50+
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.
51+
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.
52+
- type: call_button
53+
command: fastboot_flash_recovery
54+
content: >
55+
Now we need to boot into recovery again. Press run and when you see the TWRP screen you can continue.
4856
install_os:
4957
- type: call_button
5058
content: >
51-
In the next steps, you finally flash the selected OS image.
59+
In this last step, you finally flash the selected OS image.
5260
Wait until the TWRP screen appears. Then run the command.
5361
This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored
5462
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.

openandroidinstaller/installer_config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def __init__(
6262
self.install_os = install_os
6363
self.metadata = metadata
6464
self.requirements = requirements
65-
self.copy_partitions = requirements.get("copy_partitions", False)
6665

6766
@classmethod
6867
def from_file(cls, path):
@@ -137,7 +136,7 @@ def validate_config(config: str) -> bool:
137136
),
138137
"content": str,
139138
schema.Optional("command"): Regex(
140-
r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|fastboot_flash_recovery|fastboot_unlock_with_code|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery"
139+
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"
141140
),
142141
schema.Optional("allow_skip"): bool,
143142
schema.Optional("img"): str,
@@ -154,7 +153,6 @@ def validate_config(config: str) -> bool:
154153
schema.Optional("requirements"): {
155154
schema.Optional("android"): schema.Or(str, int),
156155
schema.Optional("firmware"): str,
157-
schema.Optional("copy_partitions"): bool,
158156
},
159157
"steps": {
160158
"unlock_bootloader": schema.Or(None, [step_schema]),

openandroidinstaller/openandroidinstaller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
logger.add("openandroidinstaller.log")
4747

4848
# Toggle to True for development purposes
49-
DEVELOPMENT = True
49+
DEVELOPMENT = False
5050
DEVELOPMENT_CONFIG = "sargo" # "a3y17lte" # "sargo"
5151

5252

openandroidinstaller/tooling.py

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,42 +101,53 @@ def adb_sideload(bin_path: Path, target: str) -> bool:
101101
yield True
102102

103103

104+
def adb_twrp_copy_partitions(bin_path: Path, config_path: Path):
105+
# some devices like one plus 6t or motorola moto g7 power need the partitions copied to prevent a hard brick
106+
logger.info("Sideload copy_partitions script with adb.")
107+
# activate sideload
108+
for line in run_command("adb", ["shell", "twrp", "sideload"], bin_path):
109+
yield line
110+
if (type(line) == bool) and not line:
111+
logger.error("Activating sideload failed.")
112+
yield False
113+
return
114+
# now sideload the script
115+
sleep(5)
116+
logger.info("Sideload the copy_partitions script")
117+
for line in run_command(
118+
"adb",
119+
[
120+
"sideload",
121+
str(config_path.parent) + "/copy-partitions-20220613-signed.zip",
122+
],
123+
bin_path,
124+
):
125+
yield line
126+
if (type(line) == bool) and not line:
127+
logger.error("Sideloading copy-partitions-20220613-signed.zip failed.")
128+
sleep(10)
129+
# reboot into the bootloader again
130+
logger.info("Rebooting device into bootloader with adb.")
131+
for line in run_command("adb", ["reboot", "bootloader"], bin_path):
132+
yield line
133+
if (type(line) == bool) and not line:
134+
logger.error("Reboot into bootloader failed.")
135+
yield False
136+
return
137+
sleep(7)
138+
# Copy partitions end #
139+
return True
140+
141+
104142
def adb_twrp_wipe_and_install(
105-
bin_path: Path, target: str, config_path: Path, copy_partitions: bool = False
143+
bin_path: Path, target: str, config_path: Path
106144
) -> bool:
107145
"""Wipe and format data with twrp, then flash os image with adb.
108146
109147
Only works for twrp recovery.
110148
"""
111149
logger.info("Wipe and format data with twrp, then install os image.")
112150
sleep(7)
113-
# some devices like one plus 6t or motorola moto g7 power need the partitions copied to prevent a hardbrick
114-
if copy_partitions:
115-
logger.info("Sideload copy_partitions script with adb.")
116-
# activate sideload
117-
for line in run_command("adb", ["shell", "twrp", "sideload"], bin_path):
118-
yield line
119-
if (type(line) == bool) and not line:
120-
logger.error("Activating sideload failed.")
121-
yield False
122-
return
123-
# now sideload the script
124-
sleep(5)
125-
logger.info("Sideload the copy_partitions script")
126-
for line in run_command(
127-
"adb",
128-
[
129-
"sideload",
130-
str(config_path.parent) + "/copy-partitions-20220613-signed.zip",
131-
],
132-
bin_path,
133-
):
134-
yield line
135-
if (type(line) == bool) and not line:
136-
logger.error("Sideloading copy-partitions-20220613-signed.zip failed.")
137-
sleep(5)
138-
# Copy partitions end #
139-
140151
# now perform a factory reset
141152
for line in run_command("adb", ["shell", "twrp", "format", "data"], bin_path):
142153
yield line
@@ -193,7 +204,7 @@ def adb_twrp_wipe_and_install(
193204
return
194205
break
195206
# finally reboot into os
196-
sleep(5)
207+
sleep(7)
197208
logger.info("Reboot into OS.")
198209
for line in run_command("adb", ["reboot"], bin_path): # "shell", "twrp",
199210
yield line
@@ -241,6 +252,18 @@ def fastboot_oem_unlock(bin_path: Path) -> bool:
241252
yield True
242253

243254

255+
def fastboot_get_unlock_data(bin_path: Path) -> bool:
256+
"""Get the unlock data with fastboot"""
257+
logger.info("Get unlock data with fastboot")
258+
for line in run_command("fastboot", ["oem", "get_unlock_data"], bin_path):
259+
yield line
260+
if (type(line) == bool) and not line:
261+
logger.error("Getting unlock data failed.")
262+
yield False
263+
else:
264+
yield True
265+
266+
244267
def fastboot_reboot(bin_path: Path) -> bool:
245268
"""Reboot with fastboot"""
246269
logger.info("Rebooting device with fastboot.")

openandroidinstaller/views/step_view.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@
4242
adb_reboot_download,
4343
adb_sideload,
4444
adb_twrp_wipe_and_install,
45+
adb_twrp_copy_partitions,
4546
fastboot_flash_recovery,
4647
fastboot_oem_unlock,
4748
fastboot_reboot,
4849
fastboot_unlock,
4950
fastboot_unlock_with_code,
51+
fastboot_get_unlock_data,
5052
heimdall_flash_recovery,
5153
)
5254
from widgets import (
@@ -199,13 +201,14 @@ def call_to_phone(self, e, command: str):
199201
adb_twrp_wipe_and_install,
200202
target=self.state.image_path,
201203
config_path=self.state.config_path,
202-
copy_partitions=self.state.config.copy_partitions,
203204
),
205+
"adb_twrp_copy_partitions": partial(adb_twrp_copy_partitions, config_path=self.state.config_path),
204206
"fastboot_unlock": fastboot_unlock,
205207
"fastboot_unlock_with_code": partial(
206208
fastboot_unlock_with_code, unlock_code=self.inputtext.value
207209
),
208210
"fastboot_oem_unlock": fastboot_oem_unlock,
211+
"fastboot_get_unlock_data": fastboot_get_unlock_data,
209212
"fastboot_flash_recovery": partial(
210213
fastboot_flash_recovery, recovery=self.state.recovery_path
211214
),

0 commit comments

Comments
 (0)