[GUIDE] Unlock/Root/Safetynet for Pixel 4a

Search This thread

frank93

Senior Member
Oct 16, 2010
108
22
Berlin
The OTA upgrade method isn't possible anymore (https://topjohnwu.github.io/Magisk/ota.html). To take an ota now, just take it like a normal ota on an unrooted phone, then do the patch boot img method again (repeat those steps used to initially root)
okay, i guess i wasn’t sure if an official OTA (offered via system) will "work" (due to the boot image being patched at that time). you’re saying it will, right?
and after taking that OTA my device will be unrooted, and THEN i’ll patch the boot image just like the first time and reboot again?

(or in short .. switch on "automatic system updates" in developer options, take the OTA, reboot, then back to bootloader, flash the new magisk-patched-boot.img, reboot, that’s it?)

sorry for being a bit slow, i’m just panicking so i don’t brick anything. :)
 
  • Like
Reactions: beeshyams

Zackptg5

Recognized Developer
Sep 18, 2014
4,084
6,662
zackptg5.com
okay, i guess i wasn’t sure if an official OTA (offered via system) will "work" (due to the boot image being patched at that time). you’re saying it will, right?
and after taking that OTA my device will be unrooted, and THEN i’ll patch the boot image just like the first time and reboot again?

(or in short .. switch on "automatic system updates" in developer options, take the OTA, reboot, then back to bootloader, flash the new magisk-patched-boot.img, reboot, that’s it?)

sorry for being a bit slow, i’m just panicking so i don’t brick anything. :)
Yup :)
 
  • Like
Reactions: frank93

DiamondJohn

Recognized Contributor
Aug 31, 2013
4,962
4,236
Sydney
Say, would taking an OTA and rooting afterwards wipe all data?
an OTA should not wipe your data. However, I always do a backup before I do any major changes. Nprmally to catch the cases where IIIII stuffup a syep and accidenta;y trigger a wipe or put myself in a place where I have to do something that will wipe my data.

Flashing the FULL firmware will.
Unlocking your bootloader will.
 

tcat007

Senior Member
Jul 3, 2011
5,416
2,003
Austin, TX
an OTA should not wipe your data. However, I always do a backup before I do any major changes. Nprmally to catch the cases where IIIII stuffup a syep and accidenta;y trigger a wipe or put myself in a place where I have to do something that will wipe my data.

Flashing the FULL firmware will.
Unlocking your bootloader will.
How do you do a back up without TWRP?
 

bobbarker2

Senior Member
Aug 30, 2013
1,495
505
Stuck at bootlogo, help please.

I've always done the following to update:
1. Download factory image from google
2. Extract boot.img and patch using Magisk. Copy patched_boot.img to PC.
3. Disable/Uninstall all Magisk modules
4. Reboot
5. Reboot to bootloader
6. Flash factory image from google but edit flash-all.bat "fastboot -w update image-sunfish-rq2a.210305.006.zip" to "fastboot update image-sunfish-rq2a.210305.006.zip" - removing the "-w" so it doesn't wipe user data.
7. Let phone boot, then reboot to bootloader.
8. fastboot flash boot patched_boot.img

And then I have updated and achieved root. I've had this phone since launch and done it this way for every update. But this time phone will not boot after flashing patched_boot.img. I followed instructions for v22 and unhid Magisk also. I was on V22 before flashing March update too.

Anyone have similar situation or advice on why this time its not working?

During google boot animation I can adb, I've even done
adb shell
magisk --remove-modules

just in case I forgot to disable/uninstall a module and it was causing a problem but no difference.
 
Last edited:
  • Wow
Reactions: frank93

frank93

Senior Member
Oct 16, 2010
108
22
Berlin
I've always done the following to update:
wow - i was in the same situation! with android 10 i always/usually updated more or less exactly like this - using the complete firmware, not even disabling magisk, but instead editing flash-all.bat: removing the wipe parameter at the end, and flashing the patched boot.img directly afterwards (within the batch/script). it worked just perfectly UNTIL android 11 came along, when i started to have the same results just like you describe: stuck at the google-"g"-logo, and back to bootloader. no matter what i tried, even with disabling magisk and/or trying to reboot first before patching boot.img .. like, a "clean" stock firmware upgrade, same result. and just the same with an ota-sideload. flashing back the "current" firmware at that point always got me back running the device again. but no upgrade. i ASSUME i ****ed something up while updating an earlier version, flashing something to both slots instead of (the correct) one, but that’s just a wild guess, can’t really confirm.

