Skip to content

Commit 2b3462e

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "When ANR happens, only remove ANR'd window."
2 parents 70c8723 + f44e394 commit 2b3462e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

services/input/InputDispatcher.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,14 +970,17 @@ void InputDispatcher::resumeAfterTargetsNotReadyTimeoutLocked(nsecs_t newTimeout
970970
// Give up.
971971
mInputTargetWaitTimeoutExpired = true;
972972

973-
// Release the touch targets.
974-
mTouchState.reset();
975-
976973
// Input state will not be realistic. Mark it out of sync.
977974
if (inputChannel.get()) {
978975
ssize_t connectionIndex = getConnectionIndexLocked(inputChannel);
979976
if (connectionIndex >= 0) {
980977
sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
978+
sp<InputWindowHandle> windowHandle = connection->inputWindowHandle;
979+
980+
if (windowHandle != NULL) {
981+
mTouchState.removeWindow(windowHandle);
982+
}
983+
981984
if (connection->status == Connection::STATUS_NORMAL) {
982985
CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS,
983986
"application not responding");
@@ -4146,6 +4149,15 @@ void InputDispatcher::TouchState::addOrUpdateWindow(const sp<InputWindowHandle>&
41464149
touchedWindow.pointerIds = pointerIds;
41474150
}
41484151

4152+
void InputDispatcher::TouchState::removeWindow(const sp<InputWindowHandle>& windowHandle) {
4153+
for (size_t i = 0; i < windows.size(); i++) {
4154+
if (windows.itemAt(i).windowHandle == windowHandle) {
4155+
windows.removeAt(i);
4156+
return;
4157+
}
4158+
}
4159+
}
4160+
41494161
void InputDispatcher::TouchState::filterNonAsIsTouchWindows() {
41504162
for (size_t i = 0 ; i < windows.size(); ) {
41514163
TouchedWindow& window = windows.editItemAt(i);

services/input/InputDispatcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ class InputDispatcher : public InputDispatcherInterface {
926926
void copyFrom(const TouchState& other);
927927
void addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle,
928928
int32_t targetFlags, BitSet32 pointerIds);
929+
void removeWindow(const sp<InputWindowHandle>& windowHandle);
929930
void filterNonAsIsTouchWindows();
930931
sp<InputWindowHandle> getFirstForegroundWindowHandle() const;
931932
bool isSlippery() const;

0 commit comments

Comments
 (0)