Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Xiaomi (with OrangeFox) #188

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ Linux is currently the best supported platform (tested with Ubuntu 20.04/22.04 L
- [LineageOS for microg](https://download.lineage.microg.org)
- [BlissRoms](https://blissroms.org)
- [PixelExperience](https://download.pixelexperience.org)
- [crDroid](https://crdroid.net/)
- [ArrowOS](https://arrowos.net/)
- [DivestOS](https://divestos.org/)
- TWRP Recovery:
- [TWRP recovery](https://twrp.me/Devices)
- [OrangeFox](https://wiki.orangefox.tech)
- Optional Addons:
- There are different packages of *Google Apps* available.
- [MindTheGapps](https://wiki.lineageos.org/gapps#downloads)
Expand All @@ -63,7 +67,7 @@ Linux is currently the best supported platform (tested with Ubuntu 20.04/22.04 L

## Officially supported devices

Currently, the **we support 62 devices** by various vendors and working on adding more soon!
Currently, the **we support 68+ devices** by various vendors and working on adding more soon!


Support for these devices is provided as best effort, but things might still go wrong.
Expand Down Expand Up @@ -169,8 +173,17 @@ OnePlus | Nord N200 | [dre](https://wiki.lineageos.org/devices/dre) | | tested
OnePlus | 9 | lemonade | | under development
</details>

And more to come!
<details><summary><b>Xiaomi</b></summary>

Vendor | Device Name | CodeName | Models | Status
---|----------------------------------|--------------------------------------------------------|------------------------------------------|---
Xiaomi | Redmi Note 7 | [lavender](https://wiki.lineageos.org/devices/lavender) | lavender | tested
Xiaomi | Redmi Note 8 / 8T | [ginkgo](https://wiki.lineageos.org/devices/ginkgo) | ginkgo / willow | untested
Xiaomi | Redmi Note 10S / 11SE / Poco M5S | [rosemary](https://wiki.lineageos.org/devices/rosemary) | rosemary / maltose / secret / rosemary_p | untested
Xiaomi | Redmi 9A / 9C / 9AT / 9i / 9A Sport / 10A / 10A Sport | [garden](https://wiki.lineageos.org/devices/garden) | garden / dandelion / blossom / angelican | tested
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This url does not exist

Copy link
Member Author

@anon1892 anon1892 Jul 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups... Copy - paste ! garden was never officially supported by Lineage. Which URL should I replace it with?
EDIT : No link at all, like some others phones on the readme

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also prefer, to have one config file per device code (if they are not very similar) and treat them as separate devices.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dandelion and angelican are official Xiaomi namecodes.
garden and blossom are names of unified groups of codenames, given by ROM developers.
A garden ROM will fit for dandelion device, for example. So as far I understand, we cannot divide config files per device code, isn't it ?

Copy link
Member

@MagicLike MagicLike Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by that? - Do you mean having an extra device code for 2 configs or multiple device codes for one config? (Sorry, I am just a bit confused)

Copy link
Member Author

@anon1892 anon1892 Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may forgot some (it's a mess), but globally :

Official Xiaomi codenames :

  • Redmi 9C : angelica
  • Redmi 9C NFC : angelican
  • Redmi 9A/10A/10A Sport/9i/9A Sport : dandelion
  • Poco C3/C31 : angelicain

Community names :

  • Redmi 9A/9C/9i/9 India : garden
  • All of the above + Redmi 9 Active/9AT/9I Sport : blossom

So, a garden ROM will work on dandelion and angelica phones for example
And I forgot some codenames...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, thats confusing 😀

Then it might be a good idea, to start displaying multiple device codes (or the actually found one) as well as multiple possible names for devices (or based on the code) to the user. I could see this causing confusion for users (we recently also saw this for Samsung devices :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is !
I agree, we could display device code + group name, it may be more clear?

</details>

And more to come!

## Run OpenAndroidInstaller for development

Expand Down Expand Up @@ -215,6 +228,8 @@ Every config file should have `metadata` with the following fields:
- `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.
- `supported_recovery`: [OPTIONAL] List[str]; A lit of supported recoveries. For the moment, can be twrp and/or orangefox (twrp by default)
- `notes`: [OPTIONAL] str; specific phone information, showed before choosing ROM / recovery

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 @@ -231,7 +246,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_unlock_with_code`, `fastboot_unlock`, `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_reboot_recovery`, `fastboot_flash_recovery` `fastboot_unlock_with_code`, `fastboot_unlock`, `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
1 change: 1 addition & 0 deletions openandroidinstaller/app_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(
self.config = None
self.image_path = None
self.recovery_path = None
self.chosen_recovery = None

# store views
self.default_views: List = []
Expand Down
59 changes: 59 additions & 0 deletions openandroidinstaller/assets/configs/garden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
metadata:
maintainer: A non (anon)
device_name: Xiaomi Redmi 9A / 9C / 9AT / 9i / 9A Sport / 10A / 10A Sport
is_ab_device: false
device_code: garden
supported_recovery:
- orangefox
- twrp
supported_device_codes:
- dandelion
- garden
- blossom
- angelican
notes: >
- If something goes wrong, you can reinstall MiUI here : https://xiaomifirmwareupdater.com

- OAI don't support ROM that requires permissiver.

- Be careful when choosing OrangeFox version, Android 12 & 13 ROM needs OrangeFox version code with `A12`, for example `R11.1_5_A12`. Android 10 & 11 ROM needs OrangeFox version code without `A12` (bellow on the page)
requirements:
firmware: MiUI 12.5 (Q)
steps:
unlock_bootloader:
- type: confirm_button
content: >
As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). Your device should be turned on. This will reset your phone.
allow_skip: true
- type: link_button_with_confirm
content: >
Please download official Xiaomi unlock tool, and follow instructions.
https://en.miui.com/unlock/download_en.html
You may have to wait 7 days before being able to unlock the bootloader.
Do not attempt to bypass this limitation / use non officials tools, you may brick your phone.
link: https://en.miui.com/unlock/download_en.html
allow_skip: true
- type: confirm_button
content: >
The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue.
boot_recovery:
- type: confirm_button
content: >
Now you need to boot 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.
- type: call_button
content: >
Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
command: adb_reboot_bootloader
- type: call_button
content: >
Install the recovery you chosen before by pressing 'Confirm and run'. Once it's done continue.
command: fastboot_flash_recovery
- type: call_button
img: ofox.png
content: >
Reboot to recovery by pressing 'Confirm and run', and hold the Vol+ button of your phone UNTIL you see the recovery.
If MiUI starts, you have to start the process again, since MiUI delete the recovery you just flashed.
Once it's done continue.
command: fastboot_reboot_recovery
57 changes: 57 additions & 0 deletions openandroidinstaller/assets/configs/ginkgo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
metadata:
maintainer: A non (anon)
device_name: Xiaomi Redmi Note 8 / 8T
is_ab_device: false
device_code: ginkgo
supported_recovery:
- orangefox
- twrp
supported_device_codes:
- ginkgo
- willow
notes: >
- If something goes wrong, you can reinstall MiUI here : https://xiaomifirmwareupdater.com

- You should install Android 10 or newer ROM.

- Be careful when choosing OrangeFox version, Android 12 & 13 ROM needs OrangeFox version code with `A12`, for example `R11.1_5_A12`. Android 10 & 11 ROM needs OrangeFox version code without `A12` (bellow on the page)
requirements:
android: 10 (Q)
steps:
unlock_bootloader:
- type: confirm_button
content: >
As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). Your device should be turned on. This will reset your phone.
allow_skip: true
- type: link_button_with_confirm
content: >
Please download official Xiaomi unlock tool, and follow instructions.
https://en.miui.com/unlock/download_en.html
You may have to wait 7 days before being able to unlock the bootloader.
Do not attempt to bypass this limitation / use non officials tools, you may brick your phone.
link: https://en.miui.com/unlock/download_en.html
allow_skip: true
- type: confirm_button
content: >
The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue.
boot_recovery:
- type: confirm_button
content: >
Now you need to boot 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.
- type: call_button
content: >
Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
command: adb_reboot_bootloader
- type: call_button
content: >
Install the recovery you chosen before by pressing 'Confirm and run'. Once it's done continue.
command: fastboot_flash_recovery
- type: call_button
img: ofox.png
content: >
Reboot to recovery by pressing 'Confirm and run', and hold the Vol+ button of your phone UNTIL you see the recovery.
If MiUI starts, you have to start the process again, since MiUI delete the recovery you just flashed.
Once it's done continue.
command: fastboot_reboot_recovery
56 changes: 56 additions & 0 deletions openandroidinstaller/assets/configs/lavender.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
metadata:
maintainer: A non (anon)
device_name: Xiaomi Redmi Note 7
is_ab_device: false
device_code: lavender
supported_recovery:
- orangefox
- twrp
supported_device_codes:
- lavender
notes: >
- If something goes wrong, you can reinstall MiUI here : https://xiaomifirmwareupdater.com/miui/lavender/

- You should install Android 10 or newer ROM.

- Be careful when choosing OrangeFox version, Android 12 & 13 ROM needs OrangeFox version code with `A12`, for example `R11.1_5_A12`. Android 10 & 11 ROM needs OrangeFox version code without `A12` (bellow on the page)
requirements:
android: 10 (Q)
steps:
unlock_bootloader:
- type: confirm_button
content: >
As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). Your device should be turned on. This will reset your phone.
allow_skip: true
- type: link_button_with_confirm
content: >
Please download official Xiaomi unlock tool, and follow instructions.
https://en.miui.com/unlock/download_en.html
You may have to wait 7 days before being able to unlock the bootloader.
Do not attempt to bypass this limitation / use non officials tools, you may brick your phone.
link: https://en.miui.com/unlock/download_en.html
allow_skip: true
- type: confirm_button
content: >
The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue.
boot_recovery:
- type: confirm_button
content: >
Now you need to boot 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.
- type: call_button
content: >
Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
command: adb_reboot_bootloader
- type: call_button
content: >
Install the recovery you chosen before by pressing 'Confirm and run'. Once it's done continue.
command: fastboot_flash_recovery
- type: call_button
img: ofox.png
content: >
Reboot to recovery by pressing 'Confirm and run', and hold the Vol+ button of your phone UNTIL you see the recovery.
If MiUI starts, you have to start the process again, since MiUI delete the recovery you just flashed.
Once it's done continue.
command: fastboot_reboot_recovery
51 changes: 51 additions & 0 deletions openandroidinstaller/assets/configs/rosemary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
metadata:
maintainer: A non (anon)
device_name: Xiaomi Redmi Note 10S / 11SE / Poco M5S
is_ab_device: false
device_code: rosemary
supported_recovery:
- orangefox
- twrp
supported_device_codes:
- rosemary
- secret
- maltose
- rosemary_p
notes: >
- If something goes wrong, you can reinstall MiUI here : https://xiaomifirmwareupdater.com

- Please respect the requested by the ROM developers version for MIUI and Android

- Be careful when choosing OrangeFox version, Android 12 & 13 ROM needs OrangeFox version code with `A12`, for example `R11.1_5_A12`. Android 10 & 11 ROM needs OrangeFox version code without `A12` (bellow on the page)
steps:
unlock_bootloader:
- type: confirm_button
content: >
As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). Your device should be turned on. This will reset your phone.
allow_skip: true
- type: link_button_with_confirm
content: >
Please download official Xiaomi unlock tool, and follow instructions.
https://en.miui.com/unlock/download_en.html
You may have to wait 7 days before being able to unlock the bootloader.
Do not attempt to bypass this limitation / use non officials tools, you may brick your phone.
link: https://en.miui.com/unlock/download_en.html
allow_skip: true
- type: confirm_button
content: >
The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue.
boot_recovery:
- type: confirm_button
content: >
Now you need to boot 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.
- type: call_button
content: >
Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
command: adb_reboot_bootloader
- type: call_button
content: >
Install the recovery you chosen before by pressing 'Confirm and run'. Once it's done continue.
UNTESTED : Need to hold Vol+ or no ?
command: fastboot_flash_boot
Binary file added openandroidinstaller/assets/imgs/ofox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion openandroidinstaller/installer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(
self.requirements = requirements
self.device_code = metadata.get("device_code")
self.is_ab = metadata.get("is_ab_device", False)
self.supported_recovery = metadata.get("supported_recovery")
self.supported_device_codes = metadata.get("supported_device_codes")
self.twrp_link = metadata.get("twrp-link")

Expand Down Expand Up @@ -124,6 +125,8 @@ def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfi
if custom_path:
config = InstallerConfig.from_file(custom_path)
logger.info(f"Loaded custom device config from {custom_path}.")
if 'supported_recovery' not in config.metadata:
config.metadata.update({"supported_recovery": "['twrp']"})
logger.info(f"Config metadata: {config.metadata}.")
return config
else:
Expand All @@ -134,6 +137,8 @@ def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfi
config = InstallerConfig.from_file(path)
logger.info(f"Loaded device config from {path}.")
if config:
if 'supported_recovery' not in config.metadata:
config.metadata.update({"supported_recovery": "['twrp']"})
logger.info(f"Config metadata: {config.metadata}.")
return config
else:
Expand All @@ -150,7 +155,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_boot_recovery|fastboot_flash_boot|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_boot_recovery|fastboot_flash_boot|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery|fastboot_reboot_recovery|fastboot_flash_recovery"
),
schema.Optional("allow_skip"): bool,
schema.Optional("img"): str,
Expand All @@ -166,6 +171,8 @@ def validate_config(config: str) -> bool:
"device_code": str,
"supported_device_codes": [str],
schema.Optional("twrp-link"): str,
schema.Optional("supported_recovery"): [str],
schema.Optional("notes"): str,
},
schema.Optional("requirements"): {
schema.Optional("android"): schema.Or(str, int),
Expand Down
Loading