22

I own a Samsung Galaxy S3 and the display is broken and USB debugging is set to off too.

How can I enable it using ./adb commands? I have done these steps already:

  • data/data/com.android.providers.settings/databases/settings.db changed adb_enabled value from 0 to 1.
  • Also edited build.prop in /system.

After doing all this, the phone seems bricked, it's not turning on. All I want to do is enable USB debugging and connect it to Vysor(beta) so I could control it on my computer.

Firelord
  • 25,084
  • 20
  • 124
  • 286
TheOnlyAnil
  • 547
  • 1
  • 3
  • 13
  • 1
    Welcome! Good question. +1. Why do you want to remote-control the phone though? – unforgettableidSupportsMonica Aug 26 '15 at 23:35
  • Thanks...Because the screen is broken and I want to browse the data in it. Though I figured it out last night... :) – TheOnlyAnil Aug 27 '15 at 09:04
  • The proper way of enabling USB debugging would be to unpack the boot.img, edit init.rc (enable adb, then disable RSA verificaton), repack boot.img, and boot boot.img without flashing. Once edit has been confirmed working, then flash boot.img to the device. – HasH_BrowN Mar 05 '16 at 15:07
  • Hello, i just want share a Magisk Module to bypass adb, check this https://github.com/lexavey/Adb-Root-Enabler – Anas Jul 28 '23 at 20:15

2 Answers2

18

I got it to work :)

NOTE: This requires unlocked bootloader.

  • Connect the device to Mac or PC in recovery mode. (I had to map the process in my mind as the screen was broken).
  • 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/

This way you enabled USB debugging on your device. But you still can't connect. Why? Because it asks for RSA verification. If you could view your display then you could easily tap on YES to authorize the device. I am currently figuring out to bypass this. I want to revive my dead phone badly. If you know any way to do this, please share :)

TheOnlyAnil
  • 547
  • 1
  • 3
  • 13
  • Are you running a custom Recovery? – Firelord Aug 27 '15 at 11:20
  • No. Stock recovery it is. – TheOnlyAnil Aug 27 '15 at 11:26
  • 1
    About the RSA confirmation part by user, if you're booted into Android OS, and are confirmed somehow that the screen is displaying a dialog for confirmation then you may very well use adb shell input keyevent to choose YES. See Keyevent here. It's a shot in the dark but may very well be worth firing. – Firelord Aug 27 '15 at 11:31
  • @Firelord I tried to do that. But it said authorization error. Looks like I have to authorize it first then do anything... – TheOnlyAnil Aug 27 '15 at 11:40
  • 1
    Ahh! Sorry for suggesting something that would not work. What was I thinking? If ADB access is not authorized then no way adb shell input would work. Sorry again! I'll see if there is any way to bypass the authorization somehow. – Firelord Aug 27 '15 at 11:42
  • I saw a USB to HDMI cable at a store the other day, which I assume could be used to connect an external display to your device. I suppose, with a USB hub, you could connect that, a mouse, and a keyboard to your device all at once. I also one found instructions to enable an adb connection over Wi-Fi; using all of those together you might have a pretty good shot. – Dan Henderson Aug 27 '15 at 12:01
  • @Firelord, Fundamental misunderstanding here.. How are we issuing adb commands using the stock recovery without adb being enabled? Is this not a chicken and egg problem? I thought USB debugging being enabled was a necessary condition before the adb server would allow connections? At least on my S5, if USB debugging is not enabled then the device does not broadcast its name to remote adb servers. – sherrellbc Oct 22 '15 at 14:27
  • 1
    @sherrellbc, this is one of the exceptional cases where a person has a stock recovery running full-fledged ADB daemon providing shell access. A recovery can have an ADB daemon and can get detected by an ADB client regardless of the state of USB debugging in Android OS. In short, USB debugging matters as long as you're booted into Android OS. Outside it, the setting has no significance. – Firelord Oct 22 '15 at 17:10
  • @Firelord, Yes, of course. I was just not aware of any stock recovery images that provided such access. This otherwise makes sense. Thanks! – sherrellbc Oct 22 '15 at 18:18
  • Please reverse your acceptance of your answer, as it isn't correct. Although you might have edited build.prop, you neglected to include the RSA in your answer. Without compliance through the RSA, you cannot enable USB debugging. Which in turn means that the accepted answer isn't correct. – HasH_BrowN Mar 05 '16 at 15:00
  • Why in my phone not exists this file? remote object '/data/property/persist.sys.usb.config' does not exist – Lai32290 Mar 21 '16 at 01:30
5

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. (Source)

There is a method described here by ashoke which might help out in bypassing the authorization.

However, in my Lollipop, the method varies. I noticed that in my primary and secondary Lollipop ROM the adb_keys had the same key actually. All I did was revoke the authorization from the secondary ROM (file deleted automatically ), disconnected device from PC, copied adb_keys from Primary ROM into secondary ROM, connected the device into PC, and voila! I wasn't asked for that authorization. I double checked the authorization using adb devices and it was all good.

Try the linked answer first. Authorize a different Android phone, copy its keys into your device from Recovery mode and see if it works.

Firelord
  • 25,084
  • 20
  • 124
  • 286
  • Hey thanks. I transferred adb_keys from note 2 to S3 and it worked :) – TheOnlyAnil Aug 27 '15 at 18:13
  • This is the needed info to make the accepted answer correct. Good job. +1 – HasH_BrowN Mar 05 '16 at 15:02
  • 2
    For those running a Unix based OS, adb push ~/.android/adbkey.pub /data/misc/adb/adb_keys works reliably. – Chris Olin Dec 16 '16 at 19:32
  • @ChrisOlin: thank you for your input. But I do suppose that adb should be running in root mode (adb root), otherwise, the user won't be able to directly put a file under /data/misc/. Correct? – Firelord Dec 16 '16 at 21:42
  • Not exactly, but you raise a good question. If you're trying to enable USB debugging through ADB, you'll need to be booted into recovery to accomplish this. Recovery shells (least with TWRP) default to root. If they don't, then yes, the user won't be able to push directly to /data/misc. – Chris Olin Dec 17 '16 at 17:56