topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
48.28k stars 12.33k forks source link

Recovery Image Patching during 20.4 -> 21.1 Upgrade on legacy Huawei devices running EMUI9 results in unexpected behavior and requires extra steps to avoid device wiping. #3518

Closed eierfrucht closed 3 years ago

eierfrucht commented 3 years ago

Below is a quote from a Telegram discussion. This is my firsthand account. I ran into this issue while attempting to upgrade from Magisk 20.4 to Magisk 21.1 using Magisk Manager 8.0.3 on a Huawei Honor 8 Pro (DUK-L09) running EMUI 9.1.0.215. Please regard this as more of a friendly warning for the owners of rooted Huawei devices and not an attempt at nagging the developer to fix it ASAP. Even though I was able to replicate it for several times, I really need my device all set up and can't afford performing another few factory resets for testing purposes.

"Damn this is super weird. Just to remind, this is all happening on a Huawei DUK-L09 (Honor 8 Pro a.k.a. Honor V9) So, recovery.img (actually RAMDIS.img, partition 'recovery_ramdisk') DOES get correctly patched with Magisk 21.1 both via "Direct Install" and "Patch a File" routes in Magisk Manager 8.03. You absolutely have to check 'Recovery Mode' as per manual, in my case it is auto-checked with either method anyway. The catch is: on the first boot with 21.1, you DO boot into Magisk-patched recovery image, but the 'Wipe system' option does not make Magisk booting persistent (which is one of the supposed effects of a patched ramdisk). It actually wipes the living crap out of your system — just as expected from an UNPATCHED recovery image. And seemingly there is no way to boot into the OS with Magisk enabled, no combination of long / short presses with USB power plugged / unplugged gets you there, it's either OS with Magisk disabled or 'normal' Recovery (even though the manual says you can only enter 'normal' recovery if you long press the Recovery key combo). To get Magisk 21.1 working, I had to reflash a ramdisk patched with 20.4, enter the Magisk-patched recovery with short pressing the Recovery key combo upon device start, selecting 'Wipe Device' as usual — and that (expectedly) made Magisk booting persistent. What was totally unexpected is that when I reinstalled Magisk 21.1 via Magisk Manager 8.03 using the "Direct Install" method, the system successfully rebooted into Magisk 21.1."

"The most puzzling thing is that if I wipe the device, there's no way to initially boot into the OS with a Magisk 21.1 pre-patched recovery image. I have to flash 20.4 first, update to 21.1 from the Manager, reboot, flash 20.4 again, enter Recovery, choose Wipe, reboot, update to 21.1 again and only then Magisk 21.1 becomes persistent. Until the next wipe. The initial update from 20.4 to 21.1 after a wipe results in booting into a 'normal' Recovery that will actually do another wipe on selecting Wipe instead of making Magisk booting persistent... Yeah this is as convoluted as it sounds, but I reproduced this pattern 4 times."

/EDIT/ To clarify: on my device with Magisk 19. and 20., after the initial (i.e. following a full factory reset / ROM upgrade) flashing of a patched recovery image, I absolutely had to enter Recovery once and select Wipe Device, but instead of wiping, it configured the device to boot into OS with Magisk enabled at all times. Without this step, there was no way to boot the OS with Magisk enabled. If you just booted the device without pressing anything, you ended up in the OS with Magisk disabled; if you booted into Recovery and selected anything else than Wipe, it worked as expected and you still ended up in the OS with Magisk disabled. The below paragraph from Magisk Manual NEVER worked for me unless I hit Wipe in Magisk-patched recovery at least once, and after doing that booting into Magisk became persistent until the next wipe.

(Power up normally) → (System with NO Magisk) (Recovery Key Combo) → (Splash screen) → (Release all buttons) → (System with Magisk) (Recovery Key Combo) → (Splash screen) → (Keep pressing volume up) → (Recovery Mode)

The initial installation of Magisk 21.1 on my device results in literally no way for booting the OS with Magisk enabled, and no way to make Magisk enablement persistent. Hitting Wipe in Magisk-patched recovery just wipes the device, just like with stock unpatched recovery -- as opposed to recovery images patched with Magisk 19. and 20.

When I manually re-flash 20.4 after the initial installation of 21.1, hit Wipe in Recovery, then re-flash 21.1 via fastboot (or re-upgrade it from 20.4 to 21.1 via Magisk Manager) the system continues to persistently boot with Magisk 21.1 enabled. From now on, until the next Factory Reset (or ROM upgrade), I can flash / install whichever Magisk version I desire, upgrade or downgrade it, and the system still always boots with Magisk enabled.

topjohnwu commented 3 years ago

Sorry, I don't have time to read a novel to understand your issue, please make the report short and clear...