[Magisk] topjohnwu:
2017.12.22 Magisk v14.6

Previous implementation of the hiding Magisk Manager mechanism has flaws, the Magisk Manager lack the capability to recover from the repackaged state.

If you have hidden (repackaged) Magisk Manager on v14.5, you HAVE TO upgrade both Magisk Manager and Magisk VIA THE APP to not mess up!!

Please DO check the updated Notes & Troubleshoots section in the OP if you plan to use the Hide Magisk Manager feature!!!

This should be the most thoroughly tested release ever LOL.

Not that much new exciting features, but tons of improvements along the way!!

Project Restructure

For those following the Github source would realize that the project has gone through a major restructure - the whole Magisk source code is now a single Android Studio project. Since Magisk's code is starting to become overwhelmingly huge, and also Magisk Manager (Java) is so deeply integrated with the core C/C++ part, the burden to develop Magisk is becoming more and more annoying. I decided to utilize Android Studio's CLion (a C++ IDE) NDK integration to assist the development, and another advantage is that I can develop Magisk Manager (Java) side-by-side with the native C/C++ part. Those who are willing to dig through Magisk's source can simply select the whole folder in Android Studio, and you can start developing immediately!

Just keep in mind: don't build Magisk with the built-in gradle scripts, the building process is quite complicated and all handled through the Python script "build.py"

Stability Fixes

Invincible mode has been rewritten. A new daemon "magiskinit_daemon" (a fork of magiskinit) will maintain a socket connection with the main magisk_daemon, and once disconnected (which means the daemon unexpectedly terminated), it will respawn the magisk daemon right away. This is much more robust than the previous implementation which relies on a init rc script, and the additional daemon will consume no power and very little memory since it literally does nothing unless the socket connection is broken.

A bug in the logcat monitor (a very essential part of MagiskHide and logging) which causes spawning infinite logcat processes and exhaust all resources until system reboot (not very common but fatal) is resolved. It has also be rewritten to be more efficient.

Huge MagiskSU Improvements

Since I picked up phh's Superuser source code, I have massively rewritten all the daemon part (communication, database handling, mount namespace etc.), but really never touched the actual "su" implementation. All CM based root (phh, Lineage SU, and previous MagiskSU) inherently include the same incomplete daemon-based su implementation (required since Android 4.3+) across the board. For this update I referenced the official Linux su manpage and made the behavior of MagiskSU as close to the reference as possible. The most noticeable change is that environment variables are now preserved from the original shell to the root shell. This was originally a default behavior of all Linux process forks, but since we are calling a new shell via socket by the daemon, additional work has to be done. More detailed info are in the changelogs.

MagiskHide Improvements - Continuation

In the last release, I added the feature to repackage Magisk Manager, and also move the mount point to a volatile location so it can be hidden by MagiskHide. As a continuation in this release, all Magisk related files are moved to /data/adb, a folder that already existed which has access permission (700). By doing so, any non-root process can never know the existence of any possible Magisk file on the device. In theory this should eliminate ANY naive way to detect Magisk (at least not involving hardware based cryptography) from a target process, but I know several apps that still can detect Magisk. Those might have used some other approaches to detect root (e.g. spawn another process like SafetyNet), I'll try to crack them if I find the time to do so. For those worrying the changes might break stuffs, I had added symlinks for backwards compatibility (just like the previous /magisk symlink), so it should work "most of the time" (as long as MagiskHide isn't actively running a hiding session). A complete redesigned Module template will come out along with the stable release (very soon).

Installation Flags

A new install mode: ramdisk high compression mode is introduced. In real world tests, a Magisk installation will add at most 4XX KB to the compressed ramdisk. If a device has a very small and restricted boot partition size, this size change might actually make the patched boot image unable to fit in. Starting from this release, if the free space in the boot partition is lower than 500KB, high compression mode will be triggered, Magisk will recompress your whole ramdisk with xz (lzma2 alg.). In real world tests, this will typically create near 2MB free space, so this means that Magisk should fit any possible device. This is possible thanks to updates to magiskinit, which can dynamically decompress your ramdisk on-the-fly on boot. The KEEPVERITY and KEEPFORCEENCRYPT flags now have new default settings.

If dtbo.img is detected on your device, KEEPVERITY is enabled by default. If your device is already encrypted, KEEPFORCEENCRYPT is enabled by default.

These default values will show up in Magisk Manager, and will also affect the installation via recovery.

Magisk Manager

Probably the biggest improvement for this release should be Magisk Manager. Although nothing massive changed visually, TONS of bugs and improvements are done under-the-hood. Repackaging Magisk Manager now works much better and more reliably. Settings will be migrated from the original manager to the repackaged one, and it can properly handle duplicate Magisk Managers. Tons of compatibility code has been added to support all possible su database setups. Please check the changelog for the full list of changes.