summaryrefslogtreecommitdiffstats
path: root/services/input
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-07-27 11:50:51 -0700
committerJeff Brown <jeffbrown@google.com>2011-07-27 11:50:51 -0700
commit5ea29ab7efa9a9ae22345f15a7cb9be3c5e1bbf5 (patch)
tree4403ea968de41dad277a7eb08ce00d65d43f1e3f /services/input
parentbc68a59c024bdb745dac8e2ec7408a9f30595f1a (diff)
downloadframeworks_base-5ea29ab7efa9a9ae22345f15a7cb9be3c5e1bbf5.zip
frameworks_base-5ea29ab7efa9a9ae22345f15a7cb9be3c5e1bbf5.tar.gz
frameworks_base-5ea29ab7efa9a9ae22345f15a7cb9be3c5e1bbf5.tar.bz2
Reset input dispatcher targets when focus changes apps.
This fixes an issue where an ANR can occur in a newly focused application through no fault of its own, simply because the previous app took a little while to transfer focus to the new app. Bug: 4584620 Change-Id: If3227eb68d92a09a108e9de7f0afcbd9a5dbdead
Diffstat (limited to 'services/input')
-rw-r--r--services/input/InputDispatcher.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 039b003..af13945 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -998,8 +998,7 @@ void InputDispatcher::dispatchEventToCurrentInputTargetsLocked(nsecs_t currentTi
void InputDispatcher::resetTargetsLocked() {
mCurrentInputTargetsValid = false;
mCurrentInputTargets.clear();
- mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_NONE;
- mInputTargetWaitApplicationHandle.clear();
+ resetANRTimeoutsLocked();
}
void InputDispatcher::commitTargetsLocked() {
@@ -1110,6 +1109,7 @@ void InputDispatcher::resetANRTimeoutsLocked() {
// Reset input target wait timeout.
mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_NONE;
+ mInputTargetWaitApplicationHandle.clear();
}
int32_t InputDispatcher::findFocusedWindowTargetsLocked(nsecs_t currentTime,
@@ -3226,8 +3226,14 @@ void InputDispatcher::setFocusedApplication(
AutoMutex _l(mLock);
if (inputApplicationHandle != NULL && inputApplicationHandle->update()) {
- mFocusedApplicationHandle = inputApplicationHandle;
- } else {
+ if (mFocusedApplicationHandle != inputApplicationHandle) {
+ if (mFocusedApplicationHandle != NULL) {
+ resetTargetsLocked();
+ }
+ mFocusedApplicationHandle = inputApplicationHandle;
+ }
+ } else if (mFocusedApplicationHandle != NULL) {
+ resetTargetsLocked();
mFocusedApplicationHandle.clear();
}