Tips:
Termux service with runit
- Install and enable
runit
(sv
)
pkg install termux-services
mkdir -p ~/.termux/boot/
cat > ~/.termux/boot/10-sv.rc <<EOF
#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
. $PREFIX/etc/profile
EOF
- Create service configuration
SV=${SV:-alist}
mkdir -p $PREFIX/var/service/${SV}/log
cd $PREFIX/var/service/${SV}
ln -sf ../../../share/termux-services/svlogger log/run
cat > run <<EOF
#!/data/data/com.termux/files/usr/bin/sh
exec $HOME/.local/bin/alist --data $HOME/.local/opt/alist-data server 2>&1
EOF
chmod +x run
- Manage the service
sv-enable alist
sv up alist
Log file can be found under $PREFIX/var/log/sv/${SV}
Magisk script to set ADB TCPIP port at startup
In Magisk, executable general scripts placed in /data/adb/service.d
runs in parallel and NON-BLOCKING.
cat > /data/adb/service.d/adb.sh <<EOF
stop adbd
setprop service.adb.tcp.port 7612
start adbd
EOF
chmod +x /data/adb/service.d/adb.sh
Enable “Install via USB” or “USB debugging (Security settings)” without creating MI Account
This requires root, shell access with su, and a way to edit text files as root. I used Termux and and an android root file manager that can edit text files.
First, run the following command (su first, to switch to root):
setprop persist.security.adbinstall 1
If you also want to enable “USB debugging (Security settings)”, for granting permissions, simulating UI input, etc. via ADB, run the following command too:
setprop persist.security.adbinput 1
Next, we need to edit the file /data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml
so that MIUI actually lets us do these things:
sed -i 's,"perm_adb_install_notify" value="true","perm_adb_install_notify" value="false",' /data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml
Setup Wifi-ADB for scrcpy without root
adb devices
adb tcpid 2120
adb connect 192.168.1.21:2120
adb disconnect
adb kill-server
adb usb