Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android - Enable ADB from recovery

Android - Enable ADB from recovery

Credits to @TheOnlyAnil-@Firelord^stackoverflow

  • Requirements: a) stock recovery + rooted phone b) custom recovery

  • Files changed:

    • /system/build.prop
    • /data/property/persist.sys.usb.config
    • /data/misc/adb/adb_keys

Enable ADB (1/2): enable USB debugging

same as "Settings >> Developer Opcions >> USB debugging" ON

  • Connect the device to Mac or PC in recovery mode.
  • Now open terminal/CMD in computer and go to platform-tools/. type and enter adb devices to check if the device is connected in recovery mode.
  • Now type adb shell mount data and adb shell mount system to mount the respective directories.
  • Get the persist.sys.usb.config file in your system using adb pull /data/property/persist.sys.usb.config /Your directory
  • Now open that file in a texteditor and edit it to mtp,adb and save.
  • Now push the file back in the device; adb push /your-directory/persist.sys.usb.config /data/property
  • Get the build.prop file; adb pull /system/build.prop /your-directory
  • Add these lines:
persist.service.adb.enable=1                                                    
persist.service.debuggable=1
persist.sys.usb.config=mtp,adb
  • Push build.prop back into the device; adb push /your-dir/build.prop /system/

Fast way

adb shell
mount data
echo -n 'mtp,adb' > /data/property/persist.sys.usb.config

Verify options are not present before do it: adb shell "grep 'persist.service.adb.enable' /system/build.prop"

adb shell
mount system
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 

Enable ADB (2/2): RSA verification

For the RSA verification that you asked to bypass, I don't know whether it would work in your device, but it worked in my little experiment. In Lollipop, the ADB keys (after authorization) are saved in /data/misc/adb/adb_keys. Your private key is saved in computer. In Linux the directory location is $HOME/.android/. On Windows that usually translates to %USERPROFILE%.android, but keys might end up in C:\Windows\System32\config\systemprofile.android in some cases.

adb push ~/.android/adbkey.pub /data/misc/adb/adb_keys

Bibliography

@RaghavanSanthanam

This comment has been minimized.

Copy link

commented May 3, 2018

The last RSA key step helped in my case to get rid of the "draw over apps" specific issue with "Because an app is obscuring a permissions request, Settings cannot verify your response.” that was happening when I was pressing on "OK" when prompted for USB device authorizations. I had to this manual RSA-push via recovery since none of the other approaches worked(changed ROMs, cleared cache, uninstalled the suspected apps, etc, but couldn't find the offending app) - I disabled "draw over app" for all the apps under "special acces..." in app/settings. By the way, I am using Resurrection Remix ROM for my Nexus 5. Thanks and cheers.

@fahadysf

This comment has been minimized.

Copy link

commented Jul 29, 2018

This isn't quite working on Oreo 8.1 (MIUI 10 ROM). Any idea what could be missing?

@TonyStark

This comment has been minimized.

Copy link

commented Jul 29, 2018

not work on miui rom
i run adb device while boot, it print device serial code and said unauthorised

@rbertoche

This comment has been minimized.

Copy link

commented Feb 1, 2019

That's very useful, and it did work on Lineage-16, thank you!

@attila-lendvai

This comment has been minimized.

Copy link

commented Jun 19, 2019

my recovery doesn't have ADB. is there a way to put this into an update.zip?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.