To enable adb debuging from recovery (TWRP
):
adb shell
# Data related changes
twrp mount data
mkdir /data/property
echo -n 'mtp,adb' > /data/property/persist.sys.usb.config
# System related changes
twrp remountrw system
# This next command should return empty
grep 'persist.service.adb.enable' /system/build.prop
echo '' >> /system/build.prop
echo '# Enable ADB' >> /system/build.prop
echo 'persist.service.adb.enable=1' >> /system/build.prop
echo 'persist.service.debuggable=1' >> /system/build.prop
echo 'persist.sys.usb.config=mtp,adb' >> /system/build.prop
Generate the public key and push it to device:
adb pubkey ~/.android/adbkey > ~/.android/adbkey.pub
adb push ~/.android/adbkey.pub /data/misc/adb/adb_keys
adb shell chmod 766 /data/misc/adb/adb_keys
sudo cp /lib/udev/rules.d/51-android.rules /etc/udev/rules.d/
TWRP cmdline commands: https://twrp.me/faq/openrecoveryscript.html
https://stackoverflow.com/questions/8708886/connecting-to-wifi-using-adb-shell
New