[Sony Xperia X Compact Guides, News, & Discussion] itandy:
This guide is to help anyone who wants to use Android Pay but his XC phone is unlocked and rooted. It begins with an unlocked phone with a valid backup of the TA partition as well as an unrooted /system partition.

Prerequisites:

1. A backup of TA partition (https://xdaforums.com/crossdevice-dev/sony/universal-dirtycow-based-ta-backup-t3514236)

2. Unlocked bootloader

3. Working fastboot driver and command

4. Clean /system partition without any trace of su. Systemless root is fine because it will be overwritten by the new kernel. If needed, flash the stock system partition again.

5. TWRP image for XC (https://drive.google.com/open?id=0B0j3VJ1Xp5N8M1ZGbzBBMTdyRnM)

6. Stock kernel image (Extract kernel.sin from official FTF)

7. Trim Area Proof Of Concept (https://xdaforums.com/crossdevice-dev/sony/poc-real-trim-instead-drm-fix-t3552893)

8. Tobias kernel repack tool (https://xdaforums.com/xperia-z5/development/root-automatic-repack-stock-kernel-dm-t3301605)

9. Magisk v12.0 flashable zip, not Manager app (https://xdaforums.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445)

Procedures:

1. Run TA PoC (DOUBLECLICKME.bat). You'll be asked to select your kernel image (kernel.sin) and TA backup (your TA backup file). Choose also to disable DM-Verity, Sony RIC but keep Force-encrypt (my data partition is encrypted, your choice). At the end a new file new_boot.img will be created.

2. Copy the new_boot.img in step 1 to Tobias tool folder. In the same folder, execute the following command. Again, disable Sony RIC, don't install TWRP, don't install DRM fix and don't install Busybox. At the end, another file boot.img will be created.

rootkernel.cmd new_boot.img boot.img

3. Power off your phone. Power on again while holding volume up rocker to enter fast boot mode. Execute the following command to flash the new boot image. Replace boot.img with your new image in step 2 with full path.

fastboot.exe flash boot [I]boot.img[/I]

4. Reboot your phone. No root or SuperSU app should be found.

5. Copy Magisk zip file into phone internal storage.

6. Dial *#*#7378423#*#*, followed by Service Test > Security to check if DRM is detected properly. At this point of time, your phone should be su free and DRM working properly.

7. Power off your phone. Power on again while holding volume up rocker to enter fast boot mode. Execute the following command to boot TWRP. Replace twrp.img with your TWRP image with full path.

fastboot.exe boot [I]TWRP.img[/I]

8. In TWRP, flash Magisk zip

9. Reboot your phone. Install Magisk Manager app (no long available in Play Store) (http://tiny.cc/latestmanager)

10. Run Magisk Manager and turn on Magisk Hide. You should see Magisk installed successfully and properly rooted with MagiskSU. Tap SafetyNet button to check if it can be passed.

11. (optional) Install Xposed using Magisk app, not official method. Xposed will break Safety Net again. But you can always disable it in Magisk Manager easily.

Remarks:

1. Trim Area Proof Of Concept is required to restore full DRM functionality so that Safety Net thinks the phone is still locked.

2. /system partition must be clean and free of any trace of previous su installation.

3. Magisk Manager app cannot be used to install Magisk because it requires root in the first place. Even with systemless root, after Magisk is installed this way, trace of su can be found in /vendor partition.

4. Tobias tool has to be used to repack the boot image because I found that if PoC image is used directly, phone will reboot unexpectedly after Magisk is installed.