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

Search This thread

Vedarshi

Senior Member
Oct 25, 2012
118
27
Mumbai
I've already upgraded to Android 12

After installing the patched boot.img, my 4a sits on the G screen with the loading bar below it. It is accessible via ADB, and I have run
Code:
magisk --remove-modules

I also couldn't get the phone to boot into safe mode 🙁

It's boots just fine using the unpatched boot.img
I have the same issue since the Jan build. Lost root with OTA and unable to boot into the patched magisk image - the screen is stuck at the loading bar.
I've tried flashing with dm-verity disabled, lock/unlock bootloader, wiped phone and reinstalled but it doesn't seem to work.

But here's a peculiar issue -
If I fastboot boot into the patched image, it is stuck but fixed with a reboot. If I 'fastboot flash boot', I cannot boot into the phone even after re-flashing original boot image. I have to flash all partitions again. Not sure why this is occurring
 
Last edited:

ParoxysmX

Member
Aug 5, 2011
13
1
So I have a bit of a weird problem, I don't seem to be able to either flash the patched boot.img or boot it directly as some have suggested. I'm on android 12, build SQ1A.220205.002, Feb 2022. So I downloaded the factory boot.img, patched it with the latest Magisk (v24 at the time of writing this) and tried to flash my patched image but the error is

Code:
FAILED (remote: 'Failed to write to partition Bad Buffer Size')

Now I notice the partition size is 62 megabytes approximately and the patched boot img is about 98. But weirdly the factory one is the same size. So in theory I couldn't even flash the factory. When trying to boot the patched image directly, it says

Code:
(bootloader) boot.img missing cmdline or OS version
FAILED (remote: 'Error verifiying the received boot.img: Volume Corrupt')

Which is bizarre. I tried resizing partitions but the command fails on the remote end. Any ideas?


edit: i was using the boot img for the wrong type of Pixel...bozo
 
Last edited:

cmstlist

Senior Member
Jan 11, 2010
3,374
524
Toronto
Google Pixel 4a
So I've been super lazy and haven't even upgraded to Android 12 yet. And now I have Magisk asking me to update to 24.1 which is the version that eliminates MagiskHide. So maybe someone can summarize for me: What is the "new and correct" way to install Magisk and whatever additional tools are required to get SafetyNet passing, Google Pay working, etc?
 

Lada333

Senior Member
Feb 7, 2016
1,464
493
22
Budapest
OnePlus 3T
Google Pixel 6a
Hey guys!

I've read through the last few pages of this thread, however I'd like to ask a few questions to clarify things.

I have a Pixel 4a (bought from Google Store, so it's unlocked) running Android 12 (SQ1A.220205.002). Never been rooted, never had a custom rom flashed.

  1. Is rooting as simple as downloading the latest factory image from developers.google.com to my phone, using the Magisk app to patch the image, then copying the image to my PC and then using ADB to flash the patched image?
  2. I've never had a device that had A/B side patches. Would I need to install the patched/rooted system image twice, essentially, to always have root? Or is that something I needn't worry about?
  3. Is there a way to make a backup of my current system image? As in, if trying to boot the patched image fails (ie. bootloop), can I just go "back" to how it was before? Or could I just flash the un-patched/stock factory image? Is that "guaranteed" to work?
  4. If I manage to softbrick my device, is there a way to get it back? I had a OnePlus 3T before this phone, I remember using an "unbrick tool" once when I bricked it -- does anything similar exist for the Pixel 4a?
  5. Does the Universal SafetyNet Fix work for Google Pay and banking apps (I'm aware that not all banking apps are built the same way, so it might work for some, and might not for others. I'd just like to know if it works for most, or not at all)?
  6. Is there anything to beware of? Any major annoyances, dealbreakers, etc? I used to daily my 3T, and back than I had more time on my hand (so that when something broke, it wasn't a big deal to lose data, flash stuff again, start from scratch), unfortunately that's not the case anymore. I need my phone to be as reliable as possible. Basically my main reason for rooting would be to have access to Advanced Charging Controller. Is it worth the hassle?

Apologies for the long post, and thank you for your answers in advance.
Cheers!
 

beeshyams

Senior Member
Dec 29, 2014
1,674
610
Bangalore
Hey guys!

I've read through the last few pages of this thread, however I'd like to ask a few questions to clarify things.

I have a Pixel 4a (bought from Google Store, so it's unlocked) running Android 12 (SQ1A.220205.002). Never been rooted, never had a custom rom flashed.

  1. Is rooting as simple as downloading the latest factory image from developers.google.com to my phone, using the Magisk app to patch the image, then copying the image to my PC and then using ADB to flash the patched image?
  2. I've never had a device that had A/B side patches. Would I need to install the patched/rooted system image twice, essentially, to always have root? Or is that something I needn't worry about?
  3. Is there a way to make a backup of my current system image? As in, if trying to boot the patched image fails (ie. bootloop), can I just go "back" to how it was before? Or could I just flash the un-patched/stock factory image? Is that "guaranteed" to work?
  4. If I manage to softbrick my device, is there a way to get it back? I had a OnePlus 3T before this phone, I remember using an "unbrick tool" once when I bricked it -- does anything similar exist for the Pixel 4a?
  5. Does the Universal SafetyNet Fix work for Google Pay and banking apps (I'm aware that not all banking apps are built the same way, so it might work for some, and might not for others. I'd just like to know if it works for most, or not at all)?
  6. Is there anything to beware of? Any major annoyances, dealbreakers, etc? I used to daily my 3T, and back than I had more time on my hand (so that when something broke, it wasn't a big deal to lose data, flash stuff again, start from scratch), unfortunately that's not the case anymore. I need my phone to be as reliable as possible. Basically my main reason for rooting would be to have access to Advanced Charging Controller. Is it worth the hassle?

Apologies for the long post, and thank you for your answers in advance.
Cheers!
1. Yes
2. Don't bother about A/B
3 & 4.You can always flash the OTA update or factory image to get out of mess. Unless you did something really weird, it should work
5. Yes
6. Nothing to worry. I've been using Acc for long

Edit : monthly updates require you to root (step 1). Seamless update to inactive slot is long dead
 
Last edited:
  • Like
Reactions: Lada333

Lada333

Senior Member
Feb 7, 2016
1,464
493
22
Budapest
OnePlus 3T
Google Pixel 6a
Edit : monthly updates require you to root (step 1). Seamless update to inactive slot is long dead
Meaning that if I apply an OTA, I'll lose root? So, again, I'll have to manually patch the latest factory image and then flash it? That would count as a "dirty flash," so there's no need to wipe all data, and set everything up from scratch, correct?
Also, what do you mean by "Seamless update to inactive slot is long dead"?
 

beeshyams

Senior Member
Dec 29, 2014
1,674
610
Bangalore
Meaning that if I apply an OTA, I'll lose root? So, again, I'll have to manually patch the latest factory image and then flash it? That would count as a "dirty flash," so there's no need to wipe all data, and set everything up from scratch, correct?
Also, what do you mean by "Seamless update to inactive slot is long dead"?
Yes to first paragraph
Second Para-only to reiterate that you can't use the old Magisk method of retaining root while applying OTA
 
  • Like
Reactions: Lada333

Lada333

Senior Member
Feb 7, 2016
1,464
493
22
Budapest
OnePlus 3T
Google Pixel 6a
Yes to first paragraph
Second Para-only to reiterate that you can't use the old Magisk method of retaining root while applying OTA
What was the old Magisk method?
Also, one last question: if I wanted to go back to "factory settings," I just flash a factory image, lock the bootloader, and, as far as my device is concerned, it has never been tinkered with?
 

beeshyams

Senior Member
Dec 29, 2014
1,674
610
Bangalore
What was the old Magisk method?
Also, one last question: if I wanted to go back to "factory settings," I just flash a factory image, lock the bootloader, and, as far as my device is concerned, it has never been tinkered with?
Old method, you can Google it. No point in describing what doesn't work

Yes to the second part, though I didn't try as I want root always. Factory image flashing locks the boot loader too.
 
  • Like
Reactions: Lada333

mikkoc

Senior Member
Mar 19, 2011
56
10
Has anyone been able to get banking apps to work with the latest Magisk 24.2 + zygisk + SafetyNet Fix 2.2.1?
I manage to pass all the checks with YASNAC, forcing BASIC evaluation and spoofing a Nexus 6P device.
Added all the apps in the Magisk DenyList, and Enforce DenyList enabled. Yet, all my banking apps detect root.
 

Lada333

Senior Member
Feb 7, 2016
1,464
493
22
Budapest
OnePlus 3T
Google Pixel 6a
Has anyone been able to get banking apps to work with the latest Magisk 24.2 + zygisk + SafetyNet Fix 2.2.1?
I manage to pass all the checks with YASNAC, forcing BASIC evaluation and spoofing a Nexus 6P device.
Added all the apps in the Magisk DenyList, and Enforce DenyList enabled. Yet, all my banking apps detect root.
I use Magisk Canary (24201) with SafetyNet Fix v2.2.1. I also have Zygisk enabled, DenyList enforced (banking apps added to the DenyList, of course), and it works for me.

Have you renamed your Magisk app? Some apps gave me an error, saying I'm rooted, even when I wasn't, but I had the Magisk app installed. I assume they also check for specific package names that could indicate that your device might be rooted?
I have my Magisk Manager renamed to mSettings, no apps have detected root so far.
 

mikkoc

Senior Member
Mar 19, 2011
56
10
Have you renamed your Magisk app? Some apps gave me an error, saying I'm rooted, even when I wasn't, but I had the Magisk app installed. I assume they also check for specific package names that could indicate that your device might be rooted?
I have my Magisk Manager renamed to mSettings, no apps have detected root so far.
Ok that worked for one app, but not for the other (HSBC). Oh well, that's OK, I can live with it. Thanks
 

XDAUser1234

Member
Sep 5, 2014
42
3
Quebec City
Anyone manage to successfully boot the patched magisk boot image? I was able to flash android 12 without issues, update my Magisk Canary, move the boot image to my device, patch the image, move back to PC, and fastboot flash boot patched.img -- cool beans. But then just cycle cycle cycle cycle cycle on the google logo without booting fully up. whats curious (to me) is it does boot up enough, because my WhatsApp on my PC begins to work again as if my Pixel is back on, but it is stitll just on the Google logo. Reflashing the original boot.img brings it right back up.

Any workarounds?
 

Lada333

Senior Member
Feb 7, 2016
1,464
493
22
Budapest
OnePlus 3T
Google Pixel 6a
Anyone manage to successfully boot the patched magisk boot image? I was able to flash android 12 without issues, update my Magisk Canary, move the boot image to my device, patch the image, move back to PC, and fastboot flash boot patched.img -- cool beans. But then just cycle cycle cycle cycle cycle on the google logo without booting fully up. whats curious (to me) is it does boot up enough, because my WhatsApp on my PC begins to work again as if my Pixel is back on, but it is stitll just on the Google logo. Reflashing the original boot.img brings it right back up.

Any workarounds?
What command did you use to flash the patched boot image?
Was it "fastboot flash boot boot.img"? If so, could you try flashing it with "fastboot flash --slot all boot boot.img"?
 

XDAUser1234

Member
Sep 5, 2014
42
3
Quebec City
What command did you use to flash the patched boot image?
Was it "fastboot flash boot boot.img"? If so, could you try flashing it with "fastboot flash --slot all boot boot.img"?

originally was using "fastboot flash boot patched_file.img" , then "fastboot reboot". No dice, and then fastboot flash boot boot.img to get back to normal....

just tried the above with --slot all, and it did send both options with that. Send and Write to both slot a, and slot b.....then reboot and same issue, just the Google Icon and the scrolling line scrolling on and on. I remember a while back that this was EXPECTED (to take forever) and to just let it go.... so tried that, and after watching it for over 30 mins I flashed back the regular boot.img, still no luck. Hmm.
 
Last edited:

beflythis

Senior Member
Jan 2, 2008
200
21
hello fellow sunfish folk... I am an oldschool android power user who's just picked up a pixel 4a and doing the due diligence and enjoying stock rom before going wrist deep.

coming from suzuran family (sony xperia devices), I've dealt with compromised camera on custom ROMs for far too many years... nice to see older issues / manufacturer proprietary issues are becoming less and less of a blocker as time passes.

that said, from what I am reading here and what I am seeing on youtube vids... there seems to be a blocker on latest magisk with working finance/gov apps (that don't like root) and ability to take OTA updates with root... this is what I'm seeing:

1) older magisk required to take OTA updates (device signature workaround from what I can learn here)
2) newer magisk required to use trusted apps that block on a rooted device

so does that mean there is currently no solution to be able to take OTA updates if you wish, remain rooted, AND ALSO use trusted apps? am I reading that correctly? Not a huge issue for my use case, but simply trying to understand the lay of the landscape before I start unlocking, rooting, flashing.

Second question - seeing some nice kernel dev work on these boards (woohoo!!!). Is there a hard rule of thumb about which kernels work with which roms? Fully open compat? Listed on a per-kernel basis? Apologies for the basic question that may have an obvious answer. Is there a yet established "gold standard" with a preferred combo of aftermarket kernel + custom ROM? Any recos?

coming from Sony DRM with camera issues (amazing camera if stock, ROM wipes DRM keys which compromises camera forever thereafter) - are there any similar issues with pixel roms or any forewarnings folks may have for me prior to unlocking/rooting/flashing? NGL looks like phones and platforms are getting safer and safer, easier to mod and less penalizing [nice thing]. Hoping that is correct.

Thanks in advance and what a snazzy device. happy to be a sunfish bro.
 

a1291762

Senior Member
Nov 20, 2012
751
319
yasmar.net
Anyone manage to successfully boot the patched magisk boot image?

If you can't get someone else's patched boot image to work, you can make your own.

Download the factory image that matches the version you are running. Extract it, and the embedded zip to get the boot.img. Send that to the device and use Magisk to patch it. Send it back to the PC and use fastboot to flash it (or get fastboot to boot it, then use Magisk to patch boot directly).
 

XDAUser1234

Member
Sep 5, 2014
42
3
Quebec City
If you can't get someone else's patched boot image to work, you can make your own.

Download the factory image that matches the version you are running. Extract it, and the embedded zip to get the boot.img. Send that to the device and use Magisk to patch it. Send it back to the PC and use fastboot to flash it (or get fastboot to boot it, then use Magisk to patch boot directly).

Yes, just confirming that is indeed the process I was using :) Moved the boot.img to my Pixel, use the updated Magisk Canary to patch it, move it back to to my PC, then fastboot flash it. No dice. Did someone post a patched imaage? If so, I missed it and will look back. That was actually the only way I managed to get it to work a few versions ago - self patching just would not take.

Also - realizing perhaps I am just using incompatible versions. Took the March 2022 update and have the latest magisk.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 32
    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
    It works for me:
    Magisk 23.0 stable
    Riru v 26.1.3.r513...
    Universal Safetynet Fix v2.1.2
    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
    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