Categories
Technical

Sending input events over adb

Adding a device driver to the linux kernel for android opens up a whole pandora’s box of issues that are related to building the driver and then integrating it into the whole android infrastructure.

I have always tried to take the shortcut approach of getting a build from one of the board manufacturers, and then using it as it is and make the minimal modifications that I need.

Some of the tips I have found along the way…

Sending a keystroke over ADB

A lot of times the screen will turn off on the dev board I am using and I cannot see what is on the screen. Some cool ways to turn on the screen are at…

http://stackoverflow.com/questions/14772619/wake-up-android-with-use-adb-or-eclipse-just-before-debug

If you dont want to read through a link, here is the quick summary…

adb shell input keyevent KEYCODE_POWER

Somtimes KEYCODE_MENU is better because it will also unlock the screen.

This helps a lot when you have a headless board and dont have a mouse handy to wake up the board. But it brings up to the next issue, how do I unlock the screen.

http://stackoverflow.com/questions/29072501/how-to-unlock-android-phone-through-adb

and again, the quick summary…

adb shell input keyevent 26 #Pressing the lock button
adb shell input touchscreen swipe 930 880 930 380 #Swipe UP

This one assumes that you only have a swipe turned on as it is by default in most android builds. If you are crazy enough to set a passcode…read the link.

If you want to tap somewhere on the screen…

adb shell input tap 500 1450

If you want more info on the types of events…

http://stackoverflow.com/questions/7789826/adb-shell-input-events

In case you want more information on the types of input events…

https://developer.android.com/guide/topics/ui/ui-events.html

Leave a comment