Add onPointerDownOutsideFocus for events outside the focused window (2/4)
Post the onPointerDownOutsideFocus command when the conditions are satisfied.
Added onPointerDownOutsideFocus to the InputDispatcherPolicyInterface so the
callback can be sent to the client.
Bug: 122535136
Test: InputDispatcherOnPointerDownOutsideFocus
Change-Id: Ifec75daf1fff4ef83e0c230829400abb5a065d7f
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index 0d5bc15..4dc9111 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -2055,7 +2055,7 @@
return; // skip the inconsistent event
}
- dispatchPointerDownOutsideFocusIfNecessary(motionEntry->source,
+ dispatchPointerDownOutsideFocus(motionEntry->source,
dispatchEntry->resolvedAction, inputTarget->inputChannel->getToken());
break;
@@ -2073,10 +2073,11 @@
}
-void InputDispatcher::dispatchPointerDownOutsideFocusIfNecessary(uint32_t source, int32_t action,
+void InputDispatcher::dispatchPointerDownOutsideFocus(uint32_t source, int32_t action,
const sp<IBinder>& newToken) {
int32_t maskedAction = action & AMOTION_EVENT_ACTION_MASK;
- if (source != AINPUT_SOURCE_CLASS_POINTER || maskedAction != AMOTION_EVENT_ACTION_DOWN) {
+ uint32_t maskedSource = source & AINPUT_SOURCE_CLASS_MASK;
+ if (maskedSource != AINPUT_SOURCE_CLASS_POINTER || maskedAction != AMOTION_EVENT_ACTION_DOWN) {
return;
}
@@ -2095,7 +2096,9 @@
return;
}
- // Dispatch onPointerDownOutsideFocus to the policy.
+ CommandEntry* commandEntry = postCommandLocked(
+ & InputDispatcher::doOnPointerDownOutsideFocusLockedInterruptible);
+ commandEntry->newToken = newToken;
}
void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
@@ -3997,6 +4000,12 @@
entry->release();
}
+void InputDispatcher::doOnPointerDownOutsideFocusLockedInterruptible(CommandEntry* commandEntry) {
+ mLock.unlock();
+ mPolicy->onPointerDownOutsideFocus(commandEntry->newToken);
+ mLock.lock();
+}
+
void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
CommandEntry* commandEntry) {
sp<Connection> connection = commandEntry->connection;