diff options
author | 2018-07-31 14:25:57 -0700 | |
---|---|---|
committer | 2018-11-14 18:16:20 -0800 | |
commit | 1cc78672c860d8af8dbb818bd44342697054866d (patch) | |
tree | 563118560f6ddd5d1b740fc579ebda0390ea637d | |
parent | 4e670e5debca6feb1fb2ebc1f5401570422bd230 (diff) |
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
-rw-r--r-- | include/input/IInputFlinger.h | 7 | ||||
-rw-r--r-- | include/input/InputWindow.h | 3 | ||||
-rw-r--r-- | libs/input/Android.bp | 4 | ||||
-rw-r--r-- | libs/input/IInputFlinger.cpp | 25 | ||||
-rw-r--r-- | libs/input/InputWindow.cpp | 4 | ||||
-rw-r--r-- | services/inputflinger/Android.bp | 1 | ||||
-rw-r--r-- | services/inputflinger/InputManager.cpp | 36 | ||||
-rw-r--r-- | services/inputflinger/InputManager.h | 6 | ||||
-rw-r--r-- | services/inputflinger/host/Android.bp | 8 | ||||
-rw-r--r-- | services/inputflinger/host/InputFlinger.h | 1 |
10 files changed, 83 insertions, 12 deletions
diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h index 11bb7215d6..1ef8986267 100644 --- a/include/input/IInputFlinger.h +++ b/include/input/IInputFlinger.h @@ -22,6 +22,9 @@ #include <binder/IInterface.h> +#include <utils/Vector.h> +#include <input/InputWindow.h> + namespace android { /* @@ -31,6 +34,8 @@ namespace android { class IInputFlinger : public IInterface { public: DECLARE_META_INTERFACE(InputFlinger) + + virtual void setInputWindows(const Vector<InputWindowInfo>& inputHandles) = 0; }; @@ -40,7 +45,7 @@ public: class BnInputFlinger : public BnInterface<IInputFlinger> { public: enum { - DO_SOMETHING_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, + SET_INPUT_WINDOWS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, }; virtual status_t onTransact(uint32_t code, const Parcel& data, diff --git a/include/input/InputWindow.h b/include/input/InputWindow.h index 918b9e18e3..9e3d334f7f 100644 --- a/include/input/InputWindow.h +++ b/include/input/InputWindow.h @@ -33,6 +33,9 @@ class Parcel; * Describes the properties of a window that can receive input. */ struct InputWindowInfo { + InputWindowInfo() = default; + InputWindowInfo(const Parcel& from); + // Window flags from WindowManager.LayoutParams enum { FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, diff --git a/libs/input/Android.bp b/libs/input/Android.bp index 72558a6d91..8cb8649dff 100644 --- a/libs/input/Android.bp +++ b/libs/input/Android.bp @@ -43,12 +43,12 @@ cc_library { target: { android: { srcs: [ - "IInputFlinger.cpp", "InputTransport.cpp", "VelocityControl.cpp", "VelocityTracker.cpp", "InputApplication.cpp", - "InputWindow.cpp" + "InputWindow.cpp", + "IInputFlinger.cpp" ], shared_libs: [ diff --git a/libs/input/IInputFlinger.cpp b/libs/input/IInputFlinger.cpp index 003e73dae6..47a2c0c347 100644 --- a/libs/input/IInputFlinger.cpp +++ b/libs/input/IInputFlinger.cpp @@ -23,7 +23,6 @@ #include <input/IInputFlinger.h> - namespace android { class BpInputFlinger : public BpInterface<IInputFlinger> { @@ -31,23 +30,35 @@ public: explicit BpInputFlinger(const sp<IBinder>& impl) : BpInterface<IInputFlinger>(impl) { } - virtual status_t doSomething() { + virtual void setInputWindows(const Vector<InputWindowInfo>& inputInfo) { Parcel data, reply; data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor()); - remote()->transact(BnInputFlinger::DO_SOMETHING_TRANSACTION, data, &reply); - return reply.readInt32(); + + data.writeUint32(static_cast<uint32_t>(inputInfo.size())); + for (const auto& info : inputInfo) { + info.write(data); + } + remote()->transact(BnInputFlinger::SET_INPUT_WINDOWS_TRANSACTION, data, &reply); } }; IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger"); - status_t BnInputFlinger::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { - case DO_SOMETHING_TRANSACTION: { + case SET_INPUT_WINDOWS_TRANSACTION: { CHECK_INTERFACE(IInputFlinger, data, reply); - reply->writeInt32(0); + size_t count = data.readUint32(); + if (count > data.dataSize()) { + return BAD_VALUE; + } + Vector<InputWindowInfo> handles; + handles.setCapacity(count); + for (size_t i = 0; i < count; i++) { + handles.add(InputWindowInfo(data)); + } + setInputWindows(handles); break; } default: diff --git a/libs/input/InputWindow.cpp b/libs/input/InputWindow.cpp index 6968661a16..f82437e1bf 100644 --- a/libs/input/InputWindow.cpp +++ b/libs/input/InputWindow.cpp @@ -135,6 +135,10 @@ InputWindowInfo InputWindowInfo::read(const Parcel& from) { return ret; } +InputWindowInfo::InputWindowInfo(const Parcel& from) { + *this = read(from); +} + // --- InputWindowHandle --- InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) : diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp index 9a65452f60..7812cb2a61 100644 --- a/services/inputflinger/Android.bp +++ b/services/inputflinger/Android.bp @@ -35,6 +35,7 @@ cc_library_shared { "libutils", "libui", "libhardware_legacy", + "libutils" ], cflags: [ diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index 519faa6b5c..40ca6a7d6d 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 @@ sp<InputDispatcherInterface> InputManager::getDispatcher() { 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 diff --git a/services/inputflinger/InputManager.h b/services/inputflinger/InputManager.h index 92e0af21c3..d0e4cb02be 100644 --- a/services/inputflinger/InputManager.h +++ b/services/inputflinger/InputManager.h @@ -27,6 +27,8 @@ #include <input/Input.h> #include <input/InputTransport.h> + +#include <input/IInputFlinger.h> #include <utils/Errors.h> #include <utils/Vector.h> #include <utils/Timers.h> @@ -72,7 +74,7 @@ public: virtual sp<InputDispatcherInterface> getDispatcher() = 0; }; -class InputManager : public InputManagerInterface { +class InputManager : public InputManagerInterface, public BnInputFlinger { protected: virtual ~InputManager(); @@ -93,6 +95,8 @@ public: virtual sp<InputReaderInterface> getReader(); virtual sp<InputDispatcherInterface> getDispatcher(); + virtual void setInputWindows(const Vector<InputWindowInfo>& handles); + private: sp<InputReaderInterface> mReader; sp<InputReaderThread> mReaderThread; diff --git a/services/inputflinger/host/Android.bp b/services/inputflinger/host/Android.bp index 775dbdc658..0e48f246b2 100644 --- a/services/inputflinger/host/Android.bp +++ b/services/inputflinger/host/Android.bp @@ -30,6 +30,9 @@ cc_library_shared { "libutils", "libhardware", ], + static_libs: [ + "libarect", + ], cflags: [ "-Wall", @@ -54,7 +57,10 @@ cc_binary { shared_libs: [ "libbinder", "libinputflingerhost", - "libutils", + "libutils" + ], + static_libs: [ + "libarect", ], init_rc: ["inputflinger.rc"], diff --git a/services/inputflinger/host/InputFlinger.h b/services/inputflinger/host/InputFlinger.h index 39e69e5efc..15ca7b3c24 100644 --- a/services/inputflinger/host/InputFlinger.h +++ b/services/inputflinger/host/InputFlinger.h @@ -39,6 +39,7 @@ public: InputFlinger() ANDROID_API; virtual status_t dump(int fd, const Vector<String16>& args); + void setInputWindows(const Vector<InputWindowInfo>&) {} private: virtual ~InputFlinger(); |