Android 10: Emulation of Magisk/SuperSU on an AOSP AVD

Limitations/Constraints

Limitations Applicable to Emulation of Magisk/SuperSU

Pre-requisites for Magisk/SuperSU

Target Virtual Device Details

that the SELinux policy is in effect and things that it doesn’t want to allow won’t be allowed

emulator -avd aosp10_sandbox
adb root
adb shell getenforce
-->
Enforcing
adb shell "setenforce 0"
adb shell getenforce
-->
Permissive

Launch AVD with SELinux Policy as permissive by Default

emulator -avd aosp10_sandbox -selinux permissive
emulator -avd aosp10_sandbox -selinux permissive -no-snapshot-load
adb root
adb shell "getprop ro.product.cpu.abi"
--> x86_64
adb shell getprop ro.build.ab_update
--> false
adb shell getprop ro.system.build.version.release
--> 10

adb shell getprop ro.system.build.version.sdk
-->
29
adb shell "which su"
--> /system/xbin/su
adb shell "ls -laR /system/xbin"
-->
-rwsr-x--- 1 root shell 11528 2019-08-02 15:35 su

Installing SuperSU

adb root
adb shell "cat /proc/mounts | grep -i ' / '"
-->
dev/block/dm-2 / ext4 ro,secla......
adb shell "mount -t tmpfs -o size=15M tmpfs /system/xbin"
adb shell "cat /proc/mounts | grep /system/xbin"
-->
tmpfs /system/xbin tmpfs rw,seclabel,relatime,size=15360k 0 0
cd c:\temp\x64
adb push .\ "/system/xbin/"
-->
.\: 5 files pushed, 0 skipped. 85.6 MB/s (872152 bytes in 0.010s)
adb shell "ls -l /system/xbin"
-->
libsupol.so
su
suinit
sukernel
supolicy
cd c:\temp
adb install SuperSU-v2.82-SR5.apk
-->
Performing Streamed Install
Success
adb shell "nohup /system/xbin/su 0 su --daemon &"
adb shell "ps -ef | grep daemonsu"
-->
..
..daemonsu:mount:master
..daemonsu:master
..
cd c:\temp
adb install Xplore_4.20.04-42004.apk
-->
Performing Streamed Install
Success

Installing Magisk

pip install colorama
cd C:\temp\repos
git clone --recurse-submodules https://github.com/topjohnwu/Magisk.git
# The version name and version code of Magisk
version=20.4
versionCode=20400

# The version name and version code of Magisk Manager
appVersion=7.5.1
appVersionCode=267
python build.py ndk
python build.py all
cd <repo_root_path>/scripts
chmod 755 emulator.sh
./emulator.sh
adb shell "mkdir -p /data/adb/magisk"
adb shell "cp /data/local/tmp/busybox /data/adb/magisk/"
adb push scripts/util_functions.sh /data/adb/magisk/
cd C:\temp\repos\Magisk
adb root
adb push native\out\x86\busybox scripts\emulator.sh /data/local/tmp
adb push native\out\x86\magiskinit64 /data/local/tmp/magiskinit
adb shell "mkdir -p /data/adb/magisk"
adb shell "cp /data/local/tmp/busybox /data/adb/magisk/"
adb push scripts\util_functions.sh /data/adb/magisk/
adb shell sh /data/local/tmp/emulator.sh
adb shell "ps -ef | grep -i magisk"
-->
root ..... 00:00:00 magiskd
cd C:\temp\repos\Magisk\out
adb root
adb install app-debug.apk

-->
Performing Streamed Install
Success
cd c:\temp
adb install Xplore_4.20.04-42004.apk
-->
Performing Streamed Install
Success

Final Comments

Appendix 1: Android 10 Partitions/File System

Appendix 2: Download and Install Android Studio

Appendix 3: Configuring Android Studio/SDK Platform

%ANDROID_SDK_ROOT%\emulator
%ANDROID_SDK_ROOT%\platform-tools
%ANDROID_SDK_ROOT%\tools\bin
$USERPROFILE/.android/ 
$USERPROFILE/.android/avd/

Appendix 4: Create Target AOSP 10 Virtual Device

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store