SUPPORTS ALL TYPES OF USERDATA DECRYPTION FOR BOTH OREO AND PIE ROMS - PASSWORD, DEFAULT_PASSWORD, PATTERN, PIN!!!
SUPPORTS BOTH FULL AND INCREMENTAL OTA UPDATE PACKAGES AUTOMATIC INSTALL!!!
SUPPORTS BOTH FULL AND INCREMENTAL OTA UPDATE PACKAGES AUTOMATIC INSTALL!!!
Sharing my unofficial TWRP recovery mod for nitrogen which I have started about 2 years ago for hydrogen/helium. For more details visit https://forum.xda-developers.com/mi-max/development/recovery-twrp-3-0-2-2-hydrogen-helium-t3512981...
This is and will be work in progress with fixes and reasonable features to be added.
To install:
- USB connect device to PC
- reboot to fastboot
- open Command prompt/Terminal in the folder with the recovery image and run these commands line by line:
Code:
fastboot flash recovery (XX-XX-XXXX)twrp_v323-X_nitrogen_nijel8-MOD.img
fastboot boot (XX-XX-XXXX)twrp_v323-X_nitrogen_nijel8-MOD.img
- reboot from the fresh recovery - it'll take few seconds... let it do its magic to survive MIUI stock recovery replace at system boot. This will happen whenever you install any new ROM.
Done... This TWRP will not go anywhere, /system is untouched so you can get MIUI OTAs, no need to root if you don't want to, no need to flash anything else, MIUI boots just fine having no idea about the recovery, everybody's happy...
NOTES:
ROM install:
- skip wiping Data even if switching different ROMs. Do dirty install, see how it runs, if no problems, great... you saved yourself from doing the initial
setup. If having issues then wipe Data and see how it goes...
- You do not need to wipe/format/factory reset anything before install(see above), especially System and Vendor.
- Do not install any patches like lazyflasher, sound or whatever mods, root-on-system etc that are altering System or Vendor partitions on stock MIUI without installing Magisk first or system will not boot!!!
MIUI OTA Install:
- Let MIUI download update and press "Reboot" when prompted
- Device will reboot to TWRP and start installing it.
- If device reboots to system automatically - all good, update successful
- If device does not reboot you should see some error in red
- Just flash the zip package in Internal storage -> downloaded_rom folder and reboot to system
- Done - you just got your OTA
Decryption:
If MIUI asks for decription password after reboot from TWRP don't panic!
You will most likely never see this but as anything in this live sh*t happens. I for example have seen this only once in hundreds of TWRP and MIUI flashings and reboots to system and it happen after reboot from MIUI OTA testing. Did I mentioned I never do clean installs? Why bother wiping if no post-install issues, right...
Anyway... here is how to get back to normal without loosing any data:
- Reboot back to recovery by pressing and holding POWER + VOLUME UP buttons
- Run Data backup in TWRP
- USB connect device to computer and copy all personal data you don't wanna loose from Internal storage to computer
- DO NOT FORGET TO COPY THE DATA BACKUP YOU JUST MADE FROM TWRP/BACKUPS/XXXXXX TO COMPUTER TOO!!!
- Click Wipe -> Format data -> type yes -> [ENTER]
- Reboot to MIUI and let it encrypt the device. You will see Setup new device wizard when its done
- Reboot back to recovery by pressing and holding POWER + VOLUME UP buttons
- Copy back all your personal data including the recent Data backup from computer to Internal storage -> TWRP/BACKUPS/XXXXXX
- Reboot recovery so TWRP can detect the Data backup you copied
- Restore Data backup and reboot to MIUI
- Done - MIUI should boot without complaining and all your data is intact... even your old lockscreen password and fingerprints should work
Backup/restore:
- normal backup includes Data only, you can always flash what you are running currently to restore boot, system and vendor
- if you have modified boot,system or vendor post install you can back them up to keep your changes
- You do not need to wipe/format/factory reset anything before restore... restore does that for you
Some observations during my extended decryption testing with China and Global MIUIs 8.1 and 9.0, EU MIUIs, MIUIPro, etc:
- Downgrading to ROM with lower security patch level brakes encryption in Android but not in TWRP so just boot back to recovery, backup your data to safe location, format data, restore data back and you are good to go...
- Some times switching back and forth passwords types(pin, pattern etc...) brakes encryption and you loose your data, no way back!!! This is ROM fault and not TWRP. Crypto footer just gets corrupted from Android... I have taken good measures for this not to happen in my TWRP so don't blame recovery if that happens to you...
Changelog:
[02-01-2019
- hide navbar during running operarions
- more userdata decryption reliability improvements
- Mi bunny is terrified loosing recovery control
- sync with latest Omnirom android-9.0 sources
[01-28-2019
- fix decryption with good user password on next retry if wrong password was entered before that
- improve TWRP persist
- sync with latest Omnirom android-9.0 sources
[01-09-2019
- fix system boot after restoring regular file-for-file backup on ext4 file systems(System and Vendor) - now any backup type works for any partition of any ROM
- sync with latest Omnirom android-9.0 sources
[01-07-2019
- fix installing incremental OTA patching boot - this will start working properly after your first full ROM install with new recovery(boot.img flash)
- fix loading settings from /persist if decryption fails
- made sure we always keep current settings copy on /persist
- remove excessive save settings calls
- some minor improvements
- sync with latest Omnirom android-9.0 sources
[01-05-2019
- fix incremental OTA update automatic install
- sync with latest Omnirom android-9.0 sources
[01-04-2019
- new much smaller Pie kernel built from source with LineageOS 16.0
- much smaller recovery image(see above)
- sync with latest Omnirom android-9.0 sources
[12-29-2018
- improved decrypt routine
- some minor fixes and improvements
- sync with latest Omnirom android-9.0 sources
12-28-2018
- much improved and reliable decryption routine for preventing crypto footer corruption and loosing all your data - this update is highly recomended
- fix Android 9.0 userdata decryption with custom user set password, pin or pattern
- more reliable format data routine for crypto footer support
- disable useless and sometime buggy reboot check for system size(No OS installed msg)
- sync with latest Omnirom android-9.0 sources
12-27-2018
- migrate to Android-9.0 for android tree and TWRP sources
- switch to MIUI Pie prebuilt kernel
- speed up userdata decryption
- fix userdata decryption for Android-9.0 with default password only. At this time userdata decryption wit user set password is not supported! Working on it...
- sync with latest Omnirom android-9.0 sources
11-25-2018
- fix survival routine hang/bootloop after openrecoveryscript execution(OTA)
- improved decryption handling
11-23-2018
- fix userdata decryption - no more inaccessible userdata in TWRP
- fix vendor missing from partitions to restore list in some cases
- fix TWRP bootloop trying to apply survive magic in some cases
- finaly fix crypto footer for F2FS partition formating(tested and working!!! - you can format userdata in TWRP without any system boot issues now)
- skip survive magic for good ROMs to speed up reboot
- translatable and more user friendly survive system boot screen - If you want to help translate and PM me these strings:"
Code:
<!-- Survive system boot strings -->
<string name="survive_line1">Checking if TWRP will survive system boot!</string>
<string name="survive_line2">Please, wait...</string>
11-12-2018
- fix TWRP system boot survive - no need to flash anything to prevent stock recovery reflash at MIUI boot
- fix crypto footer for F2FS partition format - need no more fastboot format userdata for system boot with forced encription enabled(needs testing)
- fix error when creating ext2, ext3, or ext4 filesystem in some cases(needs testing)
- some minor fixes and optimizations
- kernel compiled from source at build time
- build with latest Lineage OS 15.1 sources
- sync with latest Omnirom android-8.1 TWRP sources
Github sources:
NITROGEN TWRP device tree
TWRP Mod repo
Kernel source
Thank you:
TeamWin for the initial device tree!
Omnirom/TeamWin for the TWRP source code!
@topjohnwu for the magiskboot source code!
Last edited:



