From a87ea46cb023763e0a9b0222da20b0a354f79d8d Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Mon, 1 Nov 2010 20:35:46 -0700 Subject: [PATCH] Fix bugs related to cheek event suppression. Two issues: 1. First, due to an inverted conditional in the input dispatcher, we were reporting touches as long touches and vice-versa to the power manager. 2. Power manager user activity cheek event suppression also suppresses touch events (but not long touch or up events). As a result, if cheek event suppression was enabled, touches would not poke the user activity timer. However due to the above logic inversion, this actually affected long touches. Net result, if cheek suppression was enabled in the power manager and you held your thumb on the screen long enough, the phone would go to sleep! Cheek event suppression is commonly turned on when making a phone call. Interestingly, it does not seem to get turned off afterward... This change fixes the logic inversion and exempts touches from the cheek suppression. The reason we do the latter is because the old behavior was actually harmful in other ways too: a touch down would be suppressed but not a long touch or the touch up. This would cause bizarre behavior if you touched the screen while it was dimmed. Instead of brightening immediately, it would brighten either when you lifted your finger or 300ms later, whichever came first. Bug: 3154895 Change-Id: Ied9ccec6718fbe86506322ff47a4e3eb58f81834 --- libs/ui/InputDispatcher.cpp | 6 +++--- services/java/com/android/server/PowerManagerService.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp index ae81d2615e496..c0b27fe2cc430 100644 --- a/libs/ui/InputDispatcher.cpp +++ b/libs/ui/InputDispatcher.cpp @@ -51,8 +51,8 @@ namespace android { -// Delay between reporting long touch events to the power manager. -const nsecs_t EVENT_IGNORE_DURATION = 300 * 1000000LL; // 300 ms +// Delay before reporting long touch events to the power manager. +const nsecs_t LONG_TOUCH_DELAY = 300 * 1000000LL; // 300 ms // Default input dispatching timeout if there is no focused application or paused window // from which to determine an appropriate dispatching timeout. @@ -1416,7 +1416,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) { eventType = POWER_MANAGER_TOUCH_UP_EVENT; break; default: - if (motionEntry->eventTime - motionEntry->downTime >= EVENT_IGNORE_DURATION) { + if (motionEntry->eventTime - motionEntry->downTime < LONG_TOUCH_DELAY) { eventType = POWER_MANAGER_TOUCH_EVENT; } else { eventType = POWER_MANAGER_LONG_TOUCH_EVENT; diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index b0e30f9fa28f7..a6daaefe71029 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -2213,9 +2213,9 @@ class PowerManagerService extends IPowerManager.Stub int eventType, boolean force) { if (((mPokey & POKE_LOCK_IGNORE_CHEEK_EVENTS) != 0) - && (eventType == CHEEK_EVENT || eventType == TOUCH_EVENT)) { + && (eventType == CHEEK_EVENT)) { if (false) { - Slog.d(TAG, "dropping cheek or short event mPokey=0x" + Integer.toHexString(mPokey)); + Slog.d(TAG, "dropping cheek event mPokey=0x" + Integer.toHexString(mPokey)); } return; }