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

RaghavanSanthanam 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

fahadysf 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

TonyStark 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

rbertoche 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

attila-lendvai commented Jun 19, 2019

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

@samthelion

This comment has been minimized.

Copy link

samthelion commented Sep 3, 2019

Adding "service.adb.tcp.port=5555" to /system/build.prop enables ADB over Network permanently, which is not a good idea if you use your phone outside trusted networks.

@aiamuzz

This comment has been minimized.

Copy link

aiamuzz commented Sep 3, 2019

Adding "service.adb.tcp.port=5555" to /system/build.prop enables ADB over Network permanently, which is not a good idea if you use your phone outside trusted networks.

@samthelion ... is the "service.adb.tcp.port=5555" for wireless adb or wired ?

@samthelion

This comment has been minimized.

Copy link

samthelion commented Sep 3, 2019

Adding "service.adb.tcp.port=5555" to /system/build.prop enables ADB over Network permanently, which is not a good idea if you use your phone outside trusted networks.

@samthelion ... is the "service.adb.tcp.port=5555" for wireless adb or wired ?

I suppose it is for both, but i've only tested it on wifi...

@aiamuzz

This comment has been minimized.

Copy link

aiamuzz commented Sep 3, 2019

Adding "service.adb.tcp.port=5555" to /system/build.prop enables ADB over Network permanently, which is not a good idea if you use your phone outside trusted networks.

@samthelion ... is the "service.adb.tcp.port=5555" for wireless adb or wired ?

I suppose it is for both, but i've only tested it on wifi...

you mean you've tested it on wireless adb ?
How ?
Can you list out the steps to connect ... what is the IP one would need to connect with the 5555 port ... does one have to check the wifi console to grab the IP ?

@samthelion

This comment has been minimized.

Copy link

samthelion commented Sep 3, 2019

This is what i did:

-After adding "service.adb.tcp.port=5555" to /system/build.prop rebooted my phone, went to Settings/Developer options and swiped up down to ADB over Network, wich is now enabled permanently, and there is the IP address, but i assume you can get it on the console too.
-Next, on the computer, open a terminal and type "adb connect <IP_of_the_Phone:5555>"
-And you should see your device listed when typing "adb devices"

@aiamuzz

This comment has been minimized.

Copy link

aiamuzz commented Sep 3, 2019

@varhub ... thanks your instructions helped me enable adb via recovery

any possibility of adding wifi AP via recovery ?
You see i have newly flashed a custom rom ... and i am unable to access as my device screen isn't working ... the phone however is booting up ... i would like to inject my wifi AP details so the device connects to my wifi network on boot ...

@samthelion

This comment has been minimized.

Copy link

samthelion commented Sep 3, 2019

@varhub ... thanks your instructions helped me enable adb via recovery

any possibility of adding wifi AP via recovery ?
You see i have newly flashed a custom rom ... and i am unable to access as my device screen isn't working ... the phone however is booting up ... i would like to inject my wifi AP details so the device connects to my wifi network on boot ...

Let me tell you that if you already enabled ADB you can use this tool to interact with your phone, and enable wifi AP if you want...

@aiamuzz

This comment has been minimized.

Copy link

aiamuzz commented Sep 3, 2019

@varhub ... thanks your instructions helped me enable adb via recovery
any possibility of adding wifi AP via recovery ?
You see i have newly flashed a custom rom ... and i am unable to access as my device screen isn't working ... the phone however is booting up ... i would like to inject my wifi AP details so the device connects to my wifi network on boot ...

Let me tell you that if you already enabled ADB you can use this tool to interact with your phone, and enable wifi AP if you want...

yup ... i am using that tool already ... but seems the screen problem on my device is not letting me access my phone freely ...

and i wanted to test your wireless adb ... hence i would like to know if there was a way i could push the wifi AP to my device through normal adb(not recovery adb) ... 😄

@samthelion

This comment has been minimized.

Copy link

samthelion commented Sep 4, 2019

@varhub ... thanks your instructions helped me enable adb via recovery
any possibility of adding wifi AP via recovery ?
You see i have newly flashed a custom rom ... and i am unable to access as my device screen isn't working ... the phone however is booting up ... i would like to inject my wifi AP details so the device connects to my wifi network on boot ...

Let me tell you that if you already enabled ADB you can use this tool to interact with your phone, and enable wifi AP if you want...

yup ... i am using that tool already ... but seems the screen problem on my device is not letting me access my phone freely ...

and i wanted to test your wireless adb ... hence i would like to know if there was a way i could push the wifi AP to my device through normal adb(not recovery adb) ... smile

in that case you can try this although you might need different key combinations... wich can be found here

@aiamuzz

This comment has been minimized.

Copy link

aiamuzz commented Sep 4, 2019

in that case you can try this although you might need different key combinations... wich can be found here

thanks ... i managed to connect to my wifi using scrcpy ... took some time as it was laggy due to the screen issues my device had.

This is what i did:

-After adding "service.adb.tcp.port=5555" to /system/build.prop rebooted my phone, went to Settings/Developer options and swiped up down to ADB over Network, wich is now enabled permanently, and there is the IP address, but i assume you can get it on the console too.
-Next, on the computer, open a terminal and type "adb connect <IP_of_the_Phone:5555>"
-And you should see your device listed when typing "adb devices"

thanks @samthelion ... i was able to modify the build.prop and get the device to connect adb over the wireless network ...

@sreekar

This comment has been minimized.

Copy link

sreekar commented Oct 25, 2019

how to set adb vendor keys in redmi 5 plus

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.