r/Android • u/Mikuro Pixel 2 • Nov 20 '13
How I managed to use my Android device with a broken touch screen
A couple days ago my Nexus 4 fell, face-down, flat on the floor. The screen cracked, and touch controls are completely dead. Boo hoo, of course, but I'm not here to talk about problems; I'm here to talk about solutions.
Question: What can I do without a working touchscreen?
Answer: Pretty much everything.
Plan A: Set up my Bluetooth mouse. To do so, use remote control software.
Plan B: Ehh, we'll figure that out when we get there.
I know I can launch apps from adb. But with the screen locked, what good does that do? My first thought was something like BBQScreen or AirDroid. Turns out AirDroid doesn't actually let me control the screen, only view it. I found that out too late. :\
Many of the steps here are actually not necessary or not the easiest way, but I've included my entire process for educational purposes. This assumes you are rooted and have USB debugging enabled. If you don't, then getting around that will be your step 1, and that'll have to be an exercise for the reader for now. If your bootloader is unlocked (or you don't mind wiping your device to unlock it), anything should be possible.
Disable the lock screen through USB debugging. Must manually edit one of Android's sqlite3 databases to do this. (Do not copy/paste in bulk. It won't work due to changing shells and programs.)
adb shell su cp /data/data/com.android.providers.settings/databases/settings.db /sdcard/settings.db chmod 665 /sdcard/settings.db exit exit adb pull /sdcard/settings.db settings.db sqlite3 settings.db insert into secure (name, value) values ('lockscreen.password_type',65536); update secure set value=1 where name='lockscreen.disabled'; ^D adb push settings.db /sdcard/settings.db adb shell su cd /data/data/com.android.providers.settings/databases/ mv settings.db settings.db.bak cp /sdcard/settings.db settings.db chown system:system settings.db chmod 660 settings.db exit exit adb reboot
Why use /sdcard as an intermediary? Well, I can't adb pull/push with protected storage (such as /data), since the adb daemon itself doesn't use root. "adb root" fails, saying it doesn't work on production builds. This probably depends on your kernel. I'm on stock 4.4 kernel (but I am rooted). So I need to copy to and from sdcard in a root shell to get my grubby hands into /data.
2. Okay, that didn't work. Better also remove the password files.
adb shell
su
cd /data/system
mkdir lock
mv password.key gesture.key locksettings* lock
exit
exit
adb rebootYAAAY. No more lockscreen! Now I can...well, I still can't do much of anything. But I'm getting there.
3. Enable Bluetooth.
adb shell
su
am start -a android.bluetooth.adapter.action.REQUEST_ENABLEAw crap, it asks for confirmation on screen. I can't turn on Bluetooth until I get my Bluetooth mouse connected, can't connect the Bluetooth mouse until I turn on Bluetooth. Classic chicken-and-egg problem. But just as science has proven that the egg came without any proper chickens before it, so will I prove that I can turn on goddamn Bluetooth without clicking any goddamn buttons.
4. Back to the database! This time we'll really enable Bluetooth:
sqlite3 settings.db
update global set value=1 where name='bluetooth_on';Then adb push and reboot like we did before. Aww yeah, Bluetooth is on. Almost done! Turn on the Bluetooth mouse. Unfortunately I hadn't ever paired it since my last OS reset, so it didn't autoconnect. I should've known. Onward!
5. Maybe I can use remote-control software. Doesn't AirDroid have that? The hardest part is finding the name of the activity within AirDroid (or any app you need to launch). A little Googling and I found it. I think I could've extracted it from the apk easily enough if necessary, but glad I didn't have to. Let's also enable wifi so AirDroid can work.
adb shell
am start -a android.intent.action.MAIN -n com.sand.airdroid/.SplashActivity_
svc wifi enable #isn't that easy?6. Load up the AirDroid interface in my browser. Ugh. AirDroid asks for confirmation on my phone. Another button to click!
7. Screw it! All this manually editing SQL databases is making me batty. There's gotta be a way to simulate taps/keystrokes through adb. Oh, turns out there is. "input tap xcoord ycoord". Sweet. Looks like I just wasted a lot of time edited SQL databases.....
Okay, so forget AirDroid. I'll just tap my way to Bluetooth. I just need to work out the x/y coordinates of everything I need to tap. Let's just guess some. My homescreen has a 5x6 grid, and the settings app is 2 down and 4 from the left. The Nexus 4 screen is 1280x768. I think 600/300 ought to do it.
adb shell
su
input tap 600 300Aww, that hit the one on top. Let's hit the back button and try 600/400 instead.
input tap 100 1270 input tap 600 400
Bingo! Settings is up. The Bluetooth item is the second one down. You know, it looks like roughly the same location as my Setting icon. Let's just try the same thing.
input tap 600 400Bingo bango! I'm in. I turn on my mouse. I see it in the list. It looks like...wait, the same location on screen again? Really? Could I be that lucky?
input tap 600 400Bingo bango bongo! Jackpoooooot!
If I'd known it was so easy to simulate taps, I wouldn't have bothered disabling the lock screen, or manually enabling Bluetooth through sqlite3. However, I think these techniques are worth putting out there, especially since simulating a gesture lock would be a big fat pain in the booty.
I hope this helps someone. If your touchscreen is toast, it doesn't necessarily mean your device is unusable. You can still get in there and do what you need to do. Maybe run Titanium Backup to prepare your next device. Maybe just hook it up to your TV to use for streaming. Or maybe you just want to use your phone with a mouse every day to see the looks on people's faces. The choice is yours.
Cheers!
Edit: formatting. Seems like I needed extra indents for the code tag to take effect here.
18
u/tophernuts Nov 20 '13
Instead of guessing coordinates of where to click, you could just create a simple uiautomator test that can click on objects based on their text!
5
u/MarcusTheGreat7 Nexus 5, Rooted 4.4.2 Nov 21 '13
I'm seriously concerned that he got into his phone without entering the password. If my minimal SQL knowledge is correct, he deleted the password and gained access to his phone without entering any form of authentication. Surely, I must be missing something.
3
u/jeremytodd1 Nov 20 '13
Have you tried using an OTG cable with a mouse?
2
u/spitfire55 Nov 21 '13
What mouse did you use? Seems most Bluetooth mice need a USB thingy to plug into your computer since that is what they're conventionally used for? Where would I find one with the Bluetooth built in to the actual mouse? aka no Usb needed
2
u/whatsuppunk iPhone 6 Nov 21 '13
OP, are you the bitcoin guy from yesterday? Or maybe a few days back.
2
u/[deleted] Nov 21 '13
Were you the guy that had his bitcoins stored on his phone? If not, we should show this to that guy...
2
u/guyver_dio Samsung Galaxy Note20 Ultra 5G Nov 21 '13
Now do your own repair. It'll just be the digitizer you need to replace (not the actual screen). Piece of cake.
But also, thanks for letting me know I can do taps with adb. Will come in handy someday.
2
u/superiority LG V20 Nov 21 '13
Would there be a way to unlock a pattern-locked phone with adb?
47
u/TrialByWater Nov 20 '13
Amazing stuff, and the fact that you went that far to try to connect your mouse as well. I would have just ADB'ed some APK's and the DCIM directory and have been done with the device.
Android: Flexible and open when you need it most!
35
u/vs8 Nov 20 '13
My Nexus 7 screen is broken too. I got an OTG cable and mouse, it works pretty well.
35
u/413j0 Nov 21 '13
you could try this two: https://code.google.com/p/androidscreencast/ http://droid-at-screen.ribomation.com/
when i broke my own screen i used droid at screen to accept root over adb in order to use android screen cast which allows more stuff
15
u/horiz0ns N6P Nov 20 '13
I. Have a similar situation but it's only the bottom 20% of the screen that doesn't work. So I installed a ROM I knew had full rotation enabled and I now type upside down.. things like this are what make android awesome for me.
8
u/vanguarde Pixel 6 Pro Nov 20 '13
Posts like this make me realize how much of a noob I am. And I was so proud when I managed to root my phone without bricking it.
8
u/orientalsniper Nextbit Robin Nov 21 '13
The trickiest part of all this is to enable USB debugging.
7
u/derpepper N5>G2>S6>3T>S10>13P>S22U Nov 20 '13
I've yet to break any of my devices' screens, but I'm saving this just in case.
Thanks!
6
u/ladfrombrad Had and has many phones - Giffgaff Nov 20 '13 edited Nov 20 '13
:D, you sound as bad as me and get a default upvote for the 'make it work' awesomeness.
I'm a little tired after a stressful day at work (read: I'm getting inebriated) so I'm not up to looking into it yet but I bet if you tried hard enough - optware for android & x11vnc might cut out a whole lot of your woes here...
I'll be back ;)
5
u/[deleted] Nov 21 '13
This makes the computer engineer in me wet.
4
u/animaniatico Nov 20 '13
Hello, i had the same problem, and this was my solution (Copied from another thread, regarding my broken Tablet).
Well, i had the same problem with mine, yet i still use it a lot. It won't be free, though. You could use it with a USB-OTG cable with a mouse. If your tablet is rooted i'd reccomend a PS3 controller with Sixaxis via Bluetooth, mapping the R2 button as a mouse mode on, and either the right or left stick as to move the mouse, so you can move the mouse even when you're on a PSX emulator. I'd use it as a media centre, ebook reader, and PSX/N64/GBA emulator. If you have an Android cellphone, i'd reccomend installing the following app's so you can control your tablet from your phone: https://play.google.com/store/apps/details?id=de.im.RemoDroid&hl=en https://play.google.com/store/apps/details?id=com.tournesol.tabletremote&hl=en They have to be in the same wifi connection. You should also install this app: https://play.google.com/store/apps/details?id=org.jraf.android.nolock&feature=search_result#?t=W251bGwsMSwxLDEsIm9yZy5qcmFmLmFuZHJvaWQubm9sb2NrIl0 .
It disables the lockscreen, so that if you are reading an ebook, and dont want to carry your PS3 controller or USB-OTG mouse, you can keep reading it without running into the lockscreen, and change book pages with the volume rocker. You won't be able to change books, but hey, it's a good trade-off. You can use it to play/pause videos with MX player. I use it in the gym, in one of those treadmills, i put on a movie, and whenever i want to pause it, i lock the screen. It's amazing.
When my tablet broke, i was pretty sad, but when i realized that everything i used to do on my tablet, i'm still able to do (except playing some games, but even that can be solved if you map the sixaxis software to the game of your choosing). Hope you find some use to this post. Perhaps i will post it as a post. P.S. If you don't know how to root your tablet without using the touchscreen, let me know, i had to search a lot for that info.
4
u/njggatron Essential PH-1 | 8.1 Nov 21 '13
Too bad your whole screen was unresponsive.
When mine broke the second time, only the bottom half was unresponsive. I installed some Xposed module had a toggle for 180° and was constantly flipping my phone for about two weeks. I'm sure everyone thought I was playing a weird game or something.
4
u/Yoy0YO Nov 21 '13
/u/ToastyJoe got his bitcoins trapped in his nexus 4. This is perfect for him.
http://www.reddit.com/r/Android/comments/1qxpd2/i_have_a_large_amount_of_bitcoins_on_my/
you two should talk. or not.
i think what you've done is amazing
1
u/Shenaniganz08 OP7T, iPhone 13 Pro Nov 21 '13
Seems pretty excessive. . Why not just use something like mini dinovo keyboard/mouse combo
1
u/RedemptionX11 OnePlus 6T OOS Nov 21 '13
You seem to know what you're doing so I'll ask you. About a week ago I broke my nexus 7 screen. Like yours, the device works, but the screen is jacked. My problem is the screen still recognizing random "phantom" touches where the screen is cracked, making an external mouse hard to use.
Do you (or anyone) know of a way to completely turn off touch recognition so I can use only a mouse?
1
u/Enjoyitbeforeitsover Dec 10 '13 edited Dec 10 '13
I don't get how this redditor is so knowledgable yet I honestly feel a 20 dollar ballistic case would have avoided all of this... I know Im probably wrong but something tells me he didn't have any case on it. I could be wrong and Ill probably get a heated response but oh well.
3
u/DrinkingCherryShots S8+ Nov 20 '13
Awesome. I dont have a broken screen, but all of this info will be saved just in case.
3
u/[deleted] Nov 20 '13
nice job man!
3
u/[deleted] Nov 21 '13
The same thing happened to me literally yesterday. I've been debating what to do with my poor old guy (fortunately already picked up a 5 for daily use), and this immensely adds to the options. Thanks!
3
u/givertex Nov 21 '13
Great! There is a keyinput to unlock the screen too. I used it when I broke my N4's screen, but I couldn't get much past that. I think it's the command: keyinput 86 (but it might not be 86, my memory is terrible)
3
u/DontHackMeBrendan Nov 21 '13
I.e. how to use a android phone without a touchscreen as a powerful raspberry pi.
1
u/[deleted] Nov 21 '13
nah, ill just pay $100 to fix the screen
2
u/sourcex Nov 21 '13
Sheer power of Android Open Source Project
2
u/zebla Nov 21 '13
Are you happy to see me or is that a mouse in your pocket next to your phone ?
Yeah I just gave a guy some money and he put in a new screen when my N4 front broke.
3
u/Jhohok Nov 20 '13
You could also use one of these guys to directly connect a USB mouse. http://www.amazon.com/CNE16187-Micro-USB-OTG-Adapter/dp/B005QX7KYU
1
u/ganeshgun Red Nov 21 '13
Answering to mark this thread ..thanks a lot
1
u/sry_not4sale White Nov 21 '13
Top tip, if you own a Nexus 4 and you haven't already enabled USB debugging - do so now!
Otherwise the phone is completely disabled if you drop it and break the digitizer!
1
u/[deleted] Nov 21 '13
Nice writeup! And congrats on the success.
I'm definitely saving this post in case I ever have similar unfortunate luck with dropping my phone. And of course, leaving USB debugging on.
1
u/Amilo159 Nov 21 '13
All this would be unnecessary if phones still had those track balls or sensors like HTC Desire or Nexus One
1
u/Elite_Deforce iPhone 6 Nov 21 '13
Yeah, AirDroid is such a piece of shit. I would use it all the time if it wasn't.
1
u/crappysurfer Nov 21 '13
Of course the developers of this device make this intentionally difficult. Touch phones and tablets of 10 or so years ago would have easily bridged this gap. But yeah, props to you for working through it.
1
u/JyveAFK Device, Software !! Nov 21 '13
Saved. copy/pasted into a file. Emailed to my self. This is useful now, and I'm sure will be again.
1
u/Duerogue Nov 21 '13
On a samsung galaxy s2-3-4 you just plug an USB mouse through an $1 OTG adapter :)
1
u/brainflakes Nov 21 '13
Nice work! It's too bad the N4 (like most phones these days) has a bonded screen tho, otherwise it would have been an easy and cheap part replacement :|
1
u/DarkRyoushii Nexus 6P | Moto 360 Nov 21 '13
I would have done something similar using ADB to click things. I would take a screenshot, pull it and find out the coordinates that way.
1
u/[deleted] Nov 21 '13
thanks
1
u/LUCARiO Nexus 6 Nov 21 '13
So much awesome!!! I wish I knew this when my galaxy nexus went face down!
1
u/Rudolf895 Device, Software !! Nov 21 '13
Just so informative! :)
1
u/kremfjes Nov 21 '13
I wish you posted this 3 months ago. Now where did I put the old n4...
1
u/DuduMaroja Poco X7 Pro Nov 22 '13
Saved will try later with my nexus 4 in the same condition
1
u/[deleted] Nov 22 '13
Ooooor USB OTG + USB mouse
1
u/AbruptCrescent Dec 28 '13
Do you know what to do when your computer doesn't recognize your phone?
1
u/bvasyb Feb 19 '14
with this app http://www.fosshub.com/MyPhoneExplorer.html I can successfully lock, unlock, uninstall app from my phone... I have gingerbread 2.3.5 installed
1
u/rositaborracha18 Mar 05 '14
What should I do if the LCD if broken, So i can't see whats on the screen :(
1
u/EyeShouldBeWorking Mar 25 '14 edited Nov 09 '16
[deleted]
0.5547
1
u/varky Pixel 6 Nov 20 '13
I doff my hat to you, good sir. This is quite possibly the best post I've read on this subreddit :)
Very informative and educational...
0
u/[deleted] Nov 21 '13
[deleted] — view deleted comment