Last week I dropped my Nexus 5 once again, this time for good. I had cracked and broken the top glass before, but the display and the touchscreen kept on working. This time, the touchscreen no longer registers touches, though luckily the display still works somewhat. On a device with no trackball, touchpad, or keyboard, a broken touchscreen is problematic.
Unfortunately, I had been lazy about keeping my phone properly backed up. There wasn’t that much unique stuff on it, but I always meant to backup apps and app data, and to eventually root and reflash someday — but never got around to it. Consequently I didn’t have USB debugging turned on, or a computer cleared for debugging.
Generally, the way to control and back up Android devices is from your desktop computer, using a USB connection and software called adb (Android Debug Bridge, see adb docs). However, USB debugging must be first turned on in Android settings, and since Android 4.2.2, the phone asks to confirm debugging access from each computer that attempts to connect. Normally the confirmation is done using the phone touchscreen. Oops.
Here are my notes on what I did to eventually gain USB debugging access. I did not require root or fastboot. I needed a computer to act as the adb host and a few accessories: a USB OTG cable, a USB mouse, and a Bluetooth keyboard.
Learning from my trouble, I recommend people running Android 4.4.3 or higher and interested in maintaining access to their device to enable USB debugging ahead of time.
- Android phone running 4.2 or higher with broken touchscreen (touches are not detected or detected very errantly)
- Phone screen is still somewhat legible (otherwise you will be clicking in the dark – technically possible if you’re very careful, but a lot of logic and guesswork involved)
- USB debugging is not enabled in phone settings
- Your computer has not been previously allowed to access the phone for USB debugging, or at least not with “always allow from this computer” checked
- No Bluetooth input device is paired with the phone
- Phone has no password or lock screen pattern on it (though this should be solvable with a USB mouse)
The root of the problem is that to enable USB debugging you need either a working touchscreen or a pointing-or-typing input device connected to the phone while the phone is also connected to the host computer. With only one connector on the phone, connecting both a USB host computer and a USB mouse requires extra work. My workaround was to pair the phone with a Bluetooth keyboard first.
- A computer running adb host
- A phone capable of USB OTG (most Android phones with Android 4 and up, as I understand)
- A USB OTG cable (a cable that can plug into your phone on one end and give a full-size USB female connector on the other end)
- A USB mouse
- A Bluetooth keyboard (a Bluetooth mouse would also work, but you need the USB mouse first)
- Plug in the mouse into the phone. If your phone supports OTG and its microUSB port works, the mouse is recognized automatically and gives you a pointer on your phone screen
- On the phone, enable developer mode, if not already done
- On the phone, enable USB debugging mode
- On the phone, enable Bluetooth
- Pair the phone with a Bluetooth keyboard (or Bluetooth mouse, or another pointing-or-typing input device)
- Unplug the mouse from the phone
- Plug in the phone into the computer as usual
- Attempt to connect from the computer with adb (
sudo adb devicesworked for me)
- When “allow USB debugging” dialog appears on the phone, use left- and right-arrow keys on the keyboard to highlight “Cancel” or “OK” buttons. Use up-arrow to highlight the “always allow from this computer” checkbox. Use the space key to check the checkbox. Use down-arrow and right-arrow to navigate to “OK” button then use Enter to confirm.
- You should now have access to the phone using adb, even after unplugging and replugging into the computer
- You can now disable Bluetooth on the phone if you wish
Things that didn’t work
I got a USB OTG hub that plugged into the phone and offered three full-size USB female connectors and one microUSB female connector, the latter labelled for charging. I hoped that I could get mouse and computer connected to the phone at the same time. Unfortunately it appears the hub’s microUSB connector is only wired for power, not data, so adb on my computer could not see the phone. Consequently I needed the phone’s microUSB for exclusive use of the connection to the computer. To allow USB debugging, I then also needed a secondary wireless input device, for me it was the Bluetooth keyboard.
I guess it would have worked if I had a full-size USB male-to-male cable so that I could connect my computer to one of the full-size connectors on the hub, but I don’t have such a cable handy.
Things that seem like they would work
I didn’t try these, but based on my understanding they might work:
- A Bluetooth mouse pre-paired with the phone, if Bluetooth was kept enabled on the phone. You can use the mouse as back-up for the touchscreen, so you can proceed as if the touchscreen worked.
- Using a USB OTG cable, a USB hub, a USB mouse, and a USB male-to-male cable (OTG cable and hub can be one accessory). You might then be able to connect a USB mouse and the computer to the phone at the same time. I didn’t test this for lack of male-to-male cable.
- If the phone has already been rooted (you have access to
/data/misc/adb/directory on the phone), you might be able to manually add the computer’s USB debugging key (on Linux in
~/.android/adbkey.pub) into the phone’s registry, which is in
/data/misc/adb/adb_keys. See this post by ashoke and this post by Firelord for some more details.
- There might also be a way to manually add the key using the recovery mode, see this post by kiradotee for instructions. I am not sure if doing it in recovery mode requires root, I didn’t try as I am not experienced with Android recovery modes.
If you are running Android 4.4.3 or higher (there was a security issue in earlier versions), I would suggest enabling USB debugging, plugging the phone into your usual computer and checking “always allow”, and leaving USB debugging turned on. This preparation is much easier to do when your touchscreen is working, and could save you hassle in the future. It’d be especially useful if you also break your display so that it is illegible – with USB debugging pre-cleared, you can still easily get into your device and offload data.