(until today i’ve got no idea what caused this, and didn’t find a workaround. i ended up getting a new device (!), updating to android 11 there and installing everything from my backup & from scratch until i was happy. sold my old device for "nearly as new", so my investment was €40 and a lot of time "only". :) before i sold it, i finally was able to update that older device to android 11 using the built-in "reset phone"-feature (wiping everything), so .. still not sure what caused all of this, but it doesn’t matter too much anymore.)

not much help here, i imagine. but sympathy for your case, at least, for what it’s worth ... :)
 

DiamondJohn

Recognized Contributor
Aug 31, 2013
4,962
4,236
Sydney
How do you do a back up without TWRP?
Notice I used the tern "backup" and not nandroid. ;)

I backup my Calls, SMS, Apps & their Data, and various exports of my settings/config. I also have a folder on my PC of all the Magisk modules I have installed and apps not on the playstore and therefore not linked to my PlayStore account. Then I can flash the original firmware and restore the "backups".
 
  • Like
Reactions: tcat007

Typhus_

Senior Member
Jan 9, 2013
1,132
1,206
41
Lisbon
www.facebook.com
Xiaomi Mi A1
Xiaomi Mi A3
Stuck at bootlogo, help please.

I've always done the following to update:
1. Download factory image from google
2. Extract boot.img and patch using Magisk. Copy patched_boot.img to PC.
3. Disable/Uninstall all Magisk modules
4. Reboot
5. Reboot to bootloader
6. Flash factory image from google but edit flash-all.bat "fastboot -w update image-sunfish-rq2a.210305.006.zip" to "fastboot update image-sunfish-rq2a.210305.006.zip" - removing the "-w" so it doesn't wipe user data.
7. Let phone boot, then reboot to bootloader.
8. fastboot flash boot patched_boot.img

And then I have updated and achieved root. I've had this phone since launch and done it this way for every update. But this time phone will not boot after flashing patched_boot.img. I followed instructions for v22 and unhid Magisk also. I was on V22 before flashing March update too.

Anyone have similar situation or advice on why this time its not working?

During google boot animation I can adb, I've even done
adb shell
magisk --remove-modules

just in case I forgot to disable/uninstall a module and it was causing a problem but no difference.

Your procedure is exactly the procedure I always do, nothing wrong there.

Now, you may have been facing a stupid bug that I've already identified earlier upon my tests. I did noticed it since usually I'm always with the phone connected to my PC with Android Studio open after applying an OTA and rooting it again, so I catch the logcats.

Try to run this at boot as soon as boot animation starts and you're able to "talk" through adb:

Code:
pm grant com.android.systemui android.permission.READ_CONTACTS

See if that helps.

Yes, I know..."WTF!?" right?
 

jackbob1234

Member
Oct 13, 2020
16
0
hello i cannot pass safetynet using the Safetynet-fix module. anyone managed to pass safetynet? also is the magisk app messing up anyones systems as in when you open it, it never opens and then you cant open any other app.
 

tcat007

Senior Member
Jul 3, 2011
5,416
2,003
Austin, TX
hello i cannot pass safetynet using the Safetynet-fix module. anyone managed to pass safetynet? also is the magisk app messing up anyones systems as in when you open it, it never opens and then you cant open any other app.
I'm still on February with no issues. Magisk is at rev 22.0 which eliminated the manager app. Universal Safetynet Fix 1.1.1 works for me.
 

Mr.Demous

Member
Feb 20, 2011
42
11
Cairo, Egypt.
Stuck at bootlogo, help please.

