InputFlinger: Receive setInputWindows over IPC
Plumbing to expose the InputManager object as an InputFlinger
service with a single setInputWindows method.
Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: I6e63a7e251711993334d930d2b95352e6cba031e
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index 519faa6..40ca6a7 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -21,6 +21,7 @@
#include "InputManager.h"
#include <log/log.h>
+#include <unordered_map>
namespace android {
@@ -90,4 +91,39 @@
return mDispatcher;
}
+class BinderApplicationHandle : public InputApplicationHandle {
+public:
+ BinderApplicationHandle() = default;
+
+ bool updateInfo() override {
+ return true;
+ }
+};
+
+class BinderWindowHandle : public InputWindowHandle {
+public:
+ BinderWindowHandle(const InputWindowInfo& info) :
+ InputWindowHandle(new BinderApplicationHandle()) {
+
+ mInfo = info;
+ }
+
+ bool updateInfo() override {
+ return true;
+ }
+};
+
+void InputManager::setInputWindows(const Vector<InputWindowInfo>& infos) {
+ std::unordered_map<int32_t, Vector<sp<InputWindowHandle>>> handlesPerDisplay;
+
+ Vector<sp<InputWindowHandle>> handles;
+ for (const auto& info : infos) {
+ handlesPerDisplay.emplace(info.displayId, Vector<sp<InputWindowHandle>>());
+ handlesPerDisplay[info.displayId].add(new BinderWindowHandle(info));
+ }
+ for (auto const& i : handlesPerDisplay) {
+ mDispatcher->setInputWindows(i.second, i.first);
+ }
+}
+
} // namespace android