How to control your Android phone with a broken screen from adb
A few days ago I dropped my Nexus 4 on a parking lot. A few cracks in the screen and unfortunately I only was able to control the lower left quarter of the screen. Fortunately USB debugging was enabled (when it’s not, stop reading, this article won’t help you) and I was able to control my phone. All I needed was a factory reset so I’m able to sell my phone to someone who’s willing to pay for a screen repair.
I assume you have adb installed (there are enough guides on the interwebs on how to do this).
To control the phone you need the coordinates of the screen. I have a Nexus 4 with a resolution of 1280×768. 1280 pixels is about 10.2 centimeters (yes, you need an old skool ruler to control your phone).
Ok, here we go!
To see what commands you are able to execute from your terminal run
adb shell input
Our first action is to swipe from the top of the screen about 1.6 centimers down. 1.6 centimers is 1.6/10.2*1280~=200px The upper left corner is 0,0.
Run the following command from you terminal:
adb shell input touchscreen swipe 0 1 0 200
This wil swipe 200 pixels down.
Next step is to tap the settings button, located in the upper right corner
adb shell input touchscreen tap 758 15
I think you get the idea from here on. I was able to control a little part of my screen so you have to figure out all the remaining coordinates+actions on your own.
Good luck an be more careful with your phone next time 😉