From c28306ad4ac9ce7a7d5f10c2e38d422ffc309a1f Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 23 Aug 2011 21:32:42 -0700 Subject: Improve input device wake heuristics. Bug: 5205674 Only wake the device on positive interactions from the user such as button presses, movement, initial touch down events. In particular, do not wake the device on up events since the driver might synthesize them on power off, causing the device to wake up again for no good reason. Change-Id: I767f553ea36d110e6f3a10611b324487ba7d880d --- services/input/InputReader.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp index 643866b4efad..bfcf8e048111 100644 --- a/services/input/InputReader.cpp +++ b/services/input/InputReader.cpp @@ -2188,6 +2188,7 @@ void CursorInputMapper::sync(nsecs_t when) { } nsecs_t downTime = mDownTime; bool buttonsChanged = currentButtonState != lastButtonState; + bool buttonsPressed = currentButtonState & ~lastButtonState; float deltaX = mCursorMotionAccumulator.getRelativeX() * mXScale; float deltaY = mCursorMotionAccumulator.getRelativeY() * mYScale; @@ -2249,7 +2250,7 @@ void CursorInputMapper::sync(nsecs_t when) { // the device in your pocket. // TODO: Use the input device configuration to control this behavior more finely. uint32_t policyFlags = 0; - if (getDevice()->isExternal()) { + if ((buttonsPressed || moved || scrolled) && getDevice()->isExternal()) { policyFlags |= POLICY_FLAG_WAKE_DROPPED; } @@ -3345,9 +3346,12 @@ void TouchInputMapper::sync(nsecs_t when) { // Handle policy on initial down or hover events. uint32_t policyFlags = 0; - if (mLastRawPointerData.pointerCount == 0 && mCurrentRawPointerData.pointerCount != 0) { + bool initialDown = mLastRawPointerData.pointerCount == 0 + && mCurrentRawPointerData.pointerCount != 0; + bool buttonsPressed = mCurrentButtonState & ~mLastButtonState; + if (initialDown || buttonsPressed) { + // If this is a touch screen, hide the pointer on an initial down. if (mDeviceMode == DEVICE_MODE_DIRECT) { - // If this is a touch screen, hide the pointer on an initial down. getContext()->fadePointer(); } -- cgit v1.2.3-59-g8ed1b