Loading services/inputflinger/InputManager.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -111,10 +111,8 @@ void InputManager::setInputWindows(const std::vector<InputWindowInfo>& infos, handlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>()); handlesPerDisplay[info.displayId].push_back(new BinderWindowHandle(info)); } mDispatcher->setInputWindows(handlesPerDisplay); if (setInputWindowsListener) { setInputWindowsListener->onSetInputWindowsFinished(); for (auto const& i : handlesPerDisplay) { mDispatcher->setInputWindows(i.second, i.first, setInputWindowsListener); } } 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({{ADISPLAY_ID_DEFAULT, {window}}}); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); 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({{ADISPLAY_ID_DEFAULT, {window}}}); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); for (auto _ : state) { MotionEvent event = generateMotionEvent(); Loading services/inputflinger/dispatcher/InputDispatcher.cpp +87 −86 Original line number Diff line number Diff line Loading @@ -3621,18 +3621,6 @@ 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 @@ -3640,8 +3628,9 @@ void InputDispatcher::setInputWindows( * 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::setInputWindowsLocked( const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) { void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener) { if (DEBUG_FOCUS) { std::string windowList; for (const sp<InputWindowHandle>& iwh : inputWindowHandles) { Loading @@ -3649,9 +3638,12 @@ void InputDispatcher::setInputWindowsLocked( } 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 @@ -3720,7 +3712,8 @@ void InputDispatcher::setInputWindowsLocked( 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 @@ -3741,6 +3734,14 @@ void InputDispatcher::setInputWindowsLocked( 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 +2 −4 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::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) override; const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override; virtual void setFocusedApplication( int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override; virtual void setFocusedDisplay(int32_t displayId) override; Loading Loading @@ -278,8 +278,6 @@ 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 +3 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <InputListener.h> #include <input/ISetInputWindowsListener.h> #include <unordered_map> namespace android { Loading Loading @@ -100,13 +99,13 @@ public: */ virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) = 0; /* Sets the list of input windows per display. /* Sets the list of input windows. * * This method may be called on any thread (usually by the input manager). */ virtual void setInputWindows( const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) = 0; const std::vector<sp<InputWindowHandle> >& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) = 0; /* Sets the focused application on the given display. * Loading Loading
services/inputflinger/InputManager.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -111,10 +111,8 @@ void InputManager::setInputWindows(const std::vector<InputWindowInfo>& infos, handlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>()); handlesPerDisplay[info.displayId].push_back(new BinderWindowHandle(info)); } mDispatcher->setInputWindows(handlesPerDisplay); if (setInputWindowsListener) { setInputWindowsListener->onSetInputWindowsFinished(); for (auto const& i : handlesPerDisplay) { mDispatcher->setInputWindows(i.second, i.first, setInputWindowsListener); } } 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({{ADISPLAY_ID_DEFAULT, {window}}}); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); 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({{ADISPLAY_ID_DEFAULT, {window}}}); dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT); for (auto _ : state) { MotionEvent event = generateMotionEvent(); Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +87 −86 Original line number Diff line number Diff line Loading @@ -3621,18 +3621,6 @@ 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 @@ -3640,8 +3628,9 @@ void InputDispatcher::setInputWindows( * 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::setInputWindowsLocked( const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) { void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener) { if (DEBUG_FOCUS) { std::string windowList; for (const sp<InputWindowHandle>& iwh : inputWindowHandles) { Loading @@ -3649,9 +3638,12 @@ void InputDispatcher::setInputWindowsLocked( } 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 @@ -3720,7 +3712,8 @@ void InputDispatcher::setInputWindowsLocked( 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 @@ -3741,6 +3734,14 @@ void InputDispatcher::setInputWindowsLocked( 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 +2 −4 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::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) override; const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override; virtual void setFocusedApplication( int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override; virtual void setFocusedDisplay(int32_t displayId) override; Loading Loading @@ -278,8 +278,6 @@ 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 +3 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <InputListener.h> #include <input/ISetInputWindowsListener.h> #include <unordered_map> namespace android { Loading Loading @@ -100,13 +99,13 @@ public: */ virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) = 0; /* Sets the list of input windows per display. /* Sets the list of input windows. * * This method may be called on any thread (usually by the input manager). */ virtual void setInputWindows( const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) = 0; const std::vector<sp<InputWindowHandle> >& inputWindowHandles, int32_t displayId, const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) = 0; /* Sets the focused application on the given display. * Loading