InputDispatcher: Track InputChannels by IBinder token.
In the context of passing input through SurfaceFlinger we need
to change the way InputWindowHandles are passed back to the WindowManager.
In the past the InputDispatcher and the WindowManager have been in the same process.
This is taken advantange of by having the InputDispatcher pass back the same object
to the WindowManager (say in interceptKeyBeforeQueueing) which was passed in from
the WindowManager originally (in setInputWindows) this means if the WindowManager
needs to assosciate a WindowState with a given InputWindowHandle it could just
piggy back some information on a subclass of the object and cast it when receiving back
from the Input subsystem. Since the objects will be parcelled across IPC boundaries now
and the WM will not be the caller of setInputWindows, this mechanism won't work. Instead we
ask the WindowManager to provide an IBinder token at registration time, which we can parcel
through the process as a UUID. We provide this token back to Policy callbacks to enable
the WindowManager to look up it's local state.
Bug: 80101428
Bug: 113136004
Bug: 111440400
Test: Manual
Change-Id: Ia828eb61082240f38d82f89e04956da108f636de
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 066c143..0780704 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -16,6 +16,8 @@
#include "../InputDispatcher.h"
+#include <binder/Binder.h>
+
#include <gtest/gtest.h>
#include <linux/input.h>
@@ -53,12 +55,12 @@
}
virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&,
- const sp<InputWindowHandle>&,
+ const sp<IBinder>&,
const std::string&) {
return 0;
}
- virtual void notifyInputChannelBroken(const sp<InputWindowHandle>&) {
+ virtual void notifyInputChannelBroken(const sp<IBinder>&) {
}
virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) {
@@ -75,12 +77,12 @@
virtual void interceptMotionBeforeQueueing(nsecs_t, uint32_t&) {
}
- virtual nsecs_t interceptKeyBeforeDispatching(const sp<InputWindowHandle>&,
+ virtual nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>&,
const KeyEvent*, uint32_t) {
return 0;
}
- virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>&,
+ virtual bool dispatchUnhandledKey(const sp<IBinder>&,
const KeyEvent*, uint32_t, KeyEvent*) {
return false;
}
@@ -336,6 +338,8 @@
const std::string name, int32_t displayId) :
mDispatcher(dispatcher), mName(name), mDisplayId(displayId) {
InputChannel::openInputChannelPair(name, mServerChannel, mClientChannel);
+ mServerChannel->setToken(new BBinder());
+
mConsumer = new InputConsumer(mClientChannel);
}
@@ -366,7 +370,7 @@
InputWindowHandle(inputApplicationHandle),
FakeInputReceiver(dispatcher, name, displayId),
mFocused(false) {
- mDispatcher->registerInputChannel(mServerChannel, this, displayId);
+ mDispatcher->registerInputChannel(mServerChannel, displayId);
}
virtual bool updateInfo() {
@@ -649,7 +653,7 @@
public:
FakeMonitorReceiver(const sp<InputDispatcher>& dispatcher, const std::string name,
int32_t displayId) : FakeInputReceiver(dispatcher, name, displayId) {
- mDispatcher->registerInputChannel(mServerChannel, nullptr, displayId);
+ mDispatcher->registerInputChannel(mServerChannel, displayId);
}
};