Build termux as a system app for your phone
1. AIMS
when termux is a system app, I could
- hide rooted state but
- still modify hosts to block Ads;
- manage apps;
- et al.
2. MY CONDITIONS
- Device: MEIZU 17
- Android: 11
- Termux: 0.117
- Windows 10
3. MAIN STEPS
3.1. Pre-Requirements
- Android Studio: SDK for Android 11.0(R), NDK, et al.
- Rooted state
- Platform-tools for Windows
3.2. Git clone codes
Minor amendments are:
- Adding extra permissions according to @agnostic-apollo
Changing gradle maven for users from China
git clone https://github.com/termux/termux-app.git
#or
#git clone https://github.com/TREYWANGCQU/termux-app.git
3.3. Build apk for your device
It is noted that Bootstrap lib is varying from your devices. That is exactly the reason why I faced failure when I directly moved termux to system directory. the arm libs could be:
- x86
- x86_64
- armeabi-v7a
- arm64-v8a
In my issue, it is arm64-v8a.
The soluction is simple: just running apps on the hardware device
3.4. Move apk to system directory
It is easy to find the apk path of Termux via AndroidApkAnalyzer
Then,
adb root
adb shell #enter shell
mkdir -p /system/priv-app/Termux
cp -r /data/app/~~......=\=/[com.termux]/base.apk /system/app/Termux # fail to remove to priv-app
cp /data/app/~~......=\=/[com.termux]/lib/arm64 /system/lib
chmod 755 /system/priv-app/Termux
chmod 755 /system/priv-app/Termux/*
chmod 655 /system/lib/*
exit
adb uninstall com.termux
reboot
3.5. Unroot Hide root
Change a special su name to hide root
mv /system/xbin/su /system/xbin/lu.me.haha.reaticle
Create a symbol soft link to Termux directory
sh -s /system/xbin/lu.me.haha.reaticle /data/data/com.termux/files/usr/bin su
3.6. The results
am start -a android.intent.action.MAIN -n com.android.settings/com.meizu.settings.root.FlymeRootRequestActivity –ei uid 10192 –ei pid 13525 > /dev/null
I found the secret…
Comments
However, it seems step 3.5 is all enough…(ー_ー)!!