Skip to content

Commit 757a85c

Browse files
committed
Merge support for device specific notes
2 parents 357002c + 616c7e6 commit 757a85c

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

doc/how_to_contribute_your_own_installation_configurations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ A config file consists of two parts. The first part are some metadata about the
1212
Every config file should have `metadata` with the following fields:
1313
- `maintainer`: str; Maintainer and author of the config file.
1414
- `device_name`: str; Name of the device.
15+
- `brand`: [OPTIONAL] str; Name of the brand. Can be used to make brand specific actions.
1516
- `is_ab_device`: bool; A boolean to determine if the device is a/b-partitioned or not.
1617
- `device_code`: str; The official device code.
1718
- `supported_device_codes`: List[str]; A list of supported device codes for the config. The config will be loaded based on this field.
1819
- `twrp-link`: [OPTIONAL] str; name of the corresponding twrp page.
1920
- `additional_steps` : [OPTIONAL] List[str]; A list of additional steps. Can be `dtbo`, `vbmeta`, `vendor_boot` or `super_empty`.
21+
- `notes`: [OPTIONAL] List[str]; specific phone information, showed before choosing ROM / recovery
22+
- `untested`: [OPTIONAL] bool; If `true`, a warning message is showed during installation process.
2023

2124
In addition to these metadata, every config can have optional `requirements`. If these are set, the user is asked to check if they are meet.
2225
- `android`: [OPTIONAL] int|str; Android version to install prior to installing a custom ROM.
@@ -33,7 +36,7 @@ Every step in the config file corresponds to one view in the application. These
3336
- `img`: [OPTIONAL] Display an image on the left pane of the step view. Images are loaded from `openandroidinstaller/assets/imgs/`.
3437
- `content`: str; The content text displayed alongside the action of the step. Used to inform the user about what's going on. For consistency and better readability the text should be moved into the next line using `>`.
3538
- `link`: [OPTIONAL] Link to use for the link button if type is `link_button_with_confirm`.
36-
- `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_boot_recovery`, `fastboot_flash_additional_partitions`, `fastboot_unlock_with_code`, `fastboot_unlock`, `fastboot_unlock_critical`, `fastboot_oem_unlock`, `fastboot_get_unlock_data`, `fastboot_reboot`, `heimdall_flash_recovery`.
39+
- `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_boot_recovery`, `fastboot_flash_recovery`, `fastboot_reboot_recovery`, `fastboot_flash_additional_partitions`, `fastboot_unlock_with_code`, `fastboot_unlock`, `fastboot_unlock_critical`, `fastboot_oem_unlock`, `fastboot_get_unlock_data`, `fastboot_reboot`, `heimdall_flash_recovery`.
3740
- `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.
3841

3942
**Please try to retain this order of these fields in your config to ensure consistency.**

openandroidinstaller/installer_config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def validate_config(config: str) -> bool:
153153
),
154154
"content": str,
155155
schema.Optional("command"): Regex(
156-
r"""adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|adb_twrp_copy_partitions|fastboot_boot_recovery|fastboot_flash_boot|
157-
fastboot_unlock_critical|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery|fastboot_flash_additional_partitions"""
156+
r"""adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|adb_twrp_copy_partitions|fastboot_boot_recovery|fastboot_flash_boot|fastboot_flash_recovery|
157+
fastboot_unlock_critical|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|fastboot_reboot_recovery|heimdall_flash_recovery|fastboot_flash_additional_partitions"""
158158
),
159159
schema.Optional("allow_skip"): bool,
160160
schema.Optional("img"): str,
@@ -170,7 +170,9 @@ def validate_config(config: str) -> bool:
170170
"device_code": str,
171171
"supported_device_codes": [str],
172172
schema.Optional("twrp-link"): str,
173-
schema.Optional("additional_steps"): [str],
173+
schema.Optional("additional_steps"): Regex(r"dtbo|vbmeta|vendor_boot|super_empty"),
174+
schema.Optional("notes"): str,
175+
schema.Optional("brand"): str,
174176
},
175177
schema.Optional("requirements"): {
176178
schema.Optional("android"): schema.Or(str, int),

openandroidinstaller/views/select_view.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,29 @@ def build(self):
177177
self.info_field = Row()
178178
# column to insert the additional image selection controls if needed
179179
self.additional_image_selection = Column()
180+
181+
# Device specific notes
182+
notes = ""
183+
if "brand" in self.state.config.metadata and (
184+
self.state.config.metadata['brand'] == "xiaomi" or self.state.config.metadata['brand'] == "poco"):
185+
notes += "- If something goes wrong, you can reinstall MiUI here :\n<https://xiaomifirmwareupdater.com/miui/lavender/>\n\n"
186+
if "untested" in self.state.config.metadata and self.state.config.metadata['untested'] == True:
187+
notes += "- **This device has never been tested with OpenAndroidInstaller.** The installation can go wrong. You may have to finish the installation process with command line. If you test, please report the result on GitHub.\n\n"
188+
if "notes" in self.state.config.metadata:
189+
for note in self.state.config.metadata['notes']:
190+
notes += "- " + note + "\n\n"
191+
if notes != "":
192+
self.right_view.controls.extend(
193+
[
194+
Text(
195+
"Important notes for your device",
196+
style="titleSmall",
197+
color=colors.RED,
198+
weight="bold",
199+
),
200+
Markdown(f"""{notes}"""),
201+
]
202+
)
180203
# if there is an available download, show the button to the page
181204
if self.download_link:
182205
twrp_download_link = f"https://dl.twrp.me/{self.state.config.twrp_link if self.state.config.twrp_link else self.state.config.device_code}"

0 commit comments

Comments
 (0)