Skip to content

Commit d4cf7e7

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Don't ANR on hover, scroll or if a window goes away." into jb-dev
2 parents a27551d + 8249fc6 commit d4cf7e7

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

services/input/InputDispatcher.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,27 +1226,36 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
12261226
isSplit = true;
12271227
} else if (isSplit) {
12281228
// New window does not support splitting but we have already split events.
1229-
// Assign the pointer to the first foreground window we find.
1230-
// (May be NULL which is why we put this code block before the next check.)
1231-
newTouchedWindowHandle = mTempTouchState.getFirstForegroundWindowHandle();
1229+
// Ignore the new window.
1230+
newTouchedWindowHandle = NULL;
12321231
}
12331232

1234-
// If we did not find a touched window then fail.
1233+
// Handle the case where we did not find a window.
12351234
if (newTouchedWindowHandle == NULL) {
1236-
if (mFocusedApplicationHandle != NULL) {
1235+
// Try to assign the pointer to the first foreground window we find, if there is one.
1236+
newTouchedWindowHandle = mTempTouchState.getFirstForegroundWindowHandle();
1237+
if (newTouchedWindowHandle == NULL) {
1238+
// There is no touched window. If this is an initial down event
1239+
// then wait for a window to appear that will handle the touch. This is
1240+
// to ensure that we report an ANR in the case where an application has started
1241+
// but not yet put up a window and the user is starting to get impatient.
1242+
if (maskedAction == AMOTION_EVENT_ACTION_DOWN
1243+
&& mFocusedApplicationHandle != NULL) {
12371244
#if DEBUG_FOCUS
1238-
ALOGD("Waiting because there is no touched window but there is a "
1239-
"focused application that may eventually add a new window: %s.",
1240-
getApplicationWindowLabelLocked(mFocusedApplicationHandle, NULL).string());
1245+
ALOGD("Waiting because there is no touched window but there is a "
1246+
"focused application that may eventually add a new window: %s.",
1247+
getApplicationWindowLabelLocked(
1248+
mFocusedApplicationHandle, NULL).string());
12411249
#endif
1242-
injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
1243-
mFocusedApplicationHandle, NULL, nextWakeupTime);
1244-
goto Unresponsive;
1245-
}
1250+
injectionResult = handleTargetsNotReadyLocked(currentTime, entry,
1251+
mFocusedApplicationHandle, NULL, nextWakeupTime);
1252+
goto Unresponsive;
1253+
}
12461254

1247-
ALOGI("Dropping event because there is no touched window or focused application.");
1248-
injectionResult = INPUT_EVENT_INJECTION_FAILED;
1249-
goto Failed;
1255+
ALOGI("Dropping event because there is no touched window.");
1256+
injectionResult = INPUT_EVENT_INJECTION_FAILED;
1257+
goto Failed;
1258+
}
12501259
}
12511260

12521261
// Set target flags.

0 commit comments

Comments
 (0)