Loading services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -112,8 +112,6 @@ private: void notifyDropWindow(const sp<IBinder>&, float x, float y) override {} bool isPerDisplayTouchModeEnabled() override { return false; } InputDispatcherConfiguration mConfig; }; Loading services/inputflinger/dispatcher/Entry.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -195,9 +195,10 @@ void KeyEntry::recycle() { // --- TouchModeEntry --- TouchModeEntry::TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode) TouchModeEntry::TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode, int displayId) : EventEntry(id, Type::TOUCH_MODE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER), inTouchMode(inTouchMode) {} inTouchMode(inTouchMode), displayId(displayId) {} TouchModeEntry::~TouchModeEntry() {} Loading services/inputflinger/dispatcher/Entry.h +2 −1 Original line number Diff line number Diff line Loading @@ -210,8 +210,9 @@ struct SensorEntry : EventEntry { struct TouchModeEntry : EventEntry { bool inTouchMode; int32_t displayId; TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode); TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode, int32_t displayId); std::string getDescription() const override; ~TouchModeEntry() override; Loading services/inputflinger/dispatcher/InputDispatcher.cpp +29 −21 Original line number Diff line number Diff line Loading @@ -544,17 +544,12 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic mDispatchEnabled(false), mDispatchFrozen(false), mInputFilterEnabled(false), // mInTouchMode will be initialized by the WindowManager to the default device config. // To avoid leaking stack in case that call never comes, and for tests, // initialize it here anyways. mInTouchMode(kDefaultInTouchMode), mMaximumObscuringOpacityForTouch(1.0f), mFocusedDisplayId(ADISPLAY_ID_DEFAULT), mWindowTokenWithPointerCapture(nullptr), mStaleEventTimeout(staleEventTimeout), mLatencyAggregator(), mLatencyTracker(&mLatencyAggregator), kPerDisplayTouchModeEnabled(mPolicy->isPerDisplayTouchModeEnabled()) { mLatencyTracker(&mLatencyAggregator) { mLooper = sp<Looper>::make(false); mReporter = createInputReporter(); Loading @@ -562,7 +557,6 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic SurfaceComposerClient::getDefault()->addWindowInfosListener(mWindowInfoListener); mKeyRepeatState.lastKeyEntry = nullptr; policy->getDispatcherConfiguration(&mConfig); } Loading Loading @@ -1435,7 +1429,7 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( void InputDispatcher::dispatchTouchModeChangeLocked(nsecs_t currentTime, const std::shared_ptr<TouchModeEntry>& entry) { const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(mFocusedDisplayId); getWindowHandlesLocked(entry->displayId); if (windowHandles.empty()) { return; } Loading @@ -1452,7 +1446,6 @@ std::vector<InputTarget> InputDispatcher::getInputTargetsFromWindowHandlesLocked const std::vector<sp<WindowInfoHandle>>& windowHandles) const { std::vector<InputTarget> inputTargets; for (const sp<WindowInfoHandle>& handle : windowHandles) { // TODO(b/193718270): Due to performance concerns, consider notifying visible windows only. const sp<IBinder>& token = handle->getToken(); if (token == nullptr) { continue; Loading Loading @@ -5012,15 +5005,20 @@ bool InputDispatcher::setInTouchMode(bool inTouchMode, int32_t pid, int32_t uid, bool needWake = false; { std::scoped_lock lock(mLock); if (mInTouchMode == inTouchMode) { ALOGD_IF(DEBUG_TOUCH_MODE, "Request to change touch mode to %s (calling pid=%d, uid=%d, " "hasPermission=%s, target displayId=%d, mTouchModePerDisplay[displayId]=%s)", toString(inTouchMode), pid, uid, toString(hasPermission), displayId, mTouchModePerDisplay.count(displayId) == 0 ? "not set" : std::to_string(mTouchModePerDisplay[displayId]).c_str()); // TODO(b/198499018): Ensure that WM can guarantee that touch mode is properly set when // display is created. auto touchModeIt = mTouchModePerDisplay.find(displayId); if (touchModeIt != mTouchModePerDisplay.end() && touchModeIt->second == inTouchMode) { return false; } if (DEBUG_TOUCH_MODE) { ALOGD("Request to change touch mode from %s to %s (calling pid=%d, uid=%d, " "hasPermission=%s, target displayId=%d, perDisplayTouchModeEnabled=%s)", toString(mInTouchMode), toString(inTouchMode), pid, uid, toString(hasPermission), displayId, toString(kPerDisplayTouchModeEnabled)); } if (!hasPermission) { if (!focusedWindowIsOwnedByLocked(pid, uid) && !recentWindowsAreOwnedByLocked(pid, uid)) { Loading @@ -5030,11 +5028,9 @@ bool InputDispatcher::setInTouchMode(bool inTouchMode, int32_t pid, int32_t uid, return false; } } // TODO(b/198499018): Store touch mode per display (kPerDisplayTouchModeEnabled) mInTouchMode = inTouchMode; auto entry = std::make_unique<TouchModeEntry>(mIdGenerator.nextId(), now(), inTouchMode); mTouchModePerDisplay[displayId] = inTouchMode; auto entry = std::make_unique<TouchModeEntry>(mIdGenerator.nextId(), now(), inTouchMode, displayId); needWake = enqueueInboundEventLocked(std::move(entry)); } // release lock Loading Loading @@ -5474,6 +5470,16 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) { dump += INDENT "AppSwitch: not pending\n"; } if (!mTouchModePerDisplay.empty()) { dump += INDENT "TouchModePerDisplay:\n"; for (const auto& [displayId, touchMode] : mTouchModePerDisplay) { dump += StringPrintf(INDENT2 "Display: %" PRId32 " TouchMode: %s\n", displayId, std::to_string(touchMode).c_str()); } } else { dump += INDENT "TouchModePerDisplay: <none>\n"; } dump += INDENT "Configuration:\n"; dump += StringPrintf(INDENT2 "KeyRepeatDelay: %" PRId64 "ms\n", ns2ms(mConfig.keyRepeatDelay)); dump += StringPrintf(INDENT2 "KeyRepeatTimeout: %" PRId64 "ms\n", Loading Loading @@ -6366,6 +6372,8 @@ void InputDispatcher::displayRemoved(int32_t displayId) { mFocusResolver.displayRemoved(displayId); // Reset pointer capture eligibility, regardless of previous state. std::erase(mIneligibleDisplaysForPointerCapture, displayId); // Remove the associated touch mode state. mTouchModePerDisplay.erase(displayId); } // release lock // Wake up poll loop since it may need to make new input dispatching choices. Loading services/inputflinger/dispatcher/InputDispatcher.h +6 −5 Original line number Diff line number Diff line Loading @@ -342,9 +342,13 @@ private: bool mDispatchEnabled GUARDED_BY(mLock); bool mDispatchFrozen GUARDED_BY(mLock); bool mInputFilterEnabled GUARDED_BY(mLock); bool mInTouchMode GUARDED_BY(mLock); float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock); // This map is not really needed, but it helps a lot with debugging (dumpsys input). // In the java layer, touch mode states are spread across multiple DisplayContent objects, // making harder to snapshot and retrieve them. std::map<int32_t /*displayId*/, bool /*inTouchMode*/> mTouchModePerDisplay GUARDED_BY(mLock); class DispatcherWindowListener : public gui::WindowInfosListener { public: explicit DispatcherWindowListener(InputDispatcher& dispatcher) : mDispatcher(dispatcher){}; Loading Loading @@ -383,7 +387,7 @@ private: bool hasResponsiveConnectionLocked(android::gui::WindowInfoHandle& windowHandle) const REQUIRES(mLock); // Gets all the input targets (with their respective input channels) from the window handles // Returns all the input targets (with their respective input channels) from the window handles // passed as argument. std::vector<InputTarget> getInputTargetsFromWindowHandlesLocked( const std::vector<sp<android::gui::WindowInfoHandle>>& windowHandles) const Loading Loading @@ -684,9 +688,6 @@ private: bool focusedWindowIsOwnedByLocked(int32_t pid, int32_t uid) REQUIRES(mLock); bool recentWindowsAreOwnedByLocked(int32_t pid, int32_t uid) REQUIRES(mLock); // Per display touch mode enabled const bool kPerDisplayTouchModeEnabled; sp<InputReporterInterface> mReporter; }; Loading Loading
services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -112,8 +112,6 @@ private: void notifyDropWindow(const sp<IBinder>&, float x, float y) override {} bool isPerDisplayTouchModeEnabled() override { return false; } InputDispatcherConfiguration mConfig; }; Loading
services/inputflinger/dispatcher/Entry.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -195,9 +195,10 @@ void KeyEntry::recycle() { // --- TouchModeEntry --- TouchModeEntry::TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode) TouchModeEntry::TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode, int displayId) : EventEntry(id, Type::TOUCH_MODE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER), inTouchMode(inTouchMode) {} inTouchMode(inTouchMode), displayId(displayId) {} TouchModeEntry::~TouchModeEntry() {} Loading
services/inputflinger/dispatcher/Entry.h +2 −1 Original line number Diff line number Diff line Loading @@ -210,8 +210,9 @@ struct SensorEntry : EventEntry { struct TouchModeEntry : EventEntry { bool inTouchMode; int32_t displayId; TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode); TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode, int32_t displayId); std::string getDescription() const override; ~TouchModeEntry() override; Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +29 −21 Original line number Diff line number Diff line Loading @@ -544,17 +544,12 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic mDispatchEnabled(false), mDispatchFrozen(false), mInputFilterEnabled(false), // mInTouchMode will be initialized by the WindowManager to the default device config. // To avoid leaking stack in case that call never comes, and for tests, // initialize it here anyways. mInTouchMode(kDefaultInTouchMode), mMaximumObscuringOpacityForTouch(1.0f), mFocusedDisplayId(ADISPLAY_ID_DEFAULT), mWindowTokenWithPointerCapture(nullptr), mStaleEventTimeout(staleEventTimeout), mLatencyAggregator(), mLatencyTracker(&mLatencyAggregator), kPerDisplayTouchModeEnabled(mPolicy->isPerDisplayTouchModeEnabled()) { mLatencyTracker(&mLatencyAggregator) { mLooper = sp<Looper>::make(false); mReporter = createInputReporter(); Loading @@ -562,7 +557,6 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic SurfaceComposerClient::getDefault()->addWindowInfosListener(mWindowInfoListener); mKeyRepeatState.lastKeyEntry = nullptr; policy->getDispatcherConfiguration(&mConfig); } Loading Loading @@ -1435,7 +1429,7 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( void InputDispatcher::dispatchTouchModeChangeLocked(nsecs_t currentTime, const std::shared_ptr<TouchModeEntry>& entry) { const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(mFocusedDisplayId); getWindowHandlesLocked(entry->displayId); if (windowHandles.empty()) { return; } Loading @@ -1452,7 +1446,6 @@ std::vector<InputTarget> InputDispatcher::getInputTargetsFromWindowHandlesLocked const std::vector<sp<WindowInfoHandle>>& windowHandles) const { std::vector<InputTarget> inputTargets; for (const sp<WindowInfoHandle>& handle : windowHandles) { // TODO(b/193718270): Due to performance concerns, consider notifying visible windows only. const sp<IBinder>& token = handle->getToken(); if (token == nullptr) { continue; Loading Loading @@ -5012,15 +5005,20 @@ bool InputDispatcher::setInTouchMode(bool inTouchMode, int32_t pid, int32_t uid, bool needWake = false; { std::scoped_lock lock(mLock); if (mInTouchMode == inTouchMode) { ALOGD_IF(DEBUG_TOUCH_MODE, "Request to change touch mode to %s (calling pid=%d, uid=%d, " "hasPermission=%s, target displayId=%d, mTouchModePerDisplay[displayId]=%s)", toString(inTouchMode), pid, uid, toString(hasPermission), displayId, mTouchModePerDisplay.count(displayId) == 0 ? "not set" : std::to_string(mTouchModePerDisplay[displayId]).c_str()); // TODO(b/198499018): Ensure that WM can guarantee that touch mode is properly set when // display is created. auto touchModeIt = mTouchModePerDisplay.find(displayId); if (touchModeIt != mTouchModePerDisplay.end() && touchModeIt->second == inTouchMode) { return false; } if (DEBUG_TOUCH_MODE) { ALOGD("Request to change touch mode from %s to %s (calling pid=%d, uid=%d, " "hasPermission=%s, target displayId=%d, perDisplayTouchModeEnabled=%s)", toString(mInTouchMode), toString(inTouchMode), pid, uid, toString(hasPermission), displayId, toString(kPerDisplayTouchModeEnabled)); } if (!hasPermission) { if (!focusedWindowIsOwnedByLocked(pid, uid) && !recentWindowsAreOwnedByLocked(pid, uid)) { Loading @@ -5030,11 +5028,9 @@ bool InputDispatcher::setInTouchMode(bool inTouchMode, int32_t pid, int32_t uid, return false; } } // TODO(b/198499018): Store touch mode per display (kPerDisplayTouchModeEnabled) mInTouchMode = inTouchMode; auto entry = std::make_unique<TouchModeEntry>(mIdGenerator.nextId(), now(), inTouchMode); mTouchModePerDisplay[displayId] = inTouchMode; auto entry = std::make_unique<TouchModeEntry>(mIdGenerator.nextId(), now(), inTouchMode, displayId); needWake = enqueueInboundEventLocked(std::move(entry)); } // release lock Loading Loading @@ -5474,6 +5470,16 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) { dump += INDENT "AppSwitch: not pending\n"; } if (!mTouchModePerDisplay.empty()) { dump += INDENT "TouchModePerDisplay:\n"; for (const auto& [displayId, touchMode] : mTouchModePerDisplay) { dump += StringPrintf(INDENT2 "Display: %" PRId32 " TouchMode: %s\n", displayId, std::to_string(touchMode).c_str()); } } else { dump += INDENT "TouchModePerDisplay: <none>\n"; } dump += INDENT "Configuration:\n"; dump += StringPrintf(INDENT2 "KeyRepeatDelay: %" PRId64 "ms\n", ns2ms(mConfig.keyRepeatDelay)); dump += StringPrintf(INDENT2 "KeyRepeatTimeout: %" PRId64 "ms\n", Loading Loading @@ -6366,6 +6372,8 @@ void InputDispatcher::displayRemoved(int32_t displayId) { mFocusResolver.displayRemoved(displayId); // Reset pointer capture eligibility, regardless of previous state. std::erase(mIneligibleDisplaysForPointerCapture, displayId); // Remove the associated touch mode state. mTouchModePerDisplay.erase(displayId); } // release lock // Wake up poll loop since it may need to make new input dispatching choices. Loading
services/inputflinger/dispatcher/InputDispatcher.h +6 −5 Original line number Diff line number Diff line Loading @@ -342,9 +342,13 @@ private: bool mDispatchEnabled GUARDED_BY(mLock); bool mDispatchFrozen GUARDED_BY(mLock); bool mInputFilterEnabled GUARDED_BY(mLock); bool mInTouchMode GUARDED_BY(mLock); float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock); // This map is not really needed, but it helps a lot with debugging (dumpsys input). // In the java layer, touch mode states are spread across multiple DisplayContent objects, // making harder to snapshot and retrieve them. std::map<int32_t /*displayId*/, bool /*inTouchMode*/> mTouchModePerDisplay GUARDED_BY(mLock); class DispatcherWindowListener : public gui::WindowInfosListener { public: explicit DispatcherWindowListener(InputDispatcher& dispatcher) : mDispatcher(dispatcher){}; Loading Loading @@ -383,7 +387,7 @@ private: bool hasResponsiveConnectionLocked(android::gui::WindowInfoHandle& windowHandle) const REQUIRES(mLock); // Gets all the input targets (with their respective input channels) from the window handles // Returns all the input targets (with their respective input channels) from the window handles // passed as argument. std::vector<InputTarget> getInputTargetsFromWindowHandlesLocked( const std::vector<sp<android::gui::WindowInfoHandle>>& windowHandles) const Loading Loading @@ -684,9 +688,6 @@ private: bool focusedWindowIsOwnedByLocked(int32_t pid, int32_t uid) REQUIRES(mLock); bool recentWindowsAreOwnedByLocked(int32_t pid, int32_t uid) REQUIRES(mLock); // Per display touch mode enabled const bool kPerDisplayTouchModeEnabled; sp<InputReporterInterface> mReporter; }; Loading