Skip to content

Commit f44e394

Browse files
author
Jeff Brown
committed
When ANR happens, only remove ANR'd window.
The system bar uses input event injection to inject BACK keys into the application. If the receiving application ANRs, we used to clear the touch state unconditionally. Doing so would prevent the system bar from receiving the ACTION_UP event so the back button would continue to appear pressed until pressed again. Now we are more careful to only remove the specific ANR'd window from the touch state. Other windows should continue to receive touch events as usual. Change-Id: If86bfc323e2c7aed82ca1334bc67da649953168f
1 parent 80a7627 commit f44e394

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)