diff options
author | 2019-09-04 13:34:06 -0700 | |
---|---|---|
committer | 2019-09-04 13:34:06 -0700 | |
commit | 9c724d78b9f2e00a7d4de3bfd2c65f6226fa8529 (patch) | |
tree | a3796f67d19deece6118e60d2faebde9499ce083 /services/inputflinger/InputManager.cpp | |
parent | 0bc2361309d705f8c7f7766f1912fd0f7035d199 (diff) | |
parent | 638c07856510784987e81ba0b026780850bf5775 (diff) |
DO NOT MERGE - Merge Android 10 into master
Bug: 139893257
Change-Id: I0b8ce4715e111f1378ddada95d746b1788645a6d
Diffstat (limited to 'services/inputflinger/InputManager.cpp')
-rw-r--r-- | services/inputflinger/InputManager.cpp | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index 519faa6b5c..3996cca646 100644 --- a/services/inputflinger/InputManager.cpp +++ b/services/inputflinger/InputManager.cpp @@ -19,25 +19,23 @@ //#define LOG_NDEBUG 0 #include "InputManager.h" +#include "InputReaderFactory.h" + +#include <binder/IPCThreadState.h> #include <log/log.h> +#include <unordered_map> + +#include <private/android_filesystem_config.h> namespace android { InputManager::InputManager( - const sp<EventHubInterface>& eventHub, const sp<InputReaderPolicyInterface>& readerPolicy, const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) { mDispatcher = new InputDispatcher(dispatcherPolicy); - mReader = new InputReader(eventHub, readerPolicy, mDispatcher); - initialize(); -} - -InputManager::InputManager( - const sp<InputReaderInterface>& reader, - const sp<InputDispatcherInterface>& dispatcher) : - mReader(reader), - mDispatcher(dispatcher) { + mClassifier = new InputClassifier(mDispatcher); + mReader = createInputReader(readerPolicy, mClassifier); initialize(); } @@ -86,8 +84,57 @@ sp<InputReaderInterface> InputManager::getReader() { return mReader; } +sp<InputClassifierInterface> InputManager::getClassifier() { + return mClassifier; +} + sp<InputDispatcherInterface> InputManager::getDispatcher() { return mDispatcher; } +class BinderWindowHandle : public InputWindowHandle { +public: + BinderWindowHandle(const InputWindowInfo& info) { + mInfo = info; + } + + bool updateInfo() override { + return true; + } +}; + +void InputManager::setInputWindows(const std::vector<InputWindowInfo>& infos, + const sp<ISetInputWindowsListener>& setInputWindowsListener) { + std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> handlesPerDisplay; + + std::vector<sp<InputWindowHandle>> handles; + for (const auto& info : infos) { + handlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>()); + handlesPerDisplay[info.displayId].push_back(new BinderWindowHandle(info)); + } + for (auto const& i : handlesPerDisplay) { + mDispatcher->setInputWindows(i.second, i.first, setInputWindowsListener); + } +} + +void InputManager::transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken) { + mDispatcher->transferTouchFocus(fromToken, toToken); +} + +// Used by tests only. +void InputManager::registerInputChannel(const sp<InputChannel>& channel) { + IPCThreadState* ipc = IPCThreadState::self(); + const int uid = ipc->getCallingUid(); + if (uid != AID_SHELL && uid != AID_ROOT) { + ALOGE("Invalid attempt to register input channel over IPC" + "from non shell/root entity (PID: %d)", ipc->getCallingPid()); + return; + } + mDispatcher->registerInputChannel(channel, false); +} + +void InputManager::unregisterInputChannel(const sp<InputChannel>& channel) { + mDispatcher->unregisterInputChannel(channel); +} + } // namespace android |