Skip to content

Commit

Permalink
Merge support for device specific notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Aug 16, 2023
2 parents 357002c + 616c7e6 commit 757a85c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ A config file consists of two parts. The first part are some metadata about the
Every config file should have `metadata` with the following fields:
- `maintainer`: str; Maintainer and author of the config file.
- `device_name`: str; Name of the device.
- `brand`: [OPTIONAL] str; Name of the brand. Can be used to make brand specific actions.
- `is_ab_device`: bool; A boolean to determine if the device is a/b-partitioned or not.
- `device_code`: str; The official device code.
- `supported_device_codes`: List[str]; A list of supported device codes for the config. The config will be loaded based on this field.
- `twrp-link`: [OPTIONAL] str; name of the corresponding twrp page.
- `additional_steps` : [OPTIONAL] List[str]; A list of additional steps. Can be `dtbo`, `vbmeta`, `vendor_boot` or `super_empty`.
- `notes`: [OPTIONAL] List[str]; specific phone information, showed before choosing ROM / recovery
- `untested`: [OPTIONAL] bool; If `true`, a warning message is showed during installation process.

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.
- `android`: [OPTIONAL] int|str; Android version to install prior to installing a custom ROM.
Expand All @@ -33,7 +36,7 @@ Every step in the config file corresponds to one view in the application. These
- `img`: [OPTIONAL] Display an image on the left pane of the step view. Images are loaded from `openandroidinstaller/assets/imgs/`.
- `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 `>`.
- `link`: [OPTIONAL] Link to use for the link button if type is `link_button_with_confirm`.
- `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`.
- `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`.
- `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.

**Please try to retain this order of these fields in your config to ensure consistency.**
Expand Down
8 changes: 5 additions & 3 deletions openandroidinstaller/installer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ 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_boot_recovery|fastboot_flash_boot|
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"""
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|
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"""
),
schema.Optional("allow_skip"): bool,
schema.Optional("img"): str,
Expand All @@ -170,7 +170,9 @@ def validate_config(config: str) -> bool:
"device_code": str,
"supported_device_codes": [str],
schema.Optional("twrp-link"): str,
schema.Optional("additional_steps"): [str],
schema.Optional("additional_steps"): Regex(r"dtbo|vbmeta|vendor_boot|super_empty"),
schema.Optional("notes"): str,
schema.Optional("brand"): str,
},
schema.Optional("requirements"): {
schema.Optional("android"): schema.Or(str, int),
Expand Down
23 changes: 23 additions & 0 deletions openandroidinstaller/views/select_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,29 @@ def build(self):
self.info_field = Row()
# column to insert the additional image selection controls if needed
self.additional_image_selection = Column()

# Device specific notes
notes = ""
if "brand" in self.state.config.metadata and (
self.state.config.metadata['brand'] == "xiaomi" or self.state.config.metadata['brand'] == "poco"):
notes += "- If something goes wrong, you can reinstall MiUI here :\n<https://xiaomifirmwareupdater.com/miui/lavender/>\n\n"
if "untested" in self.state.config.metadata and self.state.config.metadata['untested'] == True:
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"
if "notes" in self.state.config.metadata:
for note in self.state.config.metadata['notes']:
notes += "- " + note + "\n\n"
if notes != "":
self.right_view.controls.extend(
[
Text(
"Important notes for your device",
style="titleSmall",
color=colors.RED,
weight="bold",
),
Markdown(f"""{notes}"""),
]
)
# if there is an available download, show the button to the page
if self.download_link:
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}"
Expand Down

0 comments on commit 757a85c

Please sign in to comment.