How to upgrade a phone to Android 13

Disclaimers - – I am not an expert. I have only done this once, and this is an infodump of my experiences, trying to document as many of the gotchas as possible in hope it will help my future self or somebody else. – Many of the steps vary widely between different phones. The notes below apply to my phone, board name raphael (sold as Redmi K20 Pro and Xiaomi Mi 9T Pro). Your milage will vary. – This post assumes your phone is rooted. It might be possible to upgrade without rooting if the phone is new enough and your 0wner is nice enough, but that is not sustainable. – It also assumes familiarity with the basics of Android adminning. Some reading/googling might be required. – If your phone is bricked, bursts into flames or opens a rapid transit portal into the underworld by following these notes, I am not responsible. (Though if asked nicely, might try to help)

Backup Your Apps

Do not use Titanium Backup. It has been abandoned in 2019 and is unfamiliar with newer formats such as split APKs. Backups created with it will not work. Instead, people seem to have luck with SwiftBackup, though some say the open source Neo-Backup (formerly OAndBackupX) is even better. In case Titanium backups is all you have, https://forum.xda-developers.com/t/cant-restore-apps-with-titanium-backup-after-upgrading-to-android-13.4558545/ claims all might not be lost and backups can be made to work by 1. Restoring with TiBu, but not opening the app. 2. Backing it up with Swift Backup, still not opening the app. 3. Restoring it with Swift Backup, 4. Profit. In any case, a full nandroid backup of /sdcard might be a useful additional insurance.

Transferring Backups Out

Rumor has it MTP might cause corruption on large files. Sounds odd, but better use adb push or scp. Physical media such as an actual SD Card or a thumb drive might be even better. While at it, grab a copy of Download, DCIM, Pictures and any other subfolder of /sdcard you might want to save from the total annihilation to follow.

Update /vendor

Latest ROMs will assume latest /vendor partition. To ensure you have it first flash the last/latest official release for the phone. In case of raphael, several editions can be found here – https://xiaomifirmwareupdater.com/firmware/raphael/ I don't know which of them should be used (or if it matters). I used the Global one even though it's not the latest. :/

Update /recovery

Having the latest version of the fanciest recovery might not be sufficient. A13 changed the partition encryption scheme (to FBEv1) and if your recovery hasn't been updated to support the change you might only have a garbled mess where data used to be. This is the case for Orange Fox. It has gone without a maintainer for raphael for a while and the last official release isn't up to date. Luckily, anon has created a working unofficial release (OrangeFox-R11.12FBEv1-Unofficial-raphael.zip) which can be found at https://androidfilehost.com/?fid=4279422670115710816 . Strictly speaking, this step is not necessary, as the process can be completed without having /sdcard access from recovery, but it makes life much easier.

Format Data

Poof.

Flash ROM

In my case Evolution X (https://evolution-x.org/device/raphael). Keep a copy of the OTA for later (in case Magisk suddenly disappears from /boot . See below).

Boot into /system

Do the Welcome-to-your-new-pixel-enjoy-the-unlimited-photo-storage-space song and dance. If the back gesture doesn't work, the way to fix it is 1. Enable Navigation Bar in Settings->The Evolver->Buttons, 2. Select 3-button navigation in Settings->The Evolver->Gestures->System Settings->System Navigation, 3. If the good old navigation bar appears at the bottom, wait a few seconds. If not, look through the settings to see what else needs to be enabled for it to appear. 4. Select Gesture navigation in Settings->The Evolver->Gestures->System Settings->System Navigation . It should be fine now.

Install Magisk

I think I had Magisk installed with the ROM, but then updating it via OTA caused it to somehow disappear. Or something else. Now sure why it vanished. To get it back, in general you need first to consult the Ramdisk paramter shown in the Magisk app. If it is Yes, you can have it running everytime you boot. If it's No, you have to choose 'Recovery Method' when installing, meaning you have to boot into recovery everytime you want to use Magisk, which sucks. This should hold true for all phones with the exception of some Xiaomi models, raphael included, which misreport this paramter. It says 'No', while in fact it does use a ramdisk. Therefore, the procedure to get Magisk back is — 1. Extract boot.img from the OTA you're currently running. 2. adb push/scp it to the phone (or a phone, doesn't need to be the one being updated). 3. Patch it with the Magisk app. Unselect both the recovery method and the Patch vbmeta in boot image options. 3. adb pull/scp it back out (the patched file is called magisk_patched_<version>_<random string>.img) 4. Flash it. Some recoveries might have issues with this step. Best use fastboot. 5. Verify in the app that it's installed. In any case, don't use recovery method when patching a boot image, or not use it when patching a recovery image. It will perform the patch in unnatural ways and your phone will bootloop forever.

Restore Backups

Congrats, you have a phone. Unless you did use Titanium Backup. Why did you use Titanium Backup?! :( And why does revanced's overlays make it stutter and crash?! :/

@yair@tooot.im