Loading services/inputflinger/InputManager.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -111,8 +111,10 @@ void InputManager::setInputWindows(const std::vector<InputWindowInfo>& 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); mDispatcher->setInputWindows(handlesPerDisplay); if (setInputWindowsListener) { setInputWindowsListener->onSetInputWindowsFinished(); } } Loading services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ static void benchmarkNotifyMotion(benchmark::State& state) { sp<FakeApplicationHandle> application = new FakeApplicationHandle(); sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window"); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}}); NotifyMotionArgs motionArgs = generateMotionArgs(); Loading Loading @@ -288,7 +288,7 @@ static void benchmarkInjectMotion(benchmark::State& state) { sp<FakeApplicationHandle> application = new FakeApplicationHandle(); sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window"); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}}); for (auto _ : state) { MotionEvent event = generateMotionEvent(); Loading services/inputflinger/dispatcher/InputDispatcher.cpp +86 −87 Original line number Diff line number Diff line Loading @@ -3621,6 +3621,18 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked( mWindowHandlesByDisplay[displayId] = newHandles; } void InputDispatcher::setInputWindows( const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) { { // acquire lock std::scoped_lock _l(mLock); for (auto const& i : handlesPerDisplay) { setInputWindowsLocked(i.second, i.first); } } // Wake up poll loop since it may need to make new input dispatching choices. mLooper->wake(); } /** * Called from InputManagerService, update window handle list by displayId that can receive input. * A window handle contains information about InputChannel, Touch Region, Types, Focused,... Loading @@ -3628,9 +3640,8 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked( * For focused handle, check if need to change and send a cancel event to previous one. * For removed handle, check if need to send a cancel event if already in touch. */ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener) { void InputDispatcher::setInputWindowsLocked( const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) { if (DEBUG_FOCUS) { std::string windowList; for (const sp<InputWindowHandle>& iwh : inputWindowHandles) { Loading @@ -3638,12 +3649,9 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& } ALOGD("setInputWindows displayId=%" PRId32 " %s", displayId, windowList.c_str()); } { // acquire lock std::scoped_lock _l(mLock); // Copy old handles for release if they are no longer present. const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId); const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId); updateWindowHandlesForDisplayLocked(inputWindowHandles, displayId); Loading Loading @@ -3712,8 +3720,7 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& if (touchedInputChannel != nullptr) { CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS, "touched window was removed"); synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options); synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options); } state.windows.erase(state.windows.begin() + i); } else { Loading @@ -3734,14 +3741,6 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& oldWindowHandle->releaseChannel(); } } } // release lock // Wake up poll loop since it may need to make new input dispatching choices. mLooper->wake(); if (setInputWindowsListener) { setInputWindowsListener->onSetInputWindowsFinished(); } } void InputDispatcher::setFocusedApplication( Loading services/inputflinger/dispatcher/InputDispatcher.h +4 −2 Original line number Diff line number Diff line Loading @@ -109,8 +109,8 @@ public: virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override; virtual void setInputWindows( const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override; const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) override; virtual void setFocusedApplication( int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override; virtual void setFocusedDisplay(int32_t displayId) override; Loading Loading @@ -278,6 +278,8 @@ private: std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay GUARDED_BY(mLock); void setInputWindowsLocked(const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) REQUIRES(mLock); // Get window handles by display, return an empty vector if not found. std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const REQUIRES(mLock); Loading services/inputflinger/dispatcher/include/InputDispatcherInterface.h +4 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <InputListener.h> #include <input/ISetInputWindowsListener.h> #include <unordered_map> namespace android { Loading Loading @@ -99,13 +100,13 @@ public: */ virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) = 0; /* Sets the list of input windows. /* Sets the list of input windows per display. * * This method may be called on any thread (usually by the input manager). */ virtual void setInputWindows( const std::vector<sp<InputWindowHandle> >& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) = 0; const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) = 0; /* Sets the focused application on the given display. * Loading Loading
services/inputflinger/InputManager.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -111,8 +111,10 @@ void InputManager::setInputWindows(const std::vector<InputWindowInfo>& 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); mDispatcher->setInputWindows(handlesPerDisplay); if (setInputWindowsListener) { setInputWindowsListener->onSetInputWindowsFinished(); } } Loading
services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ static void benchmarkNotifyMotion(benchmark::State& state) { sp<FakeApplicationHandle> application = new FakeApplicationHandle(); sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window"); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}}); NotifyMotionArgs motionArgs = generateMotionArgs(); Loading Loading @@ -288,7 +288,7 @@ static void benchmarkInjectMotion(benchmark::State& state) { sp<FakeApplicationHandle> application = new FakeApplicationHandle(); sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window"); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}}); for (auto _ : state) { MotionEvent event = generateMotionEvent(); Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +86 −87 Original line number Diff line number Diff line Loading @@ -3621,6 +3621,18 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked( mWindowHandlesByDisplay[displayId] = newHandles; } void InputDispatcher::setInputWindows( const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) { { // acquire lock std::scoped_lock _l(mLock); for (auto const& i : handlesPerDisplay) { setInputWindowsLocked(i.second, i.first); } } // Wake up poll loop since it may need to make new input dispatching choices. mLooper->wake(); } /** * Called from InputManagerService, update window handle list by displayId that can receive input. * A window handle contains information about InputChannel, Touch Region, Types, Focused,... Loading @@ -3628,9 +3640,8 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked( * For focused handle, check if need to change and send a cancel event to previous one. * For removed handle, check if need to send a cancel event if already in touch. */ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener) { void InputDispatcher::setInputWindowsLocked( const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) { if (DEBUG_FOCUS) { std::string windowList; for (const sp<InputWindowHandle>& iwh : inputWindowHandles) { Loading @@ -3638,12 +3649,9 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& } ALOGD("setInputWindows displayId=%" PRId32 " %s", displayId, windowList.c_str()); } { // acquire lock std::scoped_lock _l(mLock); // Copy old handles for release if they are no longer present. const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId); const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId); updateWindowHandlesForDisplayLocked(inputWindowHandles, displayId); Loading Loading @@ -3712,8 +3720,7 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& if (touchedInputChannel != nullptr) { CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS, "touched window was removed"); synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options); synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options); } state.windows.erase(state.windows.begin() + i); } else { Loading @@ -3734,14 +3741,6 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& oldWindowHandle->releaseChannel(); } } } // release lock // Wake up poll loop since it may need to make new input dispatching choices. mLooper->wake(); if (setInputWindowsListener) { setInputWindowsListener->onSetInputWindowsFinished(); } } void InputDispatcher::setFocusedApplication( Loading
services/inputflinger/dispatcher/InputDispatcher.h +4 −2 Original line number Diff line number Diff line Loading @@ -109,8 +109,8 @@ public: virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override; virtual void setInputWindows( const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override; const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) override; virtual void setFocusedApplication( int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override; virtual void setFocusedDisplay(int32_t displayId) override; Loading Loading @@ -278,6 +278,8 @@ private: std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay GUARDED_BY(mLock); void setInputWindowsLocked(const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) REQUIRES(mLock); // Get window handles by display, return an empty vector if not found. std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const REQUIRES(mLock); Loading
services/inputflinger/dispatcher/include/InputDispatcherInterface.h +4 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <InputListener.h> #include <input/ISetInputWindowsListener.h> #include <unordered_map> namespace android { Loading Loading @@ -99,13 +100,13 @@ public: */ virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) = 0; /* Sets the list of input windows. /* Sets the list of input windows per display. * * This method may be called on any thread (usually by the input manager). */ virtual void setInputWindows( const std::vector<sp<InputWindowHandle> >& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) = 0; const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) = 0; /* Sets the focused application on the given display. * Loading