Add key event label to Entry dump
When examining bugreports, it is inconvenient to have to look up
keycodes at the KeyEvent.java file or online in the documentation. When
checking the recent queue, it's nice to just have a printed value of a
specific key event.
Add KeyEvent::getLabel to the entry dump for KeyEntry.
Bug: 181096406
Test: press volume keys and then `adb shell dumpsys input`
Observe:
RecentQueue: length=10
FocusEvent(hasFocus=false), age=14108ms
FocusEvent(hasFocus=true), age=14099ms
FocusEvent(hasFocus=false), age=14079ms
FocusEvent(hasFocus=true), age=11936ms
KeyEvent(deviceId=3, eventTime=477682467000, source=0x00000101, displayId=-1, action=DOWN, flags=0x00000008, keyCode=VOLUME_DOWN(25), scanCode=114, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=4160ms
KeyEvent(deviceId=3, eventTime=477826780000, source=0x00000101, displayId=-1, action=UP, flags=0x00000008, keyCode=VOLUME_DOWN(25), scanCode=114, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=4015ms
KeyEvent(deviceId=3, eventTime=479897187000, source=0x00000101, displayId=-1, action=DOWN, flags=0x00000008, keyCode=VOLUME_DOWN(25), scanCode=114, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=1945ms
KeyEvent(deviceId=3, eventTime=480050313000, source=0x00000101, displayId=-1, action=UP, flags=0x00000008, keyCode=VOLUME_DOWN(25), scanCode=114, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=1792ms
KeyEvent(deviceId=2, eventTime=480483397000, source=0x00000101, displayId=-1, action=DOWN, flags=0x00000008, keyCode=VOLUME_UP(24), scanCode=115, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=1359ms
KeyEvent(deviceId=2, eventTime=480646721000, source=0x00000101, displayId=-1, action=UP, flags=0x00000008, keyCode=VOLUME_UP(24), scanCode=115, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=1195ms
Change-Id: Ifeb70526c589508220cade800bd104344dc312ab
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index a19b04f..e45269e 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -159,10 +159,11 @@
}
return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64
", source=0x%08x, displayId=%" PRId32 ", action=%s, "
- "flags=0x%08x, keyCode=%d, scanCode=%d, metaState=0x%08x, "
+ "flags=0x%08x, keyCode=%s(%d), scanCode=%d, metaState=0x%08x, "
"repeatCount=%d), policyFlags=0x%08x",
deviceId, eventTime, source, displayId, KeyEvent::actionToString(action),
- flags, keyCode, scanCode, metaState, repeatCount, policyFlags);
+ flags, KeyEvent::getLabel(keyCode), keyCode, scanCode, metaState,
+ repeatCount, policyFlags);
}
void KeyEntry::recycle() {