I've always done the following to update:
1. Download factory image from google
2. Extract boot.img and patch using Magisk. Copy patched_boot.img to PC.
3. Disable/Uninstall all Magisk modules
4. Reboot
5. Reboot to bootloader
6. Flash factory image from google but edit flash-all.bat "fastboot -w update image-sunfish-rq2a.210305.006.zip" to "fastboot update image-sunfish-rq2a.210305.006.zip" - removing the "-w" so it doesn't wipe user data.
7. Let phone boot, then reboot to bootloader.
8. fastboot flash boot patched_boot.img

And then I have updated and achieved root. I've had this phone since launch and done it this way for every update. But this time phone will not boot after flashing patched_boot.img. I followed instructions for v22 and unhid Magisk also. I was on V22 before flashing March update too.

Anyone have similar situation or advice on why this time its not working?

During google boot animation I can adb, I've even done
adb shell
magisk --remove-modules

just in case I forgot to disable/uninstall a module and it was causing a problem but no difference.

Did you find a fix for this?

Your procedure is exactly the procedure I always do, nothing wrong there.

Now, you may have been facing a stupid bug that I've already identified earlier upon my tests. I did noticed it since usually I'm always with the phone connected to my PC with Android Studio open after applying an OTA and rooting it again, so I catch the logcats.

Try to run this at boot as soon as boot animation starts and you're able to "talk" through adb:

Code:
pm grant com.android.systemui android.permission.READ_CONTACTS

See if that helps.

Yes, I know..."WTF!?" right?

I also tried this and it didn't help. Still stuck on G logo after flashing magisk patched image
 

Typhus_

Senior Member
Jan 9, 2013
1,132
1,206
41
Lisbon
www.facebook.com
Xiaomi Mi A1
Xiaomi Mi A3
I also tried this and it didn't help. Still stuck on G logo after flashing magisk patched image

Which Magisk version did you use to patch the boot.img?

Did you try to use the one I've shared HERE?

One other thing, one of your previous installed modules could be causing issues. Have you tried to remove them all, or disable them, before trying to boot?
 

Mr.Demous

Member
Feb 20, 2011
42
11
Cairo, Egypt.
Which Magisk version did you use to patch the boot.img?

Did you try to use the one I've shared HERE?

One other thing, one of your previous installed modules could be causing issues. Have you tried to remove them all, or disable them, before trying to boot?

I tried Magisk 22.0 and the latest canary (22004), both of them didn't work. I also removed all previous modules from magisk. Don't know what else to try.
 

Typhus_

Senior Member
Jan 9, 2013
1,132
1,206
41
Lisbon
www.facebook.com
Xiaomi Mi A1
Xiaomi Mi A3
I tried Magisk 22.0 and the latest canary (22004), both of them didn't work. I also removed all previous modules from magisk. Don't know what else to try.
Weird.

You need to capture a logcat and check what could be wrong.

Having the Magisk patched boot.img running, while booting up connect your device to your PC and run:

adb logcat > log.txt

Look for "FATAL" on the log.

You could also force boot into safe mode. While seeing the boot animation, keep pressing the volume down button. That will force your device to boot into safe mode. Magisk will detect that mode and it will disable all modules (if any installed).


If nothing works, you can just flash latest stock through fastboot. Delete the "-w" flag on the update command inside the flash-all.bat to retain your data.

If not even that does the tick, then you have no choice but to completely wipe your storage. Use flash-all.bat keeping the "-w" flag.


Cheers!
 

bobbarker2

Senior Member
Aug 30, 2013
1,495
505
Your procedure is exactly the procedure I always do, nothing wrong there.

Now, you may have been facing a stupid bug that I've already identified earlier upon my tests. I did noticed it since usually I'm always with the phone connected to my PC with Android Studio open after applying an OTA and rooting it again, so I catch the logcats.

Try to run this at boot as soon as boot animation starts and you're able to "talk" through adb:

Code:
pm grant com.android.systemui android.permission.READ_CONTACTS

See if that helps.

Yes, I know..."WTF!?" right?
Thanks for the advice. If it happens to me again I'll try it but I'm not sure that will fix it as I was watching the log cats as well and was watching all critical system processes die and try and start again only to die again.

