Resurecting a broken Android phone as a development sandbox for app development.

I had the unfortunate incident of cracking the screen on my fairly new Galaxy S5. Since most of the phone worked, I wanted to get all of my old data off, on to my new phone, and finally re-purpose the old phone as a development sandbox which I can dedicate to Android app development. Exactly which steps you’ll need to go through will depend on the functionality remaining in your device, what settings you’ve enabled, and the tools you have at hand. This details the method I used, which is possibly one of the worst case scenario that can happen, so you can probably use some of this info even if you aren’t in quite as bad of a situation.

My Situation

In my case, the screen was completely broken, it would not display information nor register touches. I had also not enabled developer options, and had a lock screen swipe pattern set. Fortunately, the new phone I bought was exactly the same as the old one, this allowed me to see what the screen would look like without being able to see the screen of my old phone. This was important for counting keystrokes needed to perform tasks in the blind, as well as tracing out the pattern for the lock screen. I had not yet paired the phone with any Bluetooth devices like a keyboard or mouse, nor had I rooted my phone.

Features that made it possible

The Galaxy S5, and many other phones have the build in ability to use a mouse, keyboard, and display through the USB port on the phone. You will need a USB host cable (apparently also called USB-to-go cable) to plug in a mouse and keyboard, you will also need an HDMI adapter for your phone to display the screen on an external monitor.

The Ultimate Goal

The bad thing is that you can’t have a mouse, keyboard, computer, and the display hooked up at the same time, and you need all of these to develop apps in a normal manner. Here is a small overview of the steps:

  • Unlock the phone completely in the blind
  • Pair the phone with a Bluetooth keyboard and mouse
  • Enable developer options
  • Disable the lock screen
  • Backup phone
  • Root the phone
  • Set up the phone to install APKs over the air

Unlocking the phone

This was undoubtedly the hardest part. There were many claims of being able to unlock the phone through USB hooked up to the computer, but required a rooted phone. If you have a password set rather than a swipe pattern, you can simply plug a USB keyboard into your phone using a USB Host Cable, type in your password, press Enter, and be done with it.

With a swipe pattern, it’s far more difficult as you need to know where the mouse pointer is, and if you attempt to swap between the mouse and HDMI display the pattern times out and resets, so the only way to do this is completely in the blind. What I did was set the same unlock pattern on my new phone, then taped a piece of paper to my desk, taped a pencil to my mouse, and traced out the pattern on the sheet of paper. After plugging in the mouse, I moved it to the lower left corner, to ensure I had a home location to start the pattern from, I then traced a line to where my pattern started, clicked the button and traced out the pattern. I then plugged the mouse into my new phone and retraced over the same line to unlock the phone. It is important to keep the mouse in a common orientation as well as trace the line, because if you rotate the mouse with your wrist, it won’t actually be moving in the same direction. For this I visually kept the side of the mouse square with the sheet of paper. It took me a good 15-20 minutes to finally unlock my phone. When it unlocks, it will play a sound, so there’s no need to keep switching back to the HDMI display to see if it worked.

Paring with a Bluetooth Keyboard and Mouse

After you have the phone unlocked, you can switch between the HDMI display, keyboard, and mouse to see where the cursor is and what’s on the display. In my case, I did not have a real Bluetooth mouse, the regular wireless mice work only with their specific dongle, and although you can use them as a mouse with the dongle plugged in, you cannot register them as a Bluetooth mouse. I did have a Bluetooth keyboard available, and fortunately this was enough to navigate around and take care of most of the work. You can move around the screen and select icons using the arrow keys, and in most apps you can use the arrow keys to select most fields, but in some cases the app only works with mouse clicks.

I never figured out how to get the menu to pull down with just they keyboard, but I was able to access the settings by navigating around with the arrow keys to select the “All Apps” from my quick launch, from there I made my way to the settings icon and managed to pair my Bluetooth keyboard. This was all done over the course of 10-15 minutes of swapping out the USB keyboard with the USB HDMI display and seeing where the cursor was and where it needed to go.

Enabling Developer Options

Once you have a Bluetooth keyboard attached, it’s fairly easy to navigate to the settings an enable the developer options (on the Galaxy S5 that’s done by going to “About” in the phone settings and clicking on the build number 10 times). But when you actually plug it into the computer, you’ll be prompted to give the computer permissions, and this prompt goes away if you try to unplug it from the computer and plug in the HDMI display. This issue was solved for me by following the same steps on my new phone, from there I was able to determine that to accept the prompt using the Bluetooth keyboard I just needed to click the down arrow once and the right arrow twice, then press enter.

Disable the lock screen

Without a Bluetooth mouse, I did not bother attempting to disable the lock screen. You have to draw the lock pattern again to disable the lock screen, and it does not play a sound when you do it correctly, making it a very time consuming process. The pattern is also slightly different on the disable screen than on the real lock screen which meant I’d have to trace out a new pattern again, making it take even longer. So, instead I went into the developer options and enabled the “Stay Awake” option which causes the phone to not re-lock while it’s charging. This was able to hold me over until I came across a Bluetooth mouse. An actual Bluetooth mouse is kinda hard to find, I finally found a combination small keyboard and touch pad at Best Buy near the tablet Bluetooth keyboards, after pairing that, I was able to use it as a mouse to disable the lock screen permanently.

Back up the phone and restore it to my new one

This was a lot harder than it should be. There is a backup service built into Android, but it is far from reliable, on my new phone only about 10 apps out of the hundreds were actually restored, and about only 5 of my contacts. If you try to search around, you’ll see a lot of very sketchy apps, and some legitimate ones that require root. The one that finally worked for me, not requiring root, was Helium. It does require that developer options are turned on. But it was able to back up and restore all of my apps and data except two of them which deliberately blocked being backed up.

Rooting the phone

I generally do not like to root my phones. I prefer that when I develop an app, that I can test it in a very similar environment that will be used by all of my customers, and I’ve never found a particularly good reason to do so anyway, at least until now. In order to install applications over the air, that is with the HDMI cable plugged in rather than plugged in to the computer, you’ll require a rooted phone. I was a bit concerned about having to do any work in the blind during the root process, but it went off without a hitch just following the “normal” instructions found pretty much everywhere.

Another option that might not require root is to connect the phone to the computer by USB and echo the screen to the PC. But this likely has performance issues, and the apps I have seen as of this writing either require root or don’t appear very mature.

Setting up the phone to receive APKs wirelessly

I used “ADB Wireless” from the play store for this. You run the app on a rooted phone, then you run “adb connect 192.168.0.1” from your PC. From then on, the remote phone appears just like a directly connected one, which you can verify using the command “adb devices”.

Leave a Reply