Android 12 GSI Post Install Fixes - Motorola Razr 5G Guides, News, & Discussion

I have been messing around with GSI roms on this device for a little over a month, and I've created some Magisk modules and an Xposed module to begin to fix the issues with the Cli display.
Disclaimers (READ THESE!!):
There are still a number of other issues with GSIs on this device, so I wouldn't recommend doing this if you use your razr as your main phone.
If you brick your device, it is your own responsibility. I am not responsible for any damage that my modules or advice might cause to your device. Do not blame me for bricking your device.
This is not written to be easy for beginners. If this is your first time modifying a device's firmware, I would advise against starting with this phone. But I would highly recommend you to start on a different device that has less restrictions and is much cheaper.
If I do not mention how to do something, you should look up a guide first before asking me. The guides that other people write are likely going to be much better and easier to understand than one I can write.
Please note that these modifications may not work on your device if the hardware is slightly different, even if it has the same model number as mine. These modifications are mainly a proof of concept, but I am open to modifying them to work on more devices.
If you are curious about how any of these modifications work, see the readme on the modules' github repositories.
By following the steps in this post, you accept that you may end up with either an expensive paperweight, or a mostly functional device with a GSI rom.
These modifications have been tested on my XT2071-3
First thing to do is to make sure you have a way of recovering your phone if it soft bricks. I downloaded the stock rom from lolinet. Make sure you have a rom that is the same version as your current rom. Motorola leaves anti-rollback enabled even if you have an unlocked bootloader.
If mess up, you can just restore it using fastboot (look up a guide)
If you really messed up, you can always try to use the "Rescue and Smart Assistant Tool", but that may be a last resort due to privacy concerns.
If you really really messed up, you may have to use a blank flash. I haven't ever had to use a blank flash, so I can't vouch for whether or not it will work. (don't do it if you don't have to)
The build number of the OS I used when installing the GSI is: RPSS31.Q1-40-34-15-10-15
Spoiler: Installing
It may also be worthwhile to flash copy-partitions-20210323_1922.zip from a custom recovery to prevent accidentally hard bricking your device. (this is recommended by the Lineage OS wiki for most devices with an a/b partition layout, so I figured I should probably use it just to be safe).
You can use thenameisnigel's unofficial TWRP image, or the unofficial lineage recovery that I attached to this post (I would not recommend flashing either one. Use "fastboot boot recovery.img" instead.) I attached the lineage recovery because it's easier to use without touch support, but either should work just fine.
You may also choose to root your phone with magisk before installing the GSI. It will be necessary for the post-install fixes, and may be harder to install after the fact.
I will not go into too much detail of how to install GSI roms, but here is a rough recreation of the fastboot commands I used:
Code:
fastboot reboot fastboot
fastboot --disable-verification flash vbmeta vbmeta.img
fastboot erase system
fastboot delete-logical-partition product_a
fastboot flash system gsi.img
fastboot -w
fastboot reboot
You should look up a tutorial if you need help. I'm not an expert on any of this.
I've tested:
This release of Phh Treble (the one with gapps doesn't work)
This release of Andy Yan's Lineage OS 19
This release of ponces' Pixel Experience GSI
All of them using the vndklite version, and I have not been able to get Android 11 to work.
Spoiler: Fixing the cli display
Once you boot into the GSI, you will notice that the Cli display will show a keyguard presentation that will freeze and stay on the screen after you unlock the device. You may also notice that touching the Cli display will interact with the main display, and not the Cli display like it should.
To fix this, you can install this magisk module: Razr5G Synaptics Touchscreen Device Associations
Before installing, you may want to mute your ringer, since it will break audio (more on that later)
This magisk module adds a configuration file that will map the touch screens to their respective displays.
Now the touch screen maps correctly, but there's still nothing to interact with.
To fix this, you can install another magisk module: Razr5G Foldable Device Fixes
These are two separate magisk modules because I will be releasing more modules that will utilize the cli display in different ways.
This magisk module will configure Android to treat the phone like a foldable device similar to the Samsung Z Fold. This is not the stock behavior of the device, which is why I will be making different modules that activate the display in a way closer to stock.
Now the cli display will actually show the UI if you turn off the display, close the device, and then wake the device. The UI will even transition from the cli display to the main display when you open the device. But if you close the device while the screen is on, the system will freeze. This has to do with Android's display manager referencing a display that the lid sensor just requested to turn off.
To avoid this conflict, I have an Xposed module this time: Cli Lid Functions
I recommend using LSPosed. You will need to enable this module for "System Framework"
This Xposed module will disable the lid sensor's ability to turn off the display. This is not ideal, but it's better than having to reboot your phone.
Spoiler: Fixing audio
For whatever reason, installing magisk modules that modify /vendor/etc on a GSI on phone will replace the audio policies with empty ones. This is not ideal, as it forces audio out of the speakers at full volume. The original audio policies still exist in the magisk mirror under vendor/etc (but not system/vendor/etc). You can overwrite the blank ones and change a setting to restore functioning audio.
1. Overwrite the blank audio policy:
You can do this with a root file explorer, or through the shell
Method A - Root File Explorer:
go to the magisk tmpfs (type "magisk --path" in a shell running as superuser. Example: `/dev/ABcD12`)
then go to .magisk/mirror/vendor/etc (you may need to show hidden files)
copy a2dp_audio_policy_configuration.xml and audio_policy_configuration.xml
paste them in /vendor/etc on the system root (make sure to overwrite the empty files)
Method B - Shell:
Run these commands in `adb shell` or your favorite terminal emulator
Code:
su
cp $(magisk --path)/.magisk/mirror/vendor/etc/a2dp_audio_policy_configuration.xml /vendor/etc
cp $(magisk --path)/.magisk/mirror/vendor/etc/audio_policy_configuration.xml /vendor/etc
After overwriting the files, do not reboot (otherwise they will get overwitten again).
2. Enable "Use alternative audio policy"
Go to `Settings > Phh Treble Settings > Qualcomm features` and enable "Use alternative audio policy"
3. Reboot
Now you can reboot, and you should have working audio again.
Spoiler: Working/Broken
What's working:
UI on the second display (opening apps, checking notifications, etc.)
Only one display on at a time
Display cutout
Camera (plus, only the outer camera works when the display is folded)
Volume buttons flipping when the lid is closed
Fingerprint
Wifi, Bluetooth, and Bluetooth audio (after disabling the hardware offload)
SMS (kind of... and only with an ims.apk)
Data
Battery life is better than stock
A lot more that I'm missing...
What's broken:
System UI is not optimized for the second display
Brightness on the secondary display
More that I'm missing...
I am still new to GSIs, so I haven't tested a whole lot, or attempted to fix much other than this.
Downloads:
Razr5G Synaptics Touchscreen Device Associations
Razr5G Foldable Device Fixes
Cli Lid Functions
Unofficial Lineage Recovery
While I could build my own GSI rom to deal with all of these issues, I chose not to since it would take more time. There is also another advantage of these modifications, which is that they can be applied to a wide variety of GSIs without having to modify each one manually.
Also, Motorola won't let a $1000+ phone boot with a modified vendor partition, for whatever reason.
This was my first time ever making a magisk module, my first time ever making an Xposed module, my first time ever working with the Android system on this low of a level, and my first time installing a GSI rom.
I may update this post with more progress in the future.

reserved

Related

[UNOFFICIAL] TWRP for Lenovo Yoga Tab 3 Plus (YTX703F/YTX703L)

It has been bugging me for quite some time that the Lenovo Yoga Tab 3 Plus has a portrait (phone) 10" screen mounted in a landscape body, and TWRP didn't have the necessary code to adjust its graphics rendering so as to compensate for this, so I just decided to patch it myself.
With these unofficial recoveries (officials can be found here and here), you get the following improvements:
Graphics are rendered in the landscape orientation
Compiled from LineageOS 15.1 sources plus LineageTWRP => much easier to maintain
(For development) Pstore/ramoops active, can retrieve the Android kernel's log on reboot or panic
Mouse pointer in the middle of the screen is gone
Factory reset commands from Android are no longer broken
Removed their prompt to install the TWRP app in Android when you try to reboot
Also be aware that flashing unofficial cm14 zips is not supported with these TWRP images!
If any of the items above bug you as well, these TWRP builds may be for you. At the moment they are optional (not required - you may use other TWRP recoveries just as well) if you are a user of LineageOS 15.1 for YTX703F/YTX703L. However, in the future we will be making steps to replace the official TWRP recoveries with these ones over here.
Known issues
None so far.
Downloads
TWRP 3.2.3: [YTX703F (Wifi)] | [YTX703L (LTE)]
Installation instructions
If your device is new to the custom ROM flashing process, you need to unlock its bootloader:
Code:
fastboot oem unlock-go
If you are not fully decided and just want to try out these TWRP images, you can just hot-boot them into RAM, without writing them permanently to flash storage:
Code:
fastboot boot twrp-3.2.3-UNOFFICIAL-YTX703L.img
If you don't like it, it's not persistent (rebooting again will get you the old recovery back)
If you're sold on the new recovery image, here's how to permanently flash it:
Code:
adb reboot bootloader # Do this only if you're not in fastboot mode right now (with the orange Lenovo image)
fastboot flash recovery twrp-3.2.3-UNOFFICIAL-YTX703L.img
fastboot continue # Will boot into Android
Build instructions
Add the following to .repo/local_manifests/roomservice.xml in a lineage-15.1 tree:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="https://github.com/omnirom" name="omnirom" review="gerrit.omnirom.org" revision="android-8.1" />
<project groups="pdk" name="android_bootable_recovery" path="bootable/recovery-twrp" remote="omnirom" />
</manifest>
Run the following:
Code:
$ repo sync bootable/recovery-twrp
$ source build/envsetup.sh
$ repopick -P bootable/recovery-twrp -g https://gerrit.omnirom.org 31454
$ repopick -P bootable/recovery-twrp -g https://gerrit.omnirom.org 31630
$ repopick -P bootable/recovery-twrp -g https://gerrit.omnirom.org 28622
$ lunch lineage_YTX703L-eng
$ WITH_TWRP=true mka recoveryimage
$ adb reboot bootloader
$ fastboot boot out/target/product/YTX703L/recovery.img
vladimiroltean said:
It has been bugging me for quite some time that the Lenovo Yoga Tab 3 Plus has a portrait (phone) 10" screen mounted in a landscape body, and TWRP didn't have the necessary code to adjust its graphics rendering so as to compensate for this, so I just decided to patch it myself.
With these unofficial recoveries (officials can be found here and here), you get the following improvements:
Graphics are rendered in the landscape orientation
Compiled from LineageOS 15.1 sources plus LineageTWRP => much easier to maintain
(For development) Pstore/ramoops active, can retrieve the Android kernel's log on reboot or panic
Mouse pointer in the middle of the screen is gone
Factory reset commands from Android are no longer broken
Removed their prompt to install the TWRP app in Android when you try to reboot
Also be aware that flashing unofficial cm14 zips is not supported with these TWRP images!
If any of the items above bug you as well, these TWRP builds may be for you. At the moment they are optional (not required - you may use other TWRP recoveries just as well) if you are a user of LineageOS 15.1 for YTX703F/YTX703L. However, in the future we will be making steps to replace the official TWRP recoveries with these ones over here.
Known issues
None so far.
Downloads
TWRP 3.2.3: [YTX703F (Wifi)] | [YTX703L (LTE)]
Installation instructions
If your device is new to the custom ROM flashing process, you need to unlock its bootloader:
If you are not fully decided and just want to try out these TWRP images, you can just hot-boot them into RAM, without writing them permanently to flash storage:
If you don't like it, it's not persistent (rebooting again will get you the old recovery back)
If you're sold on the new recovery image, here's how to permanently flash it:
Click to expand...
Click to collapse
Can I also install this new recovery image using the twrp app instead adb?
Or can i try the new Image to execute the Codes directly in the tablet with the terminal emulator App instead connecting to the PC?
tombraga said:
Can I also install this new recovery image using the twrp app instead adb?
Click to expand...
Click to collapse
I've never used that, as I consider it bloatware. If it allows you to flash a local disk image (and not only ones downloaded from twrp.me) into the recovery partition, then I suppose you can. But then again, that'd require giving it root permissions, and I don't think I'd trust it that much just because I'm lazy.
vladimiroltean said:
I've never used that, as I consider it bloatware. If it allows you to flash a local disk image (and not only ones downloaded from twrp.me) into the recovery partition, then I suppose you can. But then again, that'd require giving it root permissions, and I don't think I'd trust it that much just because I'm lazy.
Click to expand...
Click to collapse
Thanks for Information, one more question:
Can i try the new Image to execute the Codes directly in the tablet with the terminal emulator App instead connecting to the PC?
I got some problem right now with my pc and cannot use it with my tablet
tombraga said:
Thanks for Information, one more question:
Can i try the new Image to execute the Codes directly in the tablet with the terminal emulator App instead connecting to the PC?
I got some problem right now with my pc and cannot use it with my tablet
Click to expand...
Click to collapse
You can try to do this:
Code:
su
dd if=/sdcard/Download/twrp-3.2.3-UNOFFICIAL-YTX703L.img of=/dev/block/bootdevice/by-name/recovery
sync
But keep in mind that interactive "su" sessions are kinda broken (tab completion, Ctrl-c and other stuff), this patch fixes that but its's not merged yet. So your mileage might vary. If you just cut and paste the commands (make sure they match your device though!) it should work.
vladimiroltean said:
You can try to do this:
But keep in mind that interactive "su" sessions are kinda broken (tab completion, Ctrl-c and other stuff), this patch fixes that but its's not merged yet. So your mileage might vary. If you just cut and paste the commands (make sure they match your device though!) it should work.
Click to expand...
Click to collapse
Thanks, but this is too hot for, better I wait and fix my pc first, thanks
At least perhaps a stupid question: can i flash your new twrp img directly from my actual official 3.2.0-0 twrp choosing install image and then your img.file?
tombraga said:
Thanks, but this is too hot for, better I wait and fix my pc first, thanks
At least perhaps a stupid question: can i flash your new twrp img directly from my actual official 3.2.0-0 twrp choosing install image and then your img.file?
Click to expand...
Click to collapse
There are countless ways you can do it, but like you said, it's not a good idea to reflash your recovery if you're don't have a plan B if anything goes wrong.
vladimiroltean said:
There are countless ways you can do it, but like you said, it's not a good idea to reflash your recovery if you're don't have a plan B if anything goes wrong.
Click to expand...
Click to collapse
i could fix my laptop now i made it with adb as you teached and explained, worked wityout any problems
I like very much the new TWRP, waiting so long for this landscape mode and without questions to install TWRP app.
Now i uninstall the TWRP app and have a very nice TWRP recovery which is fine for my Lenovo tablet, thank you so much.
Problem: no i cannot uninstall more the TWRP app, even tried with titanium pro, but could not find the system app was the message...
should i freez the twrp app now with titanium pro?
When your twrp will go official???? I hope soon.
---------- Post added at 05:21 PM ---------- Previous post was at 05:06 PM ----------
tombraga said:
i could fix my laptop now i made it with adb as you teached and explained, worked wityout any problems
I like very much the new TWRP, waiting so long for this landscape mode and without questions to install TWRP app.
Now i uninstall the TWRP app and have a very nice TWRP recovery which is fine for my Lenovo tablet, thank you so much.
Problem: no i cannot uninstall more the TWRP app, even tried with titanium pro, but could not find the system app was the message...
should i freez the twrp app now with titanium pro?
When your twrp will go official???? I hope soon.
Click to expand...
Click to collapse
made even a first backup right now with the new TWRP, without any problem and very fast. great!
tombraga said:
Problem: no i cannot uninstall more the TWRP app, even tried with titanium pro, but could not find the system app was the message...
should i freez the twrp app now with titanium pro?
Click to expand...
Click to collapse
If it really bothers you, I would wipe the system partition and install everything else all over again (LineageOS, the exact same Gapps package, etc).
tombraga said:
When your twrp will go official???? I hope soon.
Click to expand...
Click to collapse
Probably not very soon, hence the reason why I decided to release it unofficially for a while. I contacted the TWRP project maintainers and they said they're caught at the moment with other stuff (merging with Android P codebase) and they can't review my display rotation patch until that activity is finished. So we're probably talking about the timeframe when the first official TWRP and LineageOS builds based on Android P are going to get released.
vladimiroltean said:
If it really bothers you, I would wipe the system partition and install everything else all over again (LineageOS, the exact same Gapps package, etc).
Probably not very soon, hence the reason why I decided to release it unofficially for a while. I contacted the TWRP project maintainers and they said they're caught at the moment with other stuff (merging with Android P codebase) and they can't review my display rotation patch until that activity is finished. So we're probably talking about the timeframe when the first official TWRP and LineageOS builds based on Android P are going to get released.
Click to expand...
Click to collapse
It's ok, I can live with it.
I see two things in new version
1) graphical bug inside list of files (overlapping)
2) cannot access NTFS formatted sd-card (while older version working fine)
janforman said:
I see two things in new version
1) graphical bug inside list of files (overlapping)
2) cannot access NTFS formatted sd-card (while older version working fine)
Click to expand...
Click to collapse
1. Screenshot? (I think it's vol-up + power)
2. That might be my oversight on my part. NTFS is indeed not enabled in the kernel because Android uses the ntfs-3g FUSE implementation. I think that's not available in TWRP though.
vladimiroltean said:
1. Screenshot? (I think it's vol-up + power)
2. That might be my oversight on my part. NTFS is indeed not enabled in the kernel because Android uses the ntfs-3g FUSE implementation. I think that's not available in TWRP though.
Click to expand...
Click to collapse
I flashed older TWRP version and NTFS is working well. I'm using it for flashing and backup. In new version sdcard is not mounted and in "mount" option greyed out (i cannot select it).
I had an issue flashing a custom boot animation zip and font zip, they appeared to flash fine in recovery but the boot animation and font was not changed. I flashed the latest official TWRP and these zips flashed and took effect fine. No issues with ROM zip, gapps or magisk though
scoobyjenkins said:
I had an issue flashing a custom boot animation zip and font zip, they appeared to flash fine in recovery but the boot animation and font was not changed. I flashed the latest official TWRP and these zips flashed and took effect fine. No issues with ROM zip, gapps or magisk though
Click to expand...
Click to collapse
Can you give a link to the boot animation and font you flashed.
I know you are the graphics expert around here so will be nice if you can point us to some compatible boot animations for our device.
I really don't want to sound unappreciative but the Lineage 'stock' boot animation seriously needs a facelift
Finefeather said:
Can you give a link to the boot animation and font you flashed.
I know you are the graphics expert around here so will be nice if you can point us to some compatible boot animations for our device.
I really don't want to sound unappreciative but the Lineage 'stock' boot animation seriously needs a facelift
Click to expand...
Click to collapse
The animation is nothing to do with Lineage, but if you like Raphael of TMNT, feel free to try this: https://drive.google.com/open?id=0B260dxr9nvchTG0xR2pYelhuNHc
I have noticed that with an animation that fills more of the screen than the lineage logo, there seems to be a black overlay taking up about a 3rd of the screen at the right, which obscures my animation a little but only for a couple of seconds.
As I say, I can flash this with official TWRP but it doesn't seem to take with this one
This version of TWRP is unfortunately not compatible with GApps+Aroma. (The standard version works fine.)
Rueddi_ger said:
@vladimiroltean
How do I compile this TWRP? I found the twrp.mk in our devicetree/recovery directory. I pasted all flags to the end of BoardConfigCommon and the BoarConfig of the F/L version. It compiles well, but doesn't recognize those flags, I think. When I boot the img The touchscreen is completely inverted and is weird. Apart from that it isn't in landscape mode, but in portrait ( even thought the flags include TW_THEME := landscape_hdpi) Can you give me an idea where the problem is?
You can find my device tree here: Github
Click to expand...
Click to collapse
Added instructions in the top post.
Rueddi_ger said:
Actually I forgot to mention that I do not want to build TWRP exactly, but OrangeFox (which is based on TWRP). The problem is I cannot use the lineageOS tree, I think, because OrangeFox requires to be initialized with the minimal Omni manifest (see here: https://gitlab.com/OrangeFox/Manifest ). Do you have an idea what I can do?
Click to expand...
Click to collapse
What have you tried to do and what were the errors you were faced with?
Rueddi_ger said:
Apart from that it didn't seem to recognize any TWRP flags as the theme is not landscape, although I put those flags like everywhere
Click to expand...
Click to collapse
Hate to break it to you, but rotating the recovery framebuffer is an operation that is quite a bit more involved than setting "TW_THEME := landscape" (assuming that's what you were trying to say).
Did you even bother to look at the patches linked in the top post? What about this one:
Code:
From 2a8821faf98f8c26a88e9bbe8a8a6d31015b938b Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <[email protected]>
Date: Tue, 3 Jul 2018 00:04:03 +0300
Subject: [PATCH] TW_HWROTATION: add flag to handle hardware-rotated display
panels
* The existence of TW_HWROTATION that implements this feature at the
level of calls to libpixelflinger API closely mirrors the existence of
ro.sf.hwrotation for surfaceflinger in LineageOS.
* A brute-force approach was previously attempted via the
BOARD_HAS_FLIPPED_SCREEN makefile flag. That code iterated over the
active display surface in a double-buffered setup, and performed a
"smart" memcpy from the UI drawing surface (gr_draw) onto the display
surface. The problem was that, without heavy loop optimizations, that
code could have never scaled for 90 and 270 degree rotation.
I tried and you could literally see the for loop with the naked eye
while the display surface was updating.
* That code is now gone, but support for BOARD_HAS_FLIPPED_SCREEN := true
is still there (now means TW_HWROTATION := 180).
* This patch relies on the assumption that it is impossibly difficult
and non-portable to rotate whole framebuffer display surfaces, in a
way that is not dependent upon the graphics backend (adf, fbdev, drm,
overlay etc). Therefore, it identifies the rendering primitives that
the TWRP graphics stack exposes to the GUI application above, and
implements hwrotation inside each of those calls instead:
- gr_line(), gr_fill() - 2D geometric shapes (lines, rectangles)
- gr_blit() - graphical image resources
- gr_ttf_textExWH() - font rendering
- gr_fb_width(), gr_fb_height() - framebuffer resolution
* The gist is to keep the backend and framebuffer (dimensions, row size
etc) unchanged (because making changes there is asking for trouble),
but present an altogether different reality to the calling API,
according to the compile-time constant TW_HWROTATION.
* All (x, y) API coordinates and shapes are transformed before being
actually rendered as (x_disp, y_disp) display coordinates.
* With TW_HWROTATION := 90 or 270 you can turn a landscape device into
a portrait one, because the GUI is fooled by the reversed dimensions
reported by gr_fb_width() and gr_fb_height() and renders the UI as
for a different device.
* For blit and text rendering operations, figuring out the transformed
coordinates in display space is not enough, as the surfaces that are
to be rendered have to be rotated themselves. This is handled by
allocating an intermediary rotated surface on each rendering
operation (not ideal), so the code with the intermediary surface
is compiled out for the TW_HWROTATION := 0 case.
* This is still not as bad as rotating the whole framebuffer though, and
on a msm8976 device the performance hit is not even noticeable (for
software rendering).
* Currently there is no attempt to make a connection between the
TW_HWROTATION and the { RECOVERY_TOUCHSCREEN_SWAP_XY,
RECOVERY_TOUCHSCREEN_FLIP_X, RECOVERY_TOUCHSCREEN_FLIP_Y } settings.
Change-Id: Ic8966ad5360c8a499649fdb16e242286640fd992
Signed-off-by: Vladimir Oltean <[email protected]>

Magisk Impact on Date/Time in TWRP on LG V40?

I am hoping that someone can help me. I have had an LG V40 with Android 9, Magisk, TWRP, and some Xposed Mods. At first all seemed fine in all respects. Then I noticed that the date/time in TWRP was not correct at all (2018 instead of 2020, etc). But I am 100% sure that at some point in the recent past it was correct (or at least close enough for me not to notice). So I am looking for the cause of this and how to fix it.
I noticed here that TWRP has some special code (cannot claim to fully understand it) that processes date/time differently on Qualcomm 800 series chips - which my phone has. In looking around at the code, I see that it is looking at ats* files so I have gone looking for them on my device. I find them in several places (nothing is ever easy):
/mnt/vendor/persist/time
/sbin/.magisk/mirror/data/vendor/time
/sbin/.magisk/mirror/persist/time
/data/vendor/time
In /mnt/vendor/persist/time I see:
ats_12 with modify at 2/9/2018 @ 10:39am
ats_13 with same
ats_15 with same
ats_16 with same
In /sbin/.magisk/mirror/persist/time I see the same as above.
in/sbin/.magisk/mirror/data/vendor/time I see:
ats_1 with modify at 5/1/2020 @ 6:09pm
ats_2 with same
ats_12 with modify at 5/13/2020 @ 11:49am
ats_13 with same
ats_15 with modify at 5/13/2020 @ 10:49am
ats_16 with same
And in /data/vendor/time I see the same as above.
What I am not understanding here is if these multiple sets are the result of Magisk and, if so, which are/were "original" and which are "mirrors" and in general what is Magisk doing with all this? I read here, under the heading MagicMount, that Magisk is doing things with /system and possibly with /vendor and /product. So I cannot really explain to myself what I am seeing here or why it is happening.
I apologize for the length of this and for veering off into TWRP a bit. But it is the only way I can describe my situation and conundrum.
I also have no idea how TWRP interacts with Magisk - if at all and how that might play into the date/time problems I am facing.
So thanks for your patience and help.
The files in the mirror directories are used by Magisk for Modules (magic mounting) and MagiskHide.
I'm guessing you found those files while booted up and not in TWRP. Thing is that those Magisk mirror directories won't be there when you boot into TWRP (they're mounted by Magisk during a normal boot) and thus they can't have any effect on what you are describing.
Magisk does not load at all when you boot to TWRP.
Didgeridoohan said:
The files in the mirror directories are used by Magisk for Modules (magic mounting) and MagiskHide.
I'm guessing you found those files while booted up and not in TWRP. Thing is that those Magisk mirror directories won't be there when you boot into TWRP (they're mounted by Magisk during a normal boot) and thus they can't have any effect on what you are describing.
Magisk does not load at all when you boot to TWRP.
Click to expand...
Click to collapse
Thanks for the help. You are correct, I was looking while booted into the system.
Do you happen to know if, while Magisk is doing the mirroring and merging, it fiddles any folder/file permissions/ownerships? Or should these remain identical to the "originals"? Cheers!

[GUIDE] Re-locking the bootloader on the OnePlus 6t with a self-signed build of LOS

What is this tutorial?
This tutorial will:
Creating an unofficial build of LineageOS 17.1 suitable for using to re-lock the bootloader on a OnePlus 6/6t
Take you through the process of re-locking your bootloader after installing the above
This tutorial will NOT:
Remove *all* warning messages during boot (the yellow "Custom OS" message will be present though the orange "Unlocked bootloader" message will not)
Allow you to use official builds of LineageOS 17.1 on your device with a re-locked bootloader (more details near the end of the tutorial)
This tutorial will assume you are working on an Ubuntu 18.04 installation, if you are using Windows or another Linux distro, the commands may be different.
Supported devices:
Current both the OnePlus 6 (enchilada) and 6t (fajita) have been tested, but newer phones should work as well.
For simplicities sake, all further references will only be to the 6t (fajita).
Pre-requisites:
a mid level knowledge of terminal commands and features
a supported phone
a PC with enough CPU/RAM to build LineageOS 17.1 (recommended 8 cores, 24g of RAM)
a working USB cable
fastboot/adb installed and functional
LineageOS 17.1 source code downloaded
at least one successful build of LineageOS
at least one successful signing of your build with your own keys
Misc. notes:
the basics of building/signing of LineageOS is outside the scope of this tutorial, refer to the LineageOS Wiki for details on how to complete these tasks
you'll be modifying some code in LineageOS, so if you are not comfortable using basic editing utilities as well as patch, do not proceed any further
the path to your LineageOS source code is going to be assumed to be ~/android/lineageos, if it is somewhere else, substitute the correct path in the tutorial
the path to your private certificate files is going to be assumed to be ~/android-certs, if it is somewhere else, substitute the correct path in the tutorial
*** WARNING ****
This process may brick your device. Do not proceed unless you are comfortable taking this risk.
*** WARNING ****
This process will delete all data on your phone! Do not proceed unless you have backed up your data!
*** WARNING ****
Make sure you have read through this entire process at least once before attempting, if you are uncomfortable with any steps include in this guide, do not continue.
And now on with the show!
Step 1: Basic setup
You need a few places to store things, so create some working directories:
Code:
mkdir ~/android/fajita
mkdir ~/android/fajita/oos
mkdir ~/android/fajita/images
mkdir ~/android/fajita/images_raw
mkdir ~/android/fajita/patches
mkdir ~/android/fajita/pkmd
You also need to add "~/android/lineageos/out/host/linux-x86/bin" to your shell's profile path. Make sure to close and restart your session afterwards otherwise the signing will fail later on with a "file not found" error message .
Step 2: Download the latest OxygenOS from OnePlus
Go to https://www.oneplus.com/support/softwareupgrade and download the latest OOS update, store it in ~/android/fajita/oos
Step 3: Extract the vendor.img from OOS
Run the following commands to extract the vendor.img from OOS:
Code:
cd ~/android/fajita/oos
unzip [oos file name you downloaded] payload.bin
cd ../images_raw
python ~/android/lineageos/lineage/scripts/update-payload-extractor/extract.py --partitions vendor --output_dir . ../oos/payload.bin
You should now have a ~1g file named vendor.img in the images_raw directory.
Step 4: Update fajita's BoardConfig.mk
You will need to add a few parameters to the end of ~/android/lineageos/device/oneplus/fajita/BoardConfig.mk, they are:
Code:
BOARD_PREBUILT_VENDORIMAGE := /home/<userid>/android/fajita/images_raw/vendor.img
AB_OTA_PARTITIONS += vendor
BOARD_AVB_ALGORITHM := SHA256_RSA2048
BOARD_AVB_KEY_PATH := /home/<userid>/.android-certs/releasekey.key
Note you cannot use "~"" in the path names above to signify your home directory, so give the full absolute path to make sure the files are found.
Step 5: Update sdm845-common's BoardConfigCommon.mk (optional)
LineageOS by default disables Android Verified Boot's partition verification, but you can enable it now as all the required parts will be in place. However, you may not want to if you intend to make other changes to the system/boot/vendor partitions (like Magisk, etc.) after you have re-locked the bootloader.
To enable partition verification do the following:
Code:
cd ~/android/lineageos/devices/sdm845-common
sed -i 's/^BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flag 2/#BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flag 2/' BoardConfigCommon.mk
Step 6: Patch the AOSP/LineageOS releasetools
Two releasetools included with LineageOS need to be patched as they otherwise will not properly process a pre-built vendor.img.
The required patches can be found here:
https://raw.githubusercontent.com/W.../source/add_img_to_target_files.py-17.1.patch
https://raw.githubusercontent.com/W...r/source/sign_target_files_apks.py-17.1.patch
Download both and store in ~/android/fajita/patches.
Now apply them with the following commands:
Code:
cd ~/android/lineageos/build/tools/releasetools
patch add_image_to_target_files.py ~/android/fajita/patches/add_image_to_target_files.py-17.1.patch
patch sign_target_files_apks.py ~/android/fajita/patches/sign_target_files_apks.py-17.1.patch
Step 7: Build LineageOS
You are now ready to build:
Code:
cd ~/android/lineageos
source build/envsetup.sh
croot
breakfast fajita
mka target-files-package otatools
Step 8: Prepare vendor.img
As part of the build process above, your raw vendor.img will been copied to the $OUT directory and a new hashtree (what AVB uses to verify the image) will have been added to it.
You need to use this new version in the signing process but due to how the build system works, this is not done by default.
So, let's put it where it is needed:
Code:
cp $OUT/obj/PACKAGING/target_files_intermediates/lineage_fajita-target_files-eng.*/IMAGES/vendor.img ~/android/fajita/images
Step 9: Sign the APKs
You are now ready to sign the apks with sign_target_files_apks:
Code:
./build/tools/releasetools/sign_target_files_apks -o -d ~/.android-certs --prebuilts_path ~/android/fajita/images $OUT/obj/PACKAGING/target_files_intermediates/*-target_files-*.zip signed-target_files.zip
Note the new "--prebuilts_path" option, which points to where your new vendor.img file is located.
Step 10: Build the OTA
Now it is time to complete the OTA package:
Code:
./build/tools/releasetools/ota_from_target_files -k ~/.android-certs/releasekey --block signed-target_files.zip lineage-17.1-[date]-UNOFFICIAL-fajita-signed.zip
Note, replace [date] with today's date in YYYYMMDD format.
Step 11: Create pkmd.bin for your phone
Before you can lock your phone, you have to tell it what your public key is so it knows it can trust your build.
To do this you need to create a pkmd.bin file:
Code:
~/android/lineageos/external/avb/avbtool extract_public_key --key ~/.android-certs/releasekey.key --output ~/android/fajita/pkmd/pkmd.bin
Step 12: Flashing your LineageOS build
It's time to flash your build to your phone. The following steps assume you have already unlocked your phone and have flashed an official version of LineageOS to it. You don't need to have flashed LineageOS yet, you could use TWRP through "fastboot boot" if you prefer.
Reboot your phone in to recovery mode
In LineageOS Recovery select "Apply update"
From your PC, run:
Code:
adb sideload ~/android/lineageos/lineage-17.1-[date]-UNOFFICIAL-fajita-signed.zip
When the sideload is complete, reboot in to LineageOS. Make sure everything looks good with your build.
You may also need to format your data partition at this time depending on what you had installed on your phone previously.
Step 13: Flashing your signing key
Now it's time to add your signing key to the Android Verified Boot process. To do so, do the following:
Reboot your phone in to fastboot mode
From your PC, run:
Code:
fastboot flash avb_custom_key ~/android/fajita/pkmd/pkmd.bin
fastboot reboot bootloader
fastboot oem lock
On your phone, confirm you want to re-lock and it will reboot
Your phone will then factory reset and then reboot in to LineageOS.
Which of course means you have to go through the first time setup wizard, so do so now.
Step 14: Disable OEM unlock
Congratulations! Your boot loader is now locked, but you can still unlock it again using fastboot, so it's time to disable that as well.
Unlock you phone and go to Settings->About phone
Scroll to the bottom and find "Build number"
Tap on it you enable the developer options
Go to Settings->System->Advanced->Developer options
Disable the "OEM unlocking" slider
Reboot
Step 15: Profit!
Other things
The above will build a standard USERDEBUG version of LineageOS, however this will still allow LineageOS Recovery to sideload non-signed files. If you have implemented step 5 above, then this protects your system/vendor/boot/dtbo partitions, but none of the others. Likewise USERDEBUG builds will allow for rolling back to a previous version. To increase security and disallow both of these scenarios you may want to build a USER version of LineageOS to install. However this brings in other issues, such as flashing newer firmware from OnePlus so make sure you understand the implications of both choices. For more details on build types, see https://source.android.com/setup/develop/new-device#build-variants.
In the above example the releasekey from your LineageOS install has been used to sign AVB, but AVB supports other key strengths up to SHA512_RSA8192. You could create a key just for signing AVB that used different options than the default keys generated to sign LineageOS.
If you want to remove you signing key from your phone, you can do it by running "fastboot erase avb_custom_key".
The changes you made to the make files and releasetools may conflict with future updates that you pull from LineageOS through repo sync, if you have to reset the files to get repo sync to complete successfully, you'll have to reapply the changes afterwards.
So why can't I do this with official LineageOS builds?
For Android Verified Boot (AVB) to work, it must have the hash values for each of the system/vendor/boot/dtbo partitions stored in vbmeta. Official LineageOS builds do not include the vendor.img in them (for fajita at least, other phones may), instead simply using the existing partition on the phone.
That means that there is no vendor.img information in vbmeta for the official builds, which means AVB will fail to verify it during boot and give the red corruption message and halt the boot process after you have re-locked the bootloader.
And since you cannot add to vbmeta without the LineageOS private key, which only the LineageOS signing server has, you cannot add it.
This means you must do a full build with new signing keys to make it work.
Theoretically you could pick apart a LineageOS release, rehash the system/vendor/boot/dtbo and then recreate vbmeta and the payload.bin file, but that brings a host of other issues. For example, since such a "build" would look like a full LinageOS release, if you ever accidentally let the updater run it would brick (soft) that slot and you'd have swap back to your other slot to boot again. In an extreme case, if you managed to corrupt the second slot somehow you'd have to wipe your entire and recover from the brick with one of the available tools to do so.
Ok, what messages do I see during the boot process then?
During a boot you will of course see the standard OnePlus power up screen, followed by the yellow "custom os" message an then the stardard LineageOS boot animation.
For more details on AVB boot messages, see https://source.android.com/security/verifiedboot/boot-flow
So what do those two patches to the release tools do?
AOSP/LineageOS's add_image_to_target_files.py detects if a vendor.img file already exists, and if so, simply includes it in the build process. The patch adds one extra step, so that AVB is being enabled for the build, it will replace the existing hashtree on vendor.img using the same salt and other options as will be used on system/boot/dtbo. This ensure that when vbmeta is generated, it has the right information from vendor.img.
The script is called from the make system as part of the "mka target-files-package otatools" and the appropriate parameters from the make system, like "BOARD_PREBUILT_VENDORIMAGE", are used to create arguments to the script to build the standard image files as well as include the prebuilt vendor.img.
This script is used both during the initial build as well as the signing process, but this change is only targeted at the build time implementation. During signing, the script uses whatever hashtrees are in place and does not regenerate them.
AOSP/LineageOS's sign_target_files_apks.py is responsible for signing the APKs that have been built as part of "mka target-files-package otatools", unfortunately it is not part of the "make" system, so settings like "BOARD_PREBUILT_VENDORIMAGE" do not impact the script. This means that sign_target_files_apks.py does not have any knowledge that it should be including a pre-built vendor.img, even though it is in the $OUT directory waiting to be used.
The patch adds a new parameter to the script (--prebuilts_path), so that during the signing process, any image files found in the provided path, will be included in the process. So make sure that only vendor.img is in the provided directory. This is a directory instead of a single file as future uses may be to include things like firmware, other partition types, etc. in to the signing process.
Thank you's
Obviously to all of the members of the LineageOS team!
LuK1337 for supporting fajita
optimumpro for the OnePlus 5/5t re-locking guide (https://forum.xda-developers.com/oneplus-5/how-to/guide-relock-bootloader-custom-rom-t3849299) which inspired this one
Quark.23 for helping with the process and testing on enchilada
Nice , Will this enable widewine L1?
jsidney96 said:
Nice , Will this enable widewine L1?
Click to expand...
Click to collapse
I don't believe there is a connection between the two.
WhitbyGreg said:
I don't believe there is a connection between the two.
Click to expand...
Click to collapse
If you unlock bootloader on phones supporting L1 they drop to L3. I know some Oneplus phones (op6 etc.) did not support L1 even on stock.
cowgaR said:
If you unlock bootloader on phones supporting L1 they drop to L3. I know some Oneplus phones (op6 etc.) did not support L1 even on stock.
Click to expand...
Click to collapse
Yeah.. It brings it to L1
Great writeup @WhitbyGreg
As Android security gets tighter and tighter, hoping one day all ROMs would support AVB by default..
---------- Post added at 06:16 PM ---------- Previous post was at 05:48 PM ----------
Curious question here,
WhitbyGreg said:
*** will build a standard USERDEBUG version of LineageOS, however this will still allow LineageOS Recovery to sideload non-signed files. If you have implemented step 5 above, then this protects your system/vendor/boot/dtbo partitions, but none of the others. Likewise USERDEBUG builds will allow for rolling back to a previous version. To increase security and disallow both of these scenarios you may want to build a USER version of LineageOS to install. However this brings in other issues, such as flashing newer firmware from OnePlus so make sure you understand the implications of both choices***
Click to expand...
Click to collapse
After a launch of any phone, how drastic are such firmware updates to bother about? In other words, Unless we're in stock ROM is it mandatory to update phone firmware?
arvindgr said:
Yeah.. It brings it to L1
Click to expand...
Click to collapse
Good to know.
arvindgr said:
Great writeup @WhitbyGreg
As Android security gets tighter and tighter, hoping one day all ROMs would support AVB by default..
Click to expand...
Click to collapse
That would be nice but more importantly, more phones need to support re-locking.
arvindgr said:
Curious question here,
After a launch of any phone, how drastic are such firmware updates to bother about? In other words, Unless we're in stock ROM is it mandatory to update phone firmware?
Click to expand...
Click to collapse
Reasonably important, after all, if you never get firmware updates you'll have outdated security patching for the firmware. Some official LOS builds require newer versions of the firmware as they are released and won't install without it.
This guide was very helpful to me when re-locking my Oneplus 7T and enabling hash/hashtree verification. A dude on telegram had actually sent me the link and I only briefly skimmed over. Ironically when looking for patches to fix my issues after attempting to include pre-built vendor/odm and failing I cross referenced and ended up back here.
Here's where I originally found them:
https://review.lineageos.org/c/LineageOS/android_build/+/278015
https://review.aosip.dev/c/AOSIP/platform_build/+/13385
I myself have made some more patches to ensure every possible pre-built image gets signed on my builds. After some experimentation I have found it possible to have Magisk with hash verification enabled
https://github.com/Geofferey/omni_android_build/commits/geofferey/android-10
There is also a fix to ensure appropriate args get passed when regenerating hashtree for pre-built vendor.
Geofferey said:
This guide was very helpful to me when re-locking my Oneplus 7T and enabling hash/hashtree verification.
Click to expand...
Click to collapse
So you can confirm you have relocked the bootloader on the 7T with AVB enabled?
Geofferey said:
A dude on telegram had actually sent me the link and I only briefly skimmed over. Ironically when looking for patches to fix my issues after attempting to include pre-built vendor/odm and failing I cross referenced and ended up back here.
Here's where I originally found them:
https://review.lineageos.org/c/LineageOS/android_build/+/278015
https://review.aosip.dev/c/AOSIP/platform_build/+/13385
Click to expand...
Click to collapse
Yes, those are my patches that I've submitted to LOS, I also have two other patches submitted to allow for other prebuilt images (aka firmware images) to be included in the build process.
Geofferey said:
I myself have made some more patches to ensure every possible pre-built image gets signed on my builds. After some experimentation I have found it possible to have Magisk with hash verification enabled
https://github.com/Geofferey/omni_android_build/commits/geofferey/android-10
There is also a fix to ensure appropriate args get passed when regenerating hashtree for pre-built vendor.
Click to expand...
Click to collapse
I'll take a look and see if I need to update any of my submissions, thanks.
I will have to update those commits with you as author. I messed that up and set person who picked yours as author. I am sorry. BTW thank you for those patches they were a lifesaver and inspired me.
Yes, I can confirm re-lock with AVB enabled on 7T works and also with hash verification. If I flash an image not signed by the build process with hash verification enabled I go red. Currently I am working on getting magisk directly integrated with build instead of using prebuilt patched imgs that cause builds to not pass CTS.
Geofferey said:
Currently I am working on getting magisk directly integrated with build instead of using prebuilt patched imgs that cause builds to not pass CTS.
Click to expand...
Click to collapse
Why do you want to put Magisk if you went to all the trouble of having avb with a locked bootloader? Isn't rooting defeating the purpose of avb?
quark23 said:
Why do you want to put Magisk if you went to all the trouble of having avb with a locked bootloader? Isn't rooting defeating the purpose of avb?
Click to expand...
Click to collapse
No, it does not defeat the purpose... Hashtree verification will still happen since root can be included in the build as opposed to flashing after the fact. In a way it's actually even more advised. The way I think, having root may lead to a means of being exploited but true AVB closes the door to any persistent rootkits that may try to modify partitions at block level. If ANYTHING modifies the verified partitions phone will refuse to boot and I will be protected. Doing exactly what AVB is supposed to do, verify the phone is in it's intended state. I also think of phone as a computer, you have root access on Linux, Windows and even Mac for Christ sake, why shouldn't it be the same for phones? The ONLY reason we don't by default is so manufacturers and carriers can stay in control. I've been rooting and modifying phones for years without AVB and yet to have a known breech of my data besides the Google apps constantly collecting on me. This just adds another level of security that I used to sacrifice in order to have root access.
Here is my PoC to include Magisk in builds so dm-verity can be kept enabled. Just two commits. If someone could make this better that would be really cool.
https://github.com/Geofferey/omni_android_build/commit/d60958780e6b26d7cb0cec5939b82df3df74a68f
https://github.com/Geofferey/android_vendor_magisk
I have rooted for testing and you don't gen any warning. The way avb works on my phone is it discards any modification after reboot. With no warning at boot time. If you get hacked, you can have persistent hacks with root. Make a modification from twrp with avb enabled and see for yourself.
You break the Android security model by rooting the phone. If you need certain things you can include them at build time, such as a custom hosts file.
Also, what can you do with root that does not alter the hashtree?
The power you mention is of no real use yet you expose yourself by having it. Sure, you can go by without any issues. The problem is if you happen to get hacked, the attacker has full control over your phone. You won't br able to get rid of it by rebooting.
Also I see no way for google to collect data in this setup, with or without root. Afwall has an equivalent in android 10 (that mobile data & wifi setting) and inter process comms are the real issue if you are worried about rogue apps. Afwall leaks dns requests like crazy anyway.
I say you are better off letting root go and include what you need at build time. I see that as better spent effort than trying to add root.
quark23 said:
I have rooted for testing and you don't gen any warning. The way avb works on my phone is it discards any modification after reboot. With no warning at boot time. If you get hacked, you can have persistent hacks with root. Make a modification from twrp with avb enabled and see for yourself.
Click to expand...
Click to collapse
So you built your ROM from source with root included, had TWRP go through signing and was able to modify system and other partitions without receiving a device corrupt message? I highly doubt AVB is even implemented appropriately if you were able to do so. If it is implemented it sounds like the old version, tho I remember if I violated FS too much it wouldn't be able to fix and failed to boot. Having a locked bootloader because AVB is enabled does not mean dm-verity is enabled. Also, it should be nearly impossible to just write things like files to /system or w.e. if you are on a device that ships with 10.
quark23 said:
You break the Android security model by rooting the phone. If you need certain things you can include them at build time, such as a custom hosts file.
Click to expand...
Click to collapse
I know it does, but I am not doing such small things as modifying a host file. The kinds of things I include in my personal ROMs require such a high level of access to the point where I can not write SE polices that will allow me to pass CTS and spit out user builds without serious modifications to the build env.
quark23 said:
Also, what can you do with root that does not alter the hashtree?
The power you mention is of no real use yet you expose yourself by having it. Sure, you can go by without any issues. The problem is if you happen to get hacked, the attacker has full control over your phone. You won't b able to get rid of it by rebooting.
Click to expand...
Click to collapse
The act of flashing Magisk is what breaks AVB, if you include it in the ROM at build time like I am doing then it doesn't need to be flashed. It makes modifications to the system by binding data from the wipeable data partition to /system/. If something utilizes that to install a backdoor or tunnel it goes bye-bye when I wipe. If something utilizes it to flash anything or modify system device no boot.
quark23 said:
Also I see no way for google to collect data in this setup, with or without root. Afwall has an equivalent in android 10 (that mobile data & wifi setting) and inter process comms are the real issue if you are worried about rogue apps. Afwall leaks dns requests like crazy anyway.
Click to expand...
Click to collapse
You're kidding right? Android solely exist as a mean for Google to collect data. That was the whole idea behind Android. Buy & develop an OS that any manufacturer can put on their device, let them certify for Google Play Services and collect the data that powers their ad platform. They certainly didn't opensource their baby for free. If you allow ports 80 and 443 out with inbound related allowed, that's all they need.
quark23 said:
I say you are better off letting root go and include what you need at build time. I see that as better spent effort than trying to add root.
Click to expand...
Click to collapse
I'd just rather the manufactures and Google would implement a root solution that plays nice with Androids security instead of making us resort to violating it. It's funny to me that we find it acceptable for these fools to maintain control of something you purchased with your hard earned dollars because they think we are too stupid to have it. Like I stated root and admin privileges are fully available to us on nearly any PC but phones for some reason are an exception.
_________________________________________________
I could rant and debate about this forever... Fact of matter is, you don't have to disable every Android security feature to have root.
I didn't build with magisk, I just flashed after building.
But you can try and modify anything on /system or /vendor from twrp, without magisk, without locking the bootloader, and see what happens. Avb discards the modification, but doesn't warn you. Curious of your findings regarding this. If you then flash magisk, you ofc break the hashtree and avb and the mods remain persistent.
I understand that you are building with magisk included in the hashtree. What I am wondering is what exactly are you wanting root for? What are you doing with root that does not break the hashtree?
Regarding the data collection, you lost me. What exactly is being collected on a LOS userbuild without google services? Got any dns logs or mitm wireshark packets to show? What service exactly is collecting what kind of data? Google's dns servers can be replaced before building, Greg has some scripts for that. Captive portal can also be replaced or turned off. Apart from that, and any apps you add yourself, what kind of data is being collected as I want to check it out myself. I've monitored my phone and it's pretty silent. Whatever goes out is from additional apps I use. But I don't see anything from LOS. Really curious about this.
Regarding your last point I think it's something akin to risking shooting yourself in the foot by having root by default. I understand (somewhat) the security model and I find it smart to not have it by default. Also Android uses selinux more than your standard linux distro does. There are some differences in the security models between android and pc linux distro.
I'm really hapoy that AOSP exists. Also pretty happy with the LOS project. My problem is with the outdated blobs. Maybe I'll get a Pixel at some point and give GrapheneOS a go. Seems like a really nice project.
Managed to get hardened malloc + Vanadium on LOS atm and I'm liking the browser. Overall I think AOSP is a great project. Not a fan of google's privacy policy but they do make great stuff.
quark23 said:
I understand that you are building with Magisk included in the hashtree. What I am wondering is what exactly are you wanting root for? What are you doing with root that does not break the hashtree?
Click to expand...
Click to collapse
Ah, there lies the real question. I am including in my personal builds a Debian Linux chroot that gets extracted to /data/ so I can run Linux services, etc. I have customized the chroot with Openvpn so that it connects to my server and essentially allows me back into device wherever it may lay. Basically I am adding in the stuff of nightmares that all this security is supposed to prevent. That is why I want dm-verity, because I know I am leaving my self partially open by doing so. I have a decent understanding of dm-verity and have confirmed that it does and will protect me against the scenarios I imagine. BTW it operates completely differently in locked state vs. unlocked.
quark23 said:
Regarding the data collection, you lost me. What exactly is being collected on a LOS userbuild without google services?
Click to expand...
Click to collapse
Well, if you're the type of person who doesn't require Google Play Services, nothing of course. I was merely stating that Google had open sourced Android in hopes that manufacturers would adopt the OS and qualify their devices for Google PS so that it could be used as a data collection platform. You won't easily see all the information Google collects in a Wireshark log because it is encrypted of course. LOS better be silent as hell without it or I'd contact that dev with a strongly worded message lmfao.
quark23 said:
Regarding your last point I think it's something akin to risking shooting yourself in the foot by having root by default. I understand (somewhat) the security model and I find it smart to not have it by default. Also Android uses selinux more than your standard linux distro does. There are some differences in the security models between android and pc linux distro.
Click to expand...
Click to collapse
Oh I DO NOT think it should just be enabled by default. If I had my way it would be enabled in dev ops requiring authentication and protected via a different password than the one you use to unlock the device once setup. You'd also require those "root" privileges to OEM unlock once enabled. While those features were enabled you'd be warned on boot as well but without locking you out of apps etc because that kind of sensitive data should be handled by TEE and TZ. In a real Linux operating system that hasn't been fundamentally raped to offer a false sense of security in the name of protecting carriers and manufactures you can modify SE linux policies etc, not while live but without compiling from source. A lot of us forget most these security features exist more to protect their interest and attempt to hide what's going on behind the scenes. I've actually heard of some pretty shady stories where manufacturers in China place ad-tappers that run in background on devices running GooglePS to be sold in US, so it definitely doesn't protect you if the person building your phone is shade.
quark23 said:
I'm really hapy that AOSP exists. Also pretty happy with the LOS project. My problem is with the outdated blobs. Maybe I'll get a Pixel at some point and give GrapheneOS a go. Seems like a really nice project.
Managed to get hardened malloc + Vanadium on LOS atm and I'm liking the browser. Overall I think AOSP is a great project. Not a fan of google's privacy policy but they do make great stuff.
Click to expand...
Click to collapse
Me too mate. . AOSP has taught me a lot about development and coding in general. Sadly outdated blobs are a usually a by-product of using pre-builts from manufacturers that don't update as often. Pixel would be way to go if that's a concern. I honestly just think a lot of the security is abused to suit their needs. I am just trying to turn it around to work for me where it can.
If you repo sync you should run the vendor files script as there's a couple of new files added. The Muppets github has been updated with them as well. If you don't your build will fail at first power on.
A quick question, forgive me if this is obvious: am I correct in assuming that one the above has been completed and the device is using a locally-built copy of Lineage OS, that I cannot take advantage of OTA updates? I just want to know what I'm getting in to before wiping my phone multiple times.
Thanks in advance, this thread is massively helpful.
nictabor said:
A quick question, forgive me if this is obvious: am I correct in assuming that one the above has been completed and the device is using a locally-built copy of Lineage OS, that I cannot take advantage of OTA updates? I just want to know what I'm getting in to before wiping my phone multiple times.
Thanks in advance, this thread is massively helpful.
Click to expand...
Click to collapse
Correct, though if you setup your own update server you can still use the inbuilt updater app if you want.
I just happened across this thread searching for a proper way to generate the custom avb key. I thought i had found it at one time on aosp documentation but i lost/forgot where it was.
Anyways, I have a quick q about this. Would I be correct in assuming that if i wanted gapps to be available in my build, I would need to include it during build time and not be able to flash it as per the typical methods?
I am pretty sure I won't be able to but wanted to ask here for you guys' experiences.
Also, @WhitbyGreg you should be able to i believe. just setup the url properly and host it somewhere with direct download links. (This also requires setup of json for the updater to monitor for updates)
klabit87 said:
Would I be correct in assuming that if i wanted gapps to be available in my build, I would need to include it during build time and not be able to flash it as per the typical methods?
Click to expand...
Click to collapse
Correct (at least as far as I know), once the bootloader is relocked any modification of the system partition (like adding the play services) would trigger an AVB failure.

General System root + Passed Safety Net Pixel 5a

Hey everyone,
after some trial and error, I was able to pass Safety Net.
I just want to mention what I did in the process to get there. May have been a combination of things or just one...
1. I followed this guide, but make sure you notice that It's for the Pixel 5 not 5a. But the process is similar. This process didn't fix the issue. However, it's also a good how-to on how to root. I did also modify the props to the 3a.
How to Root the Pixel 5 & Still Pass SafetyNet — Full Guide for Beginners & Intermediate Users
The Pixel 5 is a great value proposition in this era of $1,500 phones. With its reasonable price tag, fully open-sourced software, and unlockable bootloader, it's also an ideal phone for rooting.
android.gadgethacks.com
2. When that didn't work, I followed this video, and hid all my banking apps besides the Google Play Services:
3. When that didn't work, I installed these both using Magisk from this post:
Magisk General Support / Discussion
This is the place for general support and discussion regarding "Public Releases", which includes both stable and beta releases. All information, including troubleshoot guides and notes, are in the Announcement Thread
forum.xda-developers.com
4. Cleared my data and cache with Google Play and GPay + any other banking apps.
That worked for me!
EDIT: IF GOOGLE MAPS reports the wrong location, its likely XPrivacy-LUA, Google Services. Uncheck some of them.
Oh man....the only thing holding me back is the safety net thing, and it looks like we have a work around tell someone has an actual method made for this phone. Not sure if I'm ready to actually mess with this yet...but thanks for the post, bro!
anubis2k3 said:
Oh man....the only thing holding me back is the safety net thing, and it looks like we have a work around tell someone has an actual method made for this phone. Not sure if I'm ready to actually mess with this yet...but thanks for the post, bro!
Click to expand...
Click to collapse
Didnt think it was that big of a deal to me. But it was fun with a new phone with nothing on it.
This was the Magisk module that worked to pass safety net for me. I didn't need any others.
Releases · kdrag0n/safetynet-fix
Google SafetyNet attestation workarounds for Magisk - kdrag0n/safetynet-fix
github.com
Google Pay "appears" to be working too. Haven't gone out and tried it yet though.
joemommasfat said:
Google Pay "appears" to be working too. Haven't gone out and tried it yet though.
Click to expand...
Click to collapse
That's the part that I use the most, and the reason I haven't rooted yet. Please let us know if it works. Much appreciated!
I can confirm that using google pay (newer GPay app) on my rooted 5a works at merchants. I've already used it several times over the last week or so with no problems.
Deadmau-five said:
3. When that didn't work, I installed these both using Magisk from this post:
Click to expand...
Click to collapse
Why? Isn't the shim version just for Samsungs? Either way, it's the same mod, just different versions.
Someone who actually knows what they're doing needs to write up a tutorial. Following instructions posted by people who have no idea what they're doing but "it works" for them is dangerous.
borxnx said:
Why? Isn't the shim version just for Samsungs? Either way, it's the same mod, just different versions.
Someone who actually knows what they're doing needs to write up a tutorial. Following instructions posted by people who have no idea what they're doing but "it works" for them is dangerous.
Click to expand...
Click to collapse
You're absolutely correct about the dangers in following instructions posted by who knows who. I'll go further and say when it comes to root and associated items stay away from anything posted on a site other than XDA. In many cases even if the instructions were correct at some point in time they may well be outdated now.
I haven't rooted yet for a few reasons yet but will, hopefully sometime very soon. In the meantime I can state the following:
They're is no need to modify props. Modifying props to identify as a different phone would only be required for custom ROMs that don't handle it themselves (or some non-certified Chinese phones, which doesn't apply here). If you're running stock just leave that portion alone. And, if I'm not mistaken (although not 100% certain) I think safetynet-fix takes care of that for you in any case.
You will definitely need kdragOn/safetynet-fix.
Hopefully that's all you need.
I'm not sure which version of Magisk you'll need. Unless you know what you're doing and how to get out of trouble I recommend staying away from the current alphas, they're extremely cutting edge and you can expect problems.
Best best is to check the following threads and see what's going on:
Actually see this post and the 2 posts immediately following
Magisk General Support / Discussion
This is the place for general support and discussion regarding "Public Releases", which includes both stable and beta releases. All information, including troubleshoot guides and notes, are in the Announcement Thread
forum.xda-developers.com
That should pretty much cover things for the moment. If nobody else (@hfam ?) has done it by the time I get around to rooting I'll write something up specific for the 5a.
I only mentioned what works for me since there was no step-by-step guide.
Dangerous how? Doing any mods to your phone is "dangerous". I fail to see how this is more so than others. Modifying your phone is risky.
If it didn't work I wouldn't have posted this guide. I only mentioned the steps that I took. It's not really a guide, just how I passed safety net.
But, my 5a has still been working great since then. GPay included.
jcmm11 said:
You're absolutely correct about the dangers in following instructions posted by who knows who. I'll go further and say when it comes to root and associated items stay away from anything posted on a site other than XDA. In many cases even if the instructions were correct at some point in time they may well be outdated now.
I haven't rooted yet for a few reasons yet but will, hopefully sometime very soon. In the meantime I can state the following:
They're is no need to modify props. Modifying props to identify as a different phone would only be required for custom ROMs that don't handle it themselves (or some non-certified Chinese phones, which doesn't apply here). If you're running stock just leave that portion alone. And, if I'm not mistaken (although not 100% certain) I think safetynet-fix takes care of that for you in any case.
You will definitely need kdragOn/safetynet-fix.
Hopefully that's all you need.
I'm not sure which version of Magisk you'll need. Unless you know what you're doing and how to get out of trouble I recommend staying away from the current alphas, they're extremely cutting edge and you can expect problems.
Best best is to check the following threads and see what's going on:
Actually see this post and the 2 posts immediately following
Magisk General Support / Discussion
This is the place for general support and discussion regarding "Public Releases", which includes both stable and beta releases. All information, including troubleshoot guides and notes, are in the Announcement Thread
forum.xda-developers.com
That should pretty much cover things for the moment. If nobody else (@hfam ?) has done it by the time I get around to rooting I'll write something up specific for the 5a.
Click to expand...
Click to collapse
Just a quick note to say I just finished with everything (new Pixel 5a 5G, rooted + Safety net, restored all my apps, etc) and it's a flawless victory, ALL banking apps work great, SafetyNet passes, no hiccups.
I'd be happy to craft up a step by step and post it if there's some interest. It's not often I get to give back to this outstanding community, so it's the least I can do jumping on the opportunity. UFC 266 Main card is just starting, so I'll get started right after the fight and post it here in this thread.
Great to see ya again @jcmm11! Coming back to root a new phone feels like a family reunion, so great to see many of you active folks still here helping out!!
hfam
Alright, as promised, here is my writeup for a step-by-step tutorial for rooting your new Pixel 5a and getting SafetyNet up and going. I know it looks like a book, but I wanted to put it into plain language and attempt to explain the process for everyone, even absolute first timers. I know when I first started I really appreciated when the person helping didn't presume I had any knowledge, so for those that may have some experience, sorry for the wordiness. I'll also include how I apply updates when a new Android security update is pushed out. I understand that there are now elegant ways to accept OTA updates, but that is out of the scope of this tutorial as I have always had issues with OTA, and have to catch up on how that works myself. I can attest to years of using this method though (using a full factory image) to perform the "monthly" security updates, and I have never had anything but full success, so I'll share that here below the rooting tutorial.
*Disclaimer and heads-up* this is for an UNLOCKED PIxel 5a purchased directly from Google Store. At the time of this writing that is the only place I'm aware of which currently offers the PIxel 5a. Once carriers like Verizon, etc, offer this device, there may be some changes to the process, so just know up front this is for the unlocked Pixel 5a*
*WARNING*! When you unlock the bootloader on your phone it WILL WIPE YOUR PHONE and reset it to factory. If you've already used your phone and set it up, you're going to lose that setup. If you can't bear it, then the rest of this isn't for you, as root cannot be achieved without unlocking the bootloader.
First, you'll need a few things
- https://developers.google.com/android/images
and download the latest FACTORY IMAGE for "barbet", which is the Pixel 5a. You want to download the SAME VERSION that is currently installed on your device. At the time of this writing, it's the September release.
From that same page, you will need the ADB+Fastboot platform tools which will allow you to perform the required tasks, download from this link:
- https://developer.android.com/studio/releases/platform-tools.html
I use Windows 10, and extract this tools download to a folder in the root of C: called "platform-tools". You will then need to add "c:\platform-tools" to your environment path.
On the Pixel 5a, you need to enable developer options. Go into Settings/About Phone/and tap "Build Number" 7 times. This enables developer options and it will let you know when you've unlocked this as you tap 7 times. Once developer options is unlocked, go back to Settings/System/Advanced, and you'll see Developer Options is now available.
Select Developer Options, and enable "USB Debugging" and also enable "OEM Unlocking".
(**NOTE** For now at least, until you decide how you want to proceed with handling updates in future (more on that later), I strongly recommend turning OFF "Automatic System Updates" as well, just a few items below "OEM Unlocking". This prevents any updates happening automatically on a phone reboot. You don't want to wake up and find an OTA update pushed out and removed root, or worse. You can always turn it back on later.)
Plug your phone into a USB port on your PC. Allow the PC to do it's thing. You can open up Computer Management on the PC (right click the windows menu button icon lower left of your toolbar and select "Computer Management". Select "Device Manager" on the left panel. You should see "Android ADB Device" appear at the top of the right pane list of devices. if not, then visit:
Install OEM USB drivers | Android Studio | Android Developers
Discover links to the web sites for several original equipment manufacturers (OEMs), where you can download the appropriate USB driver for your device.
developer.android.com
and download the appropriate USB driver for your system and retry the above directions.
First thing we have to do is unlock the bootloader.
On the PC, open a command prompt and change directory to "C:\platform-tools" as discussed above.
Now, type in "adb reboot bootloader". The phone will reboot into bootloader. (you may receive a dialog on the phone which says something to the effect of not recognizing the PC. Go ahead and allow it, check the box to allow it in the future, and proceed.
Phone is now at the bootloader, and shows you some info letting you know it's so, including that the bootloader is locked. Also, look at the Device Manager we opened earlier and confirm that you see Android ADB Device (or similar) which confirms your PC recognizes the phone and setup for ADB commands .
To unlock the bootloader, in the command prompt type:
fastboot flashing unlock
This will unlock the bootloader, you will likely see a warning that it's going to wipe the phone. Proceed and allow the unlock. The phone will then reboot and take you to your wiped phone just as you received it out of the box, except the bootloader is now unlocked and Developer Options are still available. Let the phone continue through it's first-time setup, and leave the phone plugged into the PC. If you unplugged no biggie, but we're going right back to the PC shortly and it will need to be plugged back in before the next step to accept the file we're going to push to it.
Now, you want to open a browser on the phone and go to (at the time of this writing, v23.0 is the current stable Magisk):
Release Magisk v23.0 · topjohnwu/Magisk
This release is focused on fixing regressions and bugs. Note: Magisk v22 is the last major version to support Jellybean and Kitkat. Magisk v23 only supports Android 5.0 and higher. Bug Fixes [App]...
github.com
Scroll down and under "Assets" select that Magisk 23.apk file, download and install it. Open Magisk if it doesn't open on install, and just let it sit, we're coming back to it shortly.
PATCHING THE BOOT.IMG FILE
On the PC, go back to the Factory Image you downloaded, and extract it to a temporary directory. You will see 6 files; a few "flash-all" files, a radio image, a bootloader image, and a ZIP file called "image-barbet-XXXXXXXXXXX.zip (the xxx's are whatever the version number is you've downloaded). Double click that ZIP file and you will see a dozen files. The one we need to root the device is "boot.img".
Copy (don't move!!) this file to c:\platform-tools. Now, go back to your command prompt (still pointing to c:\platform-tools) and type in:
adb push boot.img /sdcard/Download
Now back on the phone, within the Magisk app we left open, at the top where it says Magisk, choose to install. A dialog box will open, select Patch Boot File Image. Point the process to your /sdcard/Download, and select the boot.img file we just pushed there. Now allow it to patch the boot.img and Magisk will show you it's patching it, and in a moment tell you it was successful. Close the Magisk app, open "Files" and direct it to sdcard/Download. Note the name of the patched boot file, which is called "magisk_patched-XXXXX_xxxxx.img (the X's are the Magisk version, and the x's are 5 random chars). Feel free to leave it there as you go back to the PC...
Back on the PC, in the command prompt, now type:
adb pull /sdcard/Download/magisk_patched-XXXXX_xxxxx.img
make certain you get the name exact or it won't go, no worries, just get it correct. The file now resides in the "c:\platform-tools" directory along with the unpatched "boot.img" and your ADB+Fastboot tools.
Just about done rooting, here we go!
Now, in the command prompt type:
adb reboot bootloader
The phone reboots into bootloader. Now type:
fastboot flash boot magisk_patched-XXXXX_xxxxx.img (again, use the numbers and letters in YOUR patched file!)
Lastly, type:
fastboot reboot
Your phone reboots, and you should be rooted!! Unplug your phone from the PC, open up Magisk App and confirm, the Magisk entry at the top of the main Magisk App screen should now show you the version you installed, etc!
Time to get your banking apps (and any others that may detect unlocked bootloaders/root/etc) working!
In the Magisk App, on the bottom of the screen is a 4 item menu bar. Select the right-most icon, which is "Modules". At the top of the screen select "sorting order" and sort alphabetically. Scroll down to "riru" and select the module that is JUST "RIRU", (not any of the other "riru _______" modules). Choose to download it, then choose to install it. You'll be prompted to reboot the phone, so reboot the phone.
Next, we're going to install drag0n's Universal SafetyNet fix (at the time of this writing it's currently v 2.1.1) You will need to download this via a browser on your phone, so open a web browser and go to:
GitHub - kdrag0n/safetynet-fix: Google SafetyNet attestation workarounds for Magisk
Google SafetyNet attestation workarounds for Magisk - GitHub - kdrag0n/safetynet-fix: Google SafetyNet attestation workarounds for Magisk
github.com
On the right-hand side, you'll find "Releases", and v2.1.1 is the latest. Select that, then scroll down to "Assets" and download "safetynet-fix-v2.1.1.zip" By default this will download to sdcard/Download.
Go back into the Magisk App, select the "Modules" menu as above, and at the very top select the "Install from Storage" bar. Point to the file we just downloaded and install it (don't extract it, etc, it requires the zip exactly as downloaded and will do it's thing). Again, it will install the module and prompt you to reboot. Reboot.
Almost there!
At this point, if you havent installed your banking apps, do so. DON'T RUN THEM, just install them. I also have a Nintendo Switch Online app which failed because of root, so if you also have or want this app, install it now, again, do NOT run it yet, just install. Same with any other apps you are aware which have root/bootloader unlocked issues, get them installed, but don't run 'em.
Now, we're going to use MagiskHide to hide these apps and complete the process for passing SafetyNet and running apps which may not run due to root.
in the Magisk App, at that 4 item menu bar at the bottom, select the 2nd from left, or "MagiskHide". Select the MagiskHide item and it will open to a scan of all the apps on your system. By default I believe Magisk sets up to hide Google Play Services. You will see it selected, and all the other apps on your system unselected. Select each of the banking apps, the Nintendo Switch Online (if you have it), and any other apps that YOU ARE SURE will complain about unlocked bootloaders and/or root. Any onilne gaming that's popular are good choices, but again, it's easiest to NOT RUN them PRIOR to hiding them via MagiskHide. Pokemon GO comes to mind as one I've seen that needs hiding, etc, so make it easy on yourself and do a little research on any suspect apps prior to running them, then hide them if needed.
Anyhow, select your banking apps to hide them.
Now, we're going to check SafetyNet to make sure youll now pass.
On the Home menu in the Magisk App, select "Check SafetyNet". You will be prompted to download some proprietary SafetyNet shhhhhhhtuff....so let it download. Once done, SafetyNet check will open, and you should show a blue screen which says SUCCESS, and "basicintegrity" and "ctsProfile" will be checkmarked, evalType will show BASIC.
You're good to go, rooted, SafetyNet works perfect, and you can now open your banking apps and should open right up!!
If you find any specific issues about specific apps not working, or detecting root, etc, the best place to get help is in the Magisk General Discussion forum:
Magisk General Support / Discussion
This is the place for general support and discussion regarding "Public Releases", which includes both stable and beta releases. All information, including troubleshoot guides and notes, are in the Announcement Thread
forum.xda-developers.com
I owe those folks eternally for showing me what I know, and always having the answers for any issues I've ever had. Some of the nicest, smartest people Ive had the pleasure of knowing, they're always helpful, and even maintain fantastic sites for FAQ and chock full of great info about every aspect of Magisk.
BONUS ITEM: As I indicated above, I'd share the method I know, trust, and have used many many times, trouble free, to apply a system update to the phone without overwriting anything, and not hitting any issues many encounter using the OTA method (though I understand that's been vastly improved, I haven't educated myself as to that process and will likely continue to use this method).
Security Update (monthlies) Process using Full System Image
As above, download the newest Full Factory Image from the site. Extract this full image to a directory inside C:\platform-tools
In this directory, if you're on Windows, open the "flash-all.bat" file (don't run it, open it with Notepad or something similar, I really like Notepad++ as it's free, has a LOT of great functionality and, like the native Notepad, doesn't do any goofy formatting/fonting/etc when modifying and saving a file.)
In flash-all.bat, look for the "-w" entry in the fastboot command near the end of the file and REMOVE ONLY THE "-w", leaving the line correctly formatted (don't leave an extra space or something goofy), then save the file over the top of the original with the same name. This will remove the overwriting of your data when pushing the image, the "-w" tells the process to overwrite, so we remove it.
Open up a Windows Explorer and go to your c:\platform-tools directory. Delete (or move to another location) any "boot.img" files along with any "magisk_patched-XXXXX_xxxxx.img" files from previous operations. Also note and confirm that you have correctly extracted the latest Full System Image to it's own directory, residing in c:\platform-tools.
Now, connect your phone to the PC. Open your command prompt and point to "C:\platform-tools" again. Type: cd <name of Full system Image directory>
In command prompt, type:
adb reboot bootloader
The phone is now in bootloader. In command prompt, confirm you're pointing to "C:\platform-tools\<Full System Image extract dir>" Type:
flash-all
This will do a full factory image push to your phone, you'll see a couple quick writes and phone reboots, then begins writing the rest of the image to your phone, but since we removed the "-w" from "flash-all.bat", it's NOT overwriting your data, just the necessary system files to update it to the latest version!
Reboot your phone, let it do any optimizing and updating it needs to do, and don't run anything yet, we're not quite done, just let the phone settle in and finish booting and doing it's thing.
Now, go back and perform the steps above listed under "PATCHING THE BOOT.IMG FILE" to patch the newest boot.img from the Full System Image we just updated the phone with (push the boot.img to sdcard/Download, patch with Magisk App, pull magisk_patched-XXXXX_xxxxx.img to your PC, blast it back using fastboot), and you've now rerooted the phone.
Lemme just say again that I know this was a friggin' book, and I tried to make it as clear and plain language as I could to help even a first timer, so my apologies if it seems like an onerous process. It's really not, and once you've done this once or twice, it's a cakewalk and takes about 10 minutes of your time from start to finish to do the whole system update and reroot. Again, the newer methods to take OTA without losing root may be something you'd like to look into, i definitely will, but I'm very confident in sharing this method as I know it works like a champ and is foolproof if you take your time the first few times and make sure you do what's required (remove the "-w" from the flash-all.bat, etc)
Lastly, I've been using this method since the Pixel 2, and just performed it on my new 5a, it worked exactly as it has for years for me on the P2, so you can be confident moving forward that, if you follow instructions and take your time until it's all familiar, you'll be successful in rooting, passing SafetyNet, and applying system updates without screwing up the A/B slots or overwriting your data in the process.
I hope this helps even one person, and since I rarely find myself able to give back to the community in any real meaningful way (many of these folks are WAAAY beyond my modest skills and know so much!!), I hope that this provides some folks with a useful and meaningful tutorial, providing confidence that anyone can root their P5a (or about any Pixel it seems) without being a Magisk/Android prodigy.
@Didgeridoohan, @pndwal, @zgfg, @jcmm11, and so many others over the years have been so helpful, I couldn't have done any of this without their selfless help, so give those folks a big thanks also if this is any help to you.
Best of luck,
hfam
Thanks for the write-up @hfam, it's good to know that some of the steps that i tried aren't really necessary, like using props config or hiding the actual magisk app.
Appreciate you!
nsoult said:
Thanks for the write-up @hfam, it's good to know that some of the steps that i tried aren't really necessary, like using props config or hiding the actual magisk app.
Appreciate you!
Click to expand...
Click to collapse
Awww, thanks! Glad to do it and really hope it helps some folks tackle rooting their phones and passing SN!
Rooted with magisk v.23 - flashed zip as a module
So has anyone installed the October update yet?
GrandAdmiral said:
So has anyone installed the October update yet?
Click to expand...
Click to collapse
Yep, good to go. I used the same method I shared above.
Is this working with Android 12? Which Magisk version to use?
This method did not work for Android 12. I updated my rooted phone to android 12 OTA. It returned to stock. I followed the method above to patch the factory boot.img file with magisk. After flashing my phone in bootloader with the patched boot.img, my phone will not reboot. says:
failed to load/verify boot images
Any advice? My Magisk is v23. Do I need to use a beta version?
Poking around in this thread, it seems that android 12 root is a much more involved process, requiring factory wipe and additional steps.
[Guide] Flash Magisk on Android 12
Trying to root the Pixel 5 running Android 12 by flashing a magisk-patched boot image results in the phone only booting to fastboot mode ("failed to load/verify boot images") Some users have reported that booting (instead of flashing) the patched...
forum.xda-developers.com
tintn00+xda said:
This method did not work for Android 12. I updated my rooted phone to android 12 OTA. It returned to stock. I followed the method above to patch the factory boot.img file with magisk. After flashing my phone in bootloader with the patched boot.img, my phone will not reboot. says:
failed to load/verify boot images
Any advice? My Magisk is v23. Do I need to use a beta version?
Click to expand...
Click to collapse
As you stated, you are correct. You need to perform a full wipe or flash the factory image with a wipe and then root works fine and phone boots. Tried myself and works fine.

General Flashing GSI on Edge S/20 Pro (Magisk enabled)

First of all, thanks to ilia3367 for his Pure Edition ROM which contains some very useful stuffs for flashing and booting GSI.
Code:
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in the GSI
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
What you need
1. Unlocked bootloader
Follow this guide to unlock bootloader. In overall, the unlock process is not as difficult compared to other brands, provided your device is eligible to unlock.
WARNING: The following steps assume you have already unlocked your bootloader. If you haven't unlocked your bootloader yet, or your device isn't eligible, DO NOT PROCEED.
2. fastboot
The process utilizes fastboot exclusively, so make sure you have fastboot installed.
3. A Magisk patched boot.img.
You can either patch it yourself using Magisk Manager, or use boot_magisk.img from Pure Edition ROM.
Although you should be able to use GSI without Magisk, you'll probably need to patch vbmeta (or vbmeta_system) so the stock kernel won't refuse to boot the GSI in this case. This guide does not cover non-Magisk scenario for now, as I'm not entirely sure. With Magisk, patching vbmeta is not needed.
4. A backup of factory images in case something goes wrong.
The factory image (both S and 20 Pro) can be found in the Pure Edition ROM thread as well.
Steps to flash GSI
1. Enter fastboot
Hold down both POWER and VOL- to enter fastboot mode.
Or you can use the following adb command to do so.
Code:
adb reboot bootloader
2. Enter fastbootd
Enter the following command to enter fastbootd, where you can actually access the system partitions, as this phone uses Dynamic Paritions.
Code:
fastboot reboot fastboot
WARNING: The following steps will actually modify your system partitions and may leave your phone unbootable. Make sure you have backed up everything before proceeding.
3. Flash Magisk patched boot.img
Assume you have the Magisk patched boot.img as boot_magisk.img, enter the following command.
Code:
fastboot flash boot boot_magisk.img
Note that you can also flash boot.img directly from fastboot, before entering fastbootd.
4. Remove the product partition
The phone's system partition is very small (about 1GB), but has a very big product partition (about 2.7GB). You'll get an error if you try to flash the GSI right away, as the super partition does not have enough room to resize the system partition to hold the GSI image if it's too large.
As the product partition is not useful for GSIs, it can be safely removed. Enter the following commands.
Code:
fastboot erase product
fastboot resize-logical-partition product_a 0x0
This will erase the stuffs in the product partition and set its size to zero, so the system partition would be able to claim its space when resizing.
You can always use the following command to check bootloader variables.
Code:
fastboot getvar all
In this case, check if the product_a partition has indeed been resized to zero. If yes, you can proceed.
Code:
(bootloader) partition-size:product_a:0x0
5. Flashing the GSI
Enter the following commands.
Code:
fastboot erase system
fastboot flash system gsi.img
Note that the erase command is optional. Replace gsi.img with the actual GSI image file of your choice.
6. Wipe userdata if needed
You don't need to wipe userdata if you are dirty flashing newer build of a same GSI over the existing one.
In case you need to do so (such as flashing a different GSI, or factory reset), enter the following commands.
WARNING: These commands will erase everything in the internal storage, not just app data! Make sure you have everything in the internal storage backed up before doing this. You may try this unofficial TWRP for this device if you want to perform factory reset while keeping your files, as well as creating a nandroid backup.
Code:
fastboot erase userdata
fastboot erase metadata
7. Reboot
Enter the following command to reboot.
Code:
fastboot reboot
If nothing goes wrong and the GSI doesn't have any major issue that might prevent it from successfully booting, you should be able to boot the GSI and further configure it yourself.
I'm still experimenting with GSI so I'm not sure which feature works and which doesn't.
The GSI I'm currently testing is DotOS. Different GSIs may produce different results but should be mostly similar.
For now it seems the following stuffs are working fine:
- Wi-Fi
- Bluetooth (Audio is problematic, other parts appear to work fine)
- 5G (Data)
- NFC
- Camera
- Display color settings (such as Boosted, Saturated)
- Fingerprint Sensor (Turned out it works!)
- Encryption (GSI can work with untouched vendor, which enforces encryption)
- 120/144 fps (On GSI it defaults to 120 fps, which can be changed in Phh-Treble settings)
The following stuffs are problematic:
- MTP (I recommend using ADB as it's a hit-or-miss on Linux. On some environments it works, on other environments it doesn't)
- Bluetooth Audio (Need to enable "alternate audio policy" and also "Force disable A2DP offload" for headsets to work correctly)
The following stuffs are not working:
- VoLTE (While you can enable "Force the password of 4G Calling setting" in Phh Treble Settings -> IMS features" then toggle it off then on upon system startup to make it active, it does not work correctly!)
Here are some functionalities that I won't be able to test as I'm not actually using them.
- SafetyNet related (I use microG now)
- USB Type-C Audio (I mainly use bluetooth headsets if needed for all except gaming)
- SIM2 (I'm confident it'll work as both SIM slot's IMEIs are correctly detected)
- Carrier-specific issues (Need someone using Verizon or other GSI-problematic carriers to test this)
Currently I've tested that the most recent DotOS, OctaviOS GSIs are working.
Keep in mind that not all GSIs can boot. You'll need to look for another build if the one you flashed doesn't boot correctly (which seems to be SELinux related).
For now, most of the functionalities work on GSI using a Magisk patched stock kernel and untouched vendor. The kernel source for RRA31 build (Global) is currently in the process of being released.
UPDATE (11/3/2021): The source code is now available.
but i've still have a question for the step 5
this mobile is a/b slot but you didn't use fastbootd mode is that work?
ZhenYuSAMA said:
but i've still have a question for the step 5
this mobile is a/b slot but you didn't use fastbootd mode is that work?
Click to expand...
Click to collapse
Step 2 is switching to fastbootd. The rest of the commands are done in fastbootd mode.
fastbootd uses the same syntax as fastboot.
This phone uses dynamic partitions, but is also A/B. Usually you would be on slot A if it's a new phone, but be sure to pay attention to active slot if the phone has taken OTA updates before.
I don't know if there are already OTA updates out, though this phone is still relatively new.
LSS4181 said:
Step 2 is switching to fastbootd. The rest of the commands are done in fastbootd mode.
fastbootd uses the same syntax as fastboot.
This phone uses dynamic partitions, but is also A/B. Usually you would be on slot A if it's a new phone, but be sure to pay attention to active slot if the phone has taken OTA updates before.
I don't know if there are already OTA updates out, though this phone is still relatively new.
Click to expand...
Click to collapse
whoa, now i see much thx
I tried DotOS 5.2 since i don't have volte on my area, and it was usable, only thing that annoyed me a little is CPU being capped at 2500MHz. Do you know how to have the same frecuency config as with the stock ROM?. With stock i noticed everytime i open a benchmark app the CPU stays at max frecuency on all cores even if it's not running the actual benchmark.
I don't have much knowledge with tweaking system code since the phone i had before had every ROM in every flavor already optimized (k20 pro) and with this one i'm getting a little bit bored to be honest so i wanted to do something myself but i couldn't get around those frecuency issues. Tried with Franco Kernel Manager and EX, the frecuecies applied but after around 1 minute everything went back to default.
Also, did you try the stock camera app?
Thanks.
rodrimax10 said:
I tried DotOS 5.2 since i don't have volte on my area, and it was usable, only thing that annoyed me a little is CPU being capped at 2500MHz. Do you know how to have the same frecuency config as with the stock ROM?. With stock i noticed everytime i open a benchmark app the CPU stays at max frecuency on all cores even if it's not running the actual benchmark.
I don't have much knowledge with tweaking system code since the phone i had before had every ROM in every flavor already optimized (k20 pro) and with this one i'm getting a little bit bored to be honest so i wanted to do something myself but i couldn't get around those frecuency issues. Tried with Franco Kernel Manager and EX, the frecuecies applied but after around 1 minute everything went back to default.
Also, did you try the stock camera app?
Thanks.
Click to expand...
Click to collapse
VoLTE doesn't work with GSIs yet. I tried forcing the toggle out. It does register, but calls do not function at all (hangs). I've reported the issue to phh, but I'm yet to make any progress. One thing I know is that IMS is in `/system_ext`, and that is not used by GSI.
As for CPU cap, I haven't really tried using kernel managers on the device yet (I prefer using SmartPack). My experience with SmartPack on other devices is similar, that any changes to frequencies would be reverted to default after a while.
It seems the system (or maybe just stock kernel) nowadays don't allow you to freely change CPU/GPU frequencies anymore, and your experience with Franco and EX further proved it. As for benchmark apps capping CPU frequency... I suspect the phone has some cheating mechanisms similar to some other ones in the past.
Don't know about stock camera app. For custom ROMs/GSIs my favorite is Open Camera, which is installed via NanoDroid to replace the stock ones.
Plus, with stock ROM, the system partition doesn't really have many stuffs. Other stuffs were placed in `/system_ext` and `/product`, and it appears that GSIs use neither of those. It's possible that the libraries of some essential features reside in `/system_ext` and therefore would not be available for GSIs (like IMS).
This procedure could be used to A12?
vinaaa said:
This procedure could be used to A12?
Click to expand...
Click to collapse
Yes but from my experience apart from the bugs mencioned above, in A12 fingerprint and magisk don't work and bluetooth doesn't either even with the workaround. Once i found these bugs i went back to stock so i didn't test it more than 15 minutes, it probably has a lot more to be found
LSS4181 said:
VoLTE doesn't work with GSIs yet. I tried forcing the toggle out. It does register, but calls do not function at all (hangs). I've reported the issue to phh, but I'm yet to make any progress. One thing I know is that IMS is in `/system_ext`, and that is not used by GSI.
As for CPU cap, I haven't really tried using kernel managers on the device yet (I prefer using SmartPack). My experience with SmartPack on other devices is similar, that any changes to frequencies would be reverted to default after a while.
It seems the system (or maybe just stock kernel) nowadays don't allow you to freely change CPU/GPU frequencies anymore, and your experience with Franco and EX further proved it. As for benchmark apps capping CPU frequency... I suspect the phone has some cheating mechanisms similar to some other ones in the past.
Don't know about stock camera app. For custom ROMs/GSIs my favorite is Open Camera, which is installed via NanoDroid to replace the stock ones.
Plus, with stock ROM, the system partition doesn't really have many stuffs. Other stuffs were placed in `/system_ext` and `/product`, and it appears that GSIs use neither of those. It's possible that the libraries of some essential features reside in `/system_ext` and therefore would not be available for GSIs (like IMS).
Click to expand...
Click to collapse
Thank you for the reply
I don't know if this is of any relevance but after disabling system tracing on developer options on stock A11, the CPU is not capped when opening benchmark apps anymore
I didn't like the DotOS. Yes, it has an interesting interface, interesting graphical solutions. But many additional settings and functions don't work.
ilia3367 said:
I didn't like the DotOS. Yes, it has an interesting interface, interesting graphical solutions. But many additional settings and functions don't work.
Click to expand...
Click to collapse
GSIs aren't 100% bug-free from my own experiences. Sometimes regressions or plain oversights can happen with certain versions. A long time ago with older devices I even had times when Bluetooth didn't work on a certain GSI because the maintainer forgot to include Bluetooth related libraries (as the logcat errors implied the files were absent).
A recent example would be that custom fonts used to work with an earlier build of OctaviOS (July) but broken with the latest (September). Either the maintainer somehow forgot to actually include the fonts this time, or there were regressions/bugs in the OS itself causing the feature to break.
Plus, it seems substratum is still alive and active, yet I'm quite a n00b when it comes to adding additional features to system with it (preferrably on top of plain AOSP). Back then I mainly used it for custom themes I bought, and when custom ROMs started including built-in theming and the features I need, substratum is pretty much dead to me and I haven't touched it for years since then.
PS: There is an ongoing bug with DotOS for this device, since 5.1, that keyboard layout button would not show up when using 3-button navbar (which is my favorite). The button correctly shows when using gestures or 2-button navbar. I reported the issues several times in the group but I got very limited response (probably because few users are using it thus affected)... so the issue persists with the recently released DotOS 5.2 GSI.

Categories

Resources