0

I have a rooted n4 with USB debugging enabled. The touchscreen is smashed, totally. There is an image on the screen, but it is not possible to enter any commands via the touchscreen. The device otherwise works normally. I can see what's on the screen, it connects to the wifi, etc.

So, for example Ritesh SMS backup won't work, because it needs me to tap commands on the phone. I tried the following solution https://stackoverflow.com/questions/12266374/backup-full-sms-mms-contents-via-adb

but it won't work because the phone pops up saying 'do you want to give adb shell su permissions', I can't tap yes as I can't tap anything...

  • 2
    You can use keyevents to execute the desired touch on the screen. ADB Shell Input Events. Alternatively, if the device supports OTG then you can buy an OTG cable, and then use a standard mouse to execute touches on screen. – Firelord Sep 16 '15 at 23:51
  • Thanks, that led me in the right direction: I was able to make adb shell; then input tap xxxx yyyy work for me. – Ne Mo Sep 17 '15 at 9:51
0

Note for Non-Nexus 4 users: if your device supports OTG, buy an OTG cable (comes very cheap) connect a standard PC mouse and the device to it and use the mouse to navigate the device.


Since the USB debugging is enabled and authorized, you can make good use of KeyEvents. Use input command to simulate up, down, left, and right navigational turns and enter.

Command:

adb shell input keyevent KEYCODE          # adb shell input: give further options

Examples:

adb shell input keyevent 22                # navigates one block rightward
adb shell input keyevent KEYCODE_DPAD_DOWN # navigates one block downward
adb shell input keyevent DPAD_LEFT         # navigates one block leftward

Relevant key codes:

19 -->  "KEYCODE_DPAD_UP" 
20 -->  "KEYCODE_DPAD_DOWN" 
21 -->  "KEYCODE_DPAD_LEFT" 
22 -->  "KEYCODE_DPAD_RIGHT"
23 -->  "KEYCODE_DPAD_CENTER"

(See more key codes here - by Rene Barbosa)

To simulate ENTER, use key code 66. 23 works too.

Use the key codes in combination. For example, when SuperSU app asks me to allow or deny root privileges to an app, I use the key codes 19, 20, 22 and 66 to simulate a tap on OK.


You can always use adb shell input tap X Y but you need the correct X and Y coordinates for the tap. You'll have to enable Pointer location under Developer settings as first step. Since the touchscreen is not working, finding the right coordinates is a hit and miss here. You would succeed with trial and error, should you choose this method.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.