I think some module I was using, maybe audio related, changed something in my system - which of course defeats the purpose of Magisk.

I got impatient and just did a factory reset. All set now. I was a bit disappointed by Swift backup's restore capabilities. Lots of apps were broken and required clearing of data or reinstall. I wish titanium backup developers would make the project active again.
 

DiamondJohn

Recognized Contributor
Aug 31, 2013
4,962
4,236
Sydney
Thanks for the advice. If it happens to me again I'll try it but I'm not sure that will fix it as I was watching the log cats as well and was watching all critical system processes die and try and start again only to die again.

I think some module I was using, maybe audio related, changed something in my system - which of course defeats the purpose of Magisk.

I got impatient and just did a factory reset. All set now. I was a bit disappointed by Swift backup's restore capabilities. Lots of apps were broken and required clearing of data or reinstall. I wish titanium backup developers would make the project active again.
Magisk has a shell command to disable all modules in case of boot-loops caused by a module.
Code:
adb wait-for-device shell magisk --remove-modules

from https://www.didgeridoohan.com/magisk/Magisk by @Didgeridoohan
 
  • Like
Reactions: Didgeridoohan

tohypnos

New member
Aug 29, 2020
2
0
I had failed getting root after updating to 11. Many trials failed while CRC of my own patched img does match with an uploaded img on the Internet.
I finally came up with a solution and now get Magisk work. I hope this helps people who failed applying Magisk with bootloops.
1. Prepare patched boot img as well as the PC.
2. Push the power button and tap Power off longer. Then, click ok to reboot to safe mode.
3. Before rebooting, push vol- and go into fastboot.
4. Flash patched boot img: fastboot flash boot xxx.img and fastboot continue.
5. Now the device starts with the safe mode disabling all Magisk modules, some of which was actually causing bootloops.
6. Reboot normally. Then, the phone starts still all Magisk modules inactive.
7. Remove or update outdated modules and enjoy root again;)

This procedure is based on (or exactly the same) with a safe mode solution which you can find the link above but I couldn't make it before because I was fully rebooting before applying a patched img.

In case you failed something, just flash-all (Note: don't forget to remove -w) and try from the beginning.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 19
    With the pixel 4a finally arriving for some (like me), figured I'd make a quick guide

    Note that unlocking your bootloader breaks safetynet. There's a workaround in this guide but no guarantee that it won't get patched out in the future.

    Also note that this only works with the unlocked carrier model. Cell providers typically lock you out from this unlock process.

    Unlocking Bootloader (this is for the unlocked mode, can't speak for other models)
    • Go to system settings -> About phone -> tap on 'Build number' several times until Developer Options is enabled
    • Back out into settings and go to System -> Advanced -> Developer Options -> Enabled 'OEM Unlocking'
    • Unplug your phone if it's plugged into anything and power it off
    • Boot into fastboot by holding Power + Vol Down
    • Plug into pc -> open terminal/shell/whatever
    • Type 'fastboot flashing unlock' -> Follow prompt on device to unlock bootloader (Note that this will FACTORY RESET device)
    • The bootloader is now unlocked!

    Rooting
    • Grab the boot img for your rom. If it's stock, get it from the official zip
    • Copy the boot.img to your device
    • Install Magisk manager (grab it from the release zip on github - it's in the common folder)
    • Open Magisk Manager -> select 'Beta'
    • Back on the main page of Magisk Manager, Select 'Install' -> 'Select and Patch File' -> select your boot.img file -> it'll output the patched boot img to your Downloads folder
    • Copy the magisk_patched.img to your pc
    • Reboot your device back into fastboot (see Unlock section above)
    • Open a terminal in the directory your patched boot img file is and type 'fastboot flash boot magisk_patched.img'
    • You're now rooted!
    • Disable "Automatic System Updates" in Developer Options so you aren't surprised with an OTA on boot and end up unrooted (see the OTA section below on proper way of updating)

    Passing SafetyNet
    As was discovered some time ago, google is switching to a hardware attestation method for safetynet. Fortunately, at the time of writing, there is a workaround thanks to @Didgeridoohan. As of January 2021, this fix no longer works. A new module by @kdrag0n now fixes the hardware attestation issue:
    • Enable MagiskHide in magisk manager
    • Download/Install his Safetynet-fix module from this xda thread
    • Reboot and verify you should hopefully pass safetynet!

    Taking an OTA While Rooted

    Note: Installing to Inactive slot has been disabled temporarily meaning that if you take an ota, you'll need to do the patch boot img method like you did initially. See here for more details.

    Note that you can download the rom from google's site here and extra the boot img from there for patching.
    TopJohnWu has a great guide on how to do this here along with some nice screen shots that complement this quick guide. I'll summarize the applicable stuff here:
    • When an OTA is available, ignore it at first
    • Open Magisk Manager and go to Uninstall -> Restore Images
    • Now go back to Settings -> System -> Advanced -> System Update and install the OTA but DO NOT REBOOT
    • Once the install is done (but before rebooting), go back into Magisk Manager -> Install -> Install to Inactive Slot
    • Once the install is done, choose the reboot option IN MAGISK MANAGER. It works some voodoo magic to switch to updated slot and skip post-ota verifications
    Having issues?

    Try magisk canary instead


    Note that this isn't a support thread but just a guide. You're welcome to post your tips/experiences/questions here but don't expect me to answer or reply to them.

    I'll try to keep this updated with other useful guides such as TWRP when/if it is released for this device :good:
    3
    Everytime I install magisk module and reboot I boot back up without root. Amy help?

    When you fastboot flash, make sure you flash the slot you're booting from. If you're feeling lazy, flash the patched boot.img into both slots
    Code:
    fastboot flash boot --slot all boot.img
    3
    Actually I'm on October update, with unlock bootloader and root with Magisk Canary, how can I update to November update? If someone can explain clearly, I'm little afraid with out TWRP...

    Hello,

    You could do easily.
    - First check the channel update in magisk. Change to beta (beta works well know for patching boot.img)
    - Update the manager, update magisk by direct install, update modules if needed --> reboot
    (it's better to limit risk of a bootloop)
    - After reboot, open magisk manager and uninstall magisk --> Restore images.
    - Know you could going to settings --> system --> advanced --> update (you will see the november update)
    - Update --- (wait wait wait) and reboot (it's actually impossible to keep root by reflashing from magisk before reboot), after this you have lost root when reboot

    - Download the last sunfish for pixel 4a from --> https://developers.google.com/android/images#sunfish
    (don't accept any other sources about boot.img) check that the version is the same as the one you just updated.
    - Extract boot.img from zip inside the zip archive -> transfert on phone (delete any old boot.img or patched on the phone, to avoid a mistake)
    - In magisk manager --> install magisk --> select and patch a file, choose the boot.img.
    - transfert the new makisk_patched.img on computer in adb folder for example(look the size, it must be the same as the original file)
    - power off phone
    - Boot into fastboot by holding Power + Vol Down
    - plug phone and open adb
    Code:
    d:\platform-tools>fastboot flash boot magisk_patched.img
    Sending 'boot_b' (65536 KB)                        OKAY [  1.629s]
    Writing 'boot_b'                                   OKAY [  0.294s]
    Finished. Total time: 2.265s
    
    d:\platform-tools>fastboot reboot
    Rebooting                                          OKAY [  0.044s]
    Finished. Total time: 0.052s

    That's all, your are re-rooted after update.
    2
    How do you correctly update magisk on Pixel4a since patching boot.img and stuff. What are the steps ?
    2
    i was trying to create a patched boot.img but the file always ends up being about half the size of the original file and when i flash it i cant boot any longer.

    Is there a specific version/combination of softwares that i need to produce a valid patched boot image? im currently using magisk manager 8.0.3 and 11.0.0 (RQ1A.201205.008, Dec 2020)

    EDIT: got it sorted out, as many stated before i needed to use the Canary Magisk apk to make it work. it was not so obvious where to get and the provided links are not working. In case anyone is looking for the link its on the github page in the readme
    1608385790142.png
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone