亲爱的dumpsys input |grep KeyEvent 再见
MonitoringChannels:
0: 'WindowManager (server)'
RecentQueue: length=10
KeyEvent(deviceId=2, source=0x00000301, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age= 33556.5ms
KeyEvent(deviceId=2, source=0x00000301, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=33 375.1ms
KeyEvent(deviceId=2, source=0x00000301, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age= 33244.3ms
KeyEvent(deviceId=2, source=0x00000301, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=33 163.1ms
KeyEvent(deviceId=2, source=0x00000301, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age= 33026.9ms
KeyEvent(deviceId=2, source=0x00000301, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=32 943.1ms
KeyEvent(deviceId=2, source=0x00000301, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age= 32833.5ms
KeyEvent(deviceId=2, source=0x00000301, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=32 751.1ms
KeyEvent(deviceId=2, source=0x00000301, action=DOWN, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age= 32646.0ms
KeyEvent(deviceId=2, source=0x00000301, action=UP, flags=0x00000008, keyCode=20, scanCode=108, metaState=0x00000000, repeatCount=0), policyFlags=0x62000000, age=32 563.1ms
PendingEvent:
InboundQueue:
ReplacedKeys:
AuthBlog:秋城https://www.cnblogs.com/houser0323
details:
From 755b95146851dfb0a4563e878357f7bc889cab2a Mon Sep 17 00:00:00 2001
From: Ashwini Oruganti
Date: Fri, 6 Dec 2019 10:00:53 -0800
Subject: [PATCH] Don't leak input events to dumpsys on user builds
Remove the details of KeyEvent and MotionEvent logs.
Bug: 139945049
Test: Tested on a device, the input functions work as expected and input
event logs are not leaked to dumpsys on user builds.
Change-Id: I98c9c375f18963177bf0c1d8829a217b4ad4acc6
Merged-In: I98c9c375f18963177bf0c1d8829a217b4ad4acc6
(cherry picked from commit 3b7d779774cb81c5d922f74216392c9fd7004a1b)
---
services/inputflinger/InputDispatcher.cpp | 50 +----------------------
1 file changed, 2 insertions(+), 48 deletions(-)
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index 9a449fa6d..91e017d15 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -105,36 +105,6 @@ static inline const char* toString(bool value) {
return value ? "true" : "false";
}
-static std::string motionActionToString(int32_t action) {
- // Convert MotionEvent action to string
- switch(action & AMOTION_EVENT_ACTION_MASK) {
- case AMOTION_EVENT_ACTION_DOWN:
- return "DOWN";
- case AMOTION_EVENT_ACTION_MOVE:
- return "MOVE";
- case AMOTION_EVENT_ACTION_UP:
- return "UP";
- case AMOTION_EVENT_ACTION_POINTER_DOWN:
- return "POINTER_DOWN";
- case AMOTION_EVENT_ACTION_POINTER_UP:
- return "POINTER_UP";
- }
- return StringPrintf("%" PRId32, action);
-}
-
-static std::string keyActionToString(int32_t action) {
- // Convert KeyEvent action to string
- switch(action) {
- case AKEY_EVENT_ACTION_DOWN:
- return "DOWN";
- case AKEY_EVENT_ACTION_UP:
- return "UP";
- case AKEY_EVENT_ACTION_MULTIPLE:
- return "MULTIPLE";
- }
- return StringPrintf("%" PRId32, action);
-}
-
static inline int32_t getMotionEventActionPointerIndex(int32_t action) {
return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)
>> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
@@ -4006,11 +3976,7 @@ InputDispatcher::KeyEntry::~KeyEntry() {
}
void InputDispatcher::KeyEntry::appendDescription(std::string& msg) const {
- msg += StringPrintf("KeyEvent(deviceId=%d, source=0x%08x, action=%s, "
- "flags=0x%08x, keyCode=%d, scanCode=%d, metaState=0x%08x, "
- "repeatCount=%d), policyFlags=0x%08x",
- deviceId, source, keyActionToString(action).c_str(), flags, keyCode,
- scanCode, metaState, repeatCount, policyFlags);
+ msg += StringPrintf("KeyEvent");
}
void InputDispatcher::KeyEntry::recycle() {
@@ -4051,19 +4017,7 @@ InputDispatcher::MotionEntry::~MotionEntry() {
}
void InputDispatcher::MotionEntry::appendDescription(std::string& msg) const {
- msg += StringPrintf("MotionEvent(deviceId=%d, source=0x%08x, action=%s, actionButton=0x%08x, "
- "flags=0x%08x, metaState=0x%08x, buttonState=0x%08x, "
- "edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, displayId=%d, pointers=[",
- deviceId, source, motionActionToString(action).c_str(), actionButton, flags, metaState,
- buttonState, edgeFlags, xPrecision, yPrecision, displayId);
- for (uint32_t i = 0; i < pointerCount; i++) {
- if (i) {
- msg += ", ";
- }
- msg += StringPrintf("%d: (%.1f, %.1f)", pointerProperties[i].id,
- pointerCoords[i].getX(), pointerCoords[i].getY());
- }
- msg += StringPrintf("]), policyFlags=0x%08x", policyFlags);
+ msg += StringPrintf("MotionEvent");
}
--
2.24.1.735.g03f4e72817-goog