summaryrefslogtreecommitdiffstats
path: root/libs/ui/InputDispatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ui/InputDispatcher.cpp')
-rw-r--r--libs/ui/InputDispatcher.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index 629234b..b936c4d 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -1163,7 +1163,10 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
// If the pointer is not currently down, then ignore the event.
if (! mTempTouchState.down) {
- LOGI("Dropping event because the pointer is not down.");
+#if DEBUG_INPUT_DISPATCHER_POLICY
+ LOGD("Dropping event because the pointer is not down or we previously "
+ "dropped the pointer down event.");
+#endif
injectionResult = INPUT_EVENT_INJECTION_FAILED;
goto Failed;
}
@@ -1302,6 +1305,9 @@ Failed:
}
Unresponsive:
+ // Reset temporary touch state to ensure we release unnecessary references to input channels.
+ mTempTouchState.reset();
+
nsecs_t timeSpentWaitingForApplication = getTimeSpentWaitingForApplicationLocked(currentTime);
updateDispatchStatisticsLocked(currentTime, entry,
injectionResult, timeSpentWaitingForApplication);
@@ -2586,10 +2592,14 @@ void InputDispatcher::setInputDispatchMode(bool enabled, bool frozen) {
AutoMutex _l(mLock);
if (mDispatchEnabled != enabled || mDispatchFrozen != frozen) {
- if (mDispatchFrozen && ! frozen) {
+ if (mDispatchFrozen && !frozen) {
resetANRTimeoutsLocked();
}
+ if (mDispatchEnabled && !enabled) {
+ resetAndDropEverythingLocked("dispatcher is being disabled");
+ }
+
mDispatchEnabled = enabled;
mDispatchFrozen = frozen;
changed = true;
@@ -2684,6 +2694,21 @@ bool InputDispatcher::transferTouchFocus(const sp<InputChannel>& fromChannel,
return true;
}
+void InputDispatcher::resetAndDropEverythingLocked(const char* reason) {
+#if DEBUG_FOCUS
+ LOGD("Resetting and dropping all events (%s).", reason);
+#endif
+
+ synthesizeCancelationEventsForAllConnectionsLocked(InputState::CANCEL_ALL_EVENTS, reason);
+
+ resetKeyRepeatLocked();
+ releasePendingEventLocked();
+ drainInboundQueueLocked();
+ resetTargetsLocked();
+
+ mTouchState.reset();
+}
+
void InputDispatcher::logDispatchStateLocked() {
String8 dump;
dumpDispatchStateLocked(dump);
@@ -2775,7 +2800,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
dump.append(INDENT "ActiveConnections:\n");
for (size_t i = 0; i < mActiveConnections.size(); i++) {
const Connection* connection = mActiveConnections[i];
- dump.appendFormat(INDENT2 "%d: '%s', status=%s, outboundQueueLength=%u"
+ dump.appendFormat(INDENT2 "%d: '%s', status=%s, outboundQueueLength=%u, "
"inputState.isNeutral=%s\n",
i, connection->getInputChannelName(), connection->getStatusLabel(),
connection->outboundQueue.count(),