Reputation: 2134
I use the command adb shell su -- getevent -lt /dev/input/event5 > Test.txt
to log the touch event. It works when I touch the screen, i.e, it writes all actions (key down, key move and key up with the coordinates).
But, when I use the command adb shell input tap x y
to simulate the touch, even if the device get the event (for example, the app is opened) but in the log file, there is no log lines about this tap.
How can I log the simulate the key event touch with adb
?
Upvotes: 4
Views: 12238
Reputation: 5964
adb shell dumpsys input | grep -A 10 RecentQueue:
Shows the last 10 key press events, this is particularly useful on Android TV.
Example output:
RecentQueue: length=10
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000001, age=235389ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=235239ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000001, age=235134ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=234984ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000001, age=234894ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=234744ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000001, age=234654ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=234564ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000001, age=234444ms
KeyEvent(deviceId=7, source=0x00000301, displayId=-1, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=234339ms
Consider that each button press consists of a DOWN event and an UP event so these 10 events represent only 5 actual button presses.
Upvotes: 0
Reputation: 31686
The reason for you not being to see your input tap
events in the getevent
output is that sendevent
and getevent
work with Linux kernel input events and input
command injects the events directly into the Android input event queue.
This (old but still useful) article has some nice diagrams illustrating the input event propagation in Android.
Unfortunately there is no easy (ready to use) way to do what you asked for. The closest thing I could think of is using dumpsys input
command - it shows last 10 input events (including ones injected by the input
command) in the RecentQueue: section.
Upvotes: 5