[Magisk] topjohnwu:
2017.11.23 Magisk v14.5

Many people dislike the direction Google is leading Android judging from the Pixel lineup. Inevitably we will see Pixel-2-like configurations on all newly released device at some point in the future, since any device shipping with Oreo will need to pass Google's new VTS. And for sure we start seeing cheap shots like lazy OEMs releasing new devices with outdated software, which I'm VERY disappointed to see the "highly praised" OnePlus 5T on the list, but I digress.

The introduction of Project Treble brings a huge change to how we mod our devices, and Magisk is exactly created to accommodate this nature: minimum intrusion with maximum versatility. It is sad to see people in the forums happily rooted their shiny new Pixel 2 XL, but immediately modify system files just like the good old days, completely ignoring what Magisk is created for in the first place. Not blaming anyone here, but I guess the systemless concept still requires some time to be widely accepted.

Forgive my little rant, let's get into the nitty-gritty :), here's another release with exciting new features!

Dynamic Runtime Initramfs Setup

As mentioned, installing Magisk on newer devices starting from the original Pixel series requires special treatments, and this has led to two separate logic for installation. I have spend some time rewriting the startup process of Magisk, and unified the installation across all devices. The magisk binary and init scripts are embedded into magiskinit, and magiskinit will dynamically inject these files and patch (or construct in the case of skip_initramfs devices) initramfs and sepolicy on-the-go. The actual modifications done on the device is replacing init with magiskinit in ramdisk of boot.img , and additional dtb/kernel/dtbo patches if required.

MagiskHide - Even More Badass!

More and more apps (those that doesn't use Google's SafetyNet API to check device integrity) has been updated to detect Magisk, such as the popular game Fate Grand Order and a handful of banking apps. I got bored and had my hands on to fix this issue. The fix can be roughly split to two parts, both of them are future proof to a certain extent. There are still some stuffs that can be detected, but even if I can hide them easily I haven't bothered yet. Unless they come up with complete new innovative ways to detect Magisk, the new hiding method should work in all cases (at least for now).

The first part is that Magisk image's mount point is now moved under /sbin/.core (along with several internal paths) , from /magisk to /sbin/.core/img; a symlink (/magisk -> /sbin/.core/img) is still added for legacy support. However, the symlink could be temporarily removed when MagiskHide is working, so scripts that had hardcoded path "/magisk" should really start migrating to "/sbin/.core/img" since "/magisk" doesn't always exists. The result is that the existence of the folders will also be hidden with MagiskHide. Changing the mount point means some modules using bad techniques such as creating symlinks pointing into magisk internal paths might break! You shouldn't assume the Magisk mount point to always be /magisk. One possible way to overcome this is to NOT use symlinks but use hardlinks (command ln without the -s flag), but I still wouldn't recommended it since modules should not depend on Magisk's internal stuffs.

Some modules NOT using the util_functions.sh from Magisk will have high chances to break, please update accordingly, or migrate to use the global util_functions.sh so Magisk internal changes will reflect to your module

The second part of the puzzle is that Magisk Manager can now be properly hidden. Hiding Magisk Manager will now repackage itself with a randomly generated package name to replace the original one. The real magic and challenge here is to transfer root management from the old package name to the new one seamlessly. Even though I have put a ton of effort and this feature has been tested for quite a while, due to the complexity I would still only recommend enabling this if you ACTUALLY need it. If you face any issues, simply just reinstall the proper Magisk Manager back and re-hide again.

Welcome On Board, Pixel 2!

Lastly, let's welcome Pixel 2 (XL) on the official support list! One additional change to the Pixel 2 installation compared with v14.4 is that I added dtbo.img patching support to disable avb-verity of the vendor partition. You can now modify (though not recommended) the partition without issues. The DTBO is a separate partition on the device, and Magisk will backup the original one to /data/stock_dtbo.img.gz for restoration and uninstallation.

P.S. This release was meant to be a stable v15.0, but my testers suggested to remain as beta due to the couple big changes mentioned above. It is now a good time for Magisk Manager translators to submit your patches to Github and prepare for the upcoming stable release!