Loading services/inputflinger/dispatcher/InputDispatcher.cpp +12 −11 Original line number Diff line number Diff line Loading @@ -2967,7 +2967,7 @@ void InputDispatcher::updateInteractionTokensLocked(const EventEntry& entry, return; // Not a key or a motion } std::unordered_set<sp<IBinder>, IBinderHash> newConnectionTokens; std::unordered_set<sp<IBinder>, StrongPointerHash<IBinder>> newConnectionTokens; std::vector<sp<Connection>> newConnections; for (const InputTarget& target : targets) { if ((target.flags & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) == Loading Loading @@ -4284,12 +4284,8 @@ sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked(const sp<IBinder>& return nullptr; } sp<InputWindowHandle> InputDispatcher::getFocusedWindowHandleLocked(int displayId) const { sp<IBinder> focusedToken = mFocusResolver.getFocusedWindowToken(displayId); return getWindowHandleLocked(focusedToken, displayId); } bool InputDispatcher::hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const { sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked( const sp<InputWindowHandle>& windowHandle) const { for (auto& it : mWindowHandlesByDisplay) { const std::vector<sp<InputWindowHandle>>& windowHandles = it.second; for (const sp<InputWindowHandle>& handle : windowHandles) { Loading @@ -4301,11 +4297,16 @@ bool InputDispatcher::hasWindowHandleLocked(const sp<InputWindowHandle>& windowH windowHandle->getName().c_str(), it.first, windowHandle->getInfo()->displayId); } return true; return handle; } } } return false; return nullptr; } sp<InputWindowHandle> InputDispatcher::getFocusedWindowHandleLocked(int displayId) const { sp<IBinder> focusedToken = mFocusResolver.getFocusedWindowToken(displayId); return getWindowHandleLocked(focusedToken, displayId); } bool InputDispatcher::hasResponsiveConnectionLocked(InputWindowHandle& windowHandle) const { Loading Loading @@ -4461,7 +4462,7 @@ void InputDispatcher::setInputWindowsLocked( TouchState& state = stateIt->second; for (size_t i = 0; i < state.windows.size();) { TouchedWindow& touchedWindow = state.windows[i]; if (!hasWindowHandleLocked(touchedWindow.windowHandle)) { if (getWindowHandleLocked(touchedWindow.windowHandle) == nullptr) { if (DEBUG_FOCUS) { ALOGD("Touched window was removed: %s in display %" PRId32, touchedWindow.windowHandle->getName().c_str(), displayId); Loading Loading @@ -4493,7 +4494,7 @@ void InputDispatcher::setInputWindowsLocked( // Otherwise, they might stick around until the window handle is destroyed // which might not happen until the next GC. for (const sp<InputWindowHandle>& oldWindowHandle : oldWindowHandles) { if (!hasWindowHandleLocked(oldWindowHandle)) { if (getWindowHandleLocked(oldWindowHandle) == nullptr) { if (DEBUG_FOCUS) { ALOGD("Window went away: %s", oldWindowHandle->getName().c_str()); } Loading services/inputflinger/dispatcher/InputDispatcher.h +8 −7 Original line number Diff line number Diff line Loading @@ -221,12 +221,11 @@ private: void removeConnectionLocked(const sp<Connection>& connection) REQUIRES(mLock); struct IBinderHash { std::size_t operator()(const sp<IBinder>& b) const { return std::hash<IBinder*>{}(b.get()); } template <typename T> struct StrongPointerHash { std::size_t operator()(const sp<T>& b) const { return std::hash<T*>{}(b.get()); } }; std::unordered_map<sp<IBinder>, std::shared_ptr<InputChannel>, IBinderHash> std::unordered_map<sp<IBinder>, std::shared_ptr<InputChannel>, StrongPointerHash<IBinder>> mInputChannelsByToken GUARDED_BY(mLock); // Finds the display ID of the gesture monitor identified by the provided token. Loading Loading @@ -327,10 +326,11 @@ private: // to loop through all displays. sp<InputWindowHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken, int displayId) const REQUIRES(mLock); sp<InputWindowHandle> getWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock); std::shared_ptr<InputChannel> getInputChannelLocked(const sp<IBinder>& windowToken) const REQUIRES(mLock); sp<InputWindowHandle> getFocusedWindowHandleLocked(int displayId) const REQUIRES(mLock); bool hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock); bool hasResponsiveConnectionLocked(InputWindowHandle& windowHandle) const REQUIRES(mLock); /* Loading Loading @@ -371,7 +371,8 @@ private: std::string mLastAnrState GUARDED_BY(mLock); // The connection tokens of the channels that the user last interacted, for debugging std::unordered_set<sp<IBinder>, IBinderHash> mInteractionConnectionTokens GUARDED_BY(mLock); std::unordered_set<sp<IBinder>, StrongPointerHash<IBinder>> mInteractionConnectionTokens GUARDED_BY(mLock); void updateInteractionTokensLocked(const EventEntry& entry, const std::vector<InputTarget>& targets) REQUIRES(mLock); Loading Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +12 −11 Original line number Diff line number Diff line Loading @@ -2967,7 +2967,7 @@ void InputDispatcher::updateInteractionTokensLocked(const EventEntry& entry, return; // Not a key or a motion } std::unordered_set<sp<IBinder>, IBinderHash> newConnectionTokens; std::unordered_set<sp<IBinder>, StrongPointerHash<IBinder>> newConnectionTokens; std::vector<sp<Connection>> newConnections; for (const InputTarget& target : targets) { if ((target.flags & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) == Loading Loading @@ -4284,12 +4284,8 @@ sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked(const sp<IBinder>& return nullptr; } sp<InputWindowHandle> InputDispatcher::getFocusedWindowHandleLocked(int displayId) const { sp<IBinder> focusedToken = mFocusResolver.getFocusedWindowToken(displayId); return getWindowHandleLocked(focusedToken, displayId); } bool InputDispatcher::hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const { sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked( const sp<InputWindowHandle>& windowHandle) const { for (auto& it : mWindowHandlesByDisplay) { const std::vector<sp<InputWindowHandle>>& windowHandles = it.second; for (const sp<InputWindowHandle>& handle : windowHandles) { Loading @@ -4301,11 +4297,16 @@ bool InputDispatcher::hasWindowHandleLocked(const sp<InputWindowHandle>& windowH windowHandle->getName().c_str(), it.first, windowHandle->getInfo()->displayId); } return true; return handle; } } } return false; return nullptr; } sp<InputWindowHandle> InputDispatcher::getFocusedWindowHandleLocked(int displayId) const { sp<IBinder> focusedToken = mFocusResolver.getFocusedWindowToken(displayId); return getWindowHandleLocked(focusedToken, displayId); } bool InputDispatcher::hasResponsiveConnectionLocked(InputWindowHandle& windowHandle) const { Loading Loading @@ -4461,7 +4462,7 @@ void InputDispatcher::setInputWindowsLocked( TouchState& state = stateIt->second; for (size_t i = 0; i < state.windows.size();) { TouchedWindow& touchedWindow = state.windows[i]; if (!hasWindowHandleLocked(touchedWindow.windowHandle)) { if (getWindowHandleLocked(touchedWindow.windowHandle) == nullptr) { if (DEBUG_FOCUS) { ALOGD("Touched window was removed: %s in display %" PRId32, touchedWindow.windowHandle->getName().c_str(), displayId); Loading Loading @@ -4493,7 +4494,7 @@ void InputDispatcher::setInputWindowsLocked( // Otherwise, they might stick around until the window handle is destroyed // which might not happen until the next GC. for (const sp<InputWindowHandle>& oldWindowHandle : oldWindowHandles) { if (!hasWindowHandleLocked(oldWindowHandle)) { if (getWindowHandleLocked(oldWindowHandle) == nullptr) { if (DEBUG_FOCUS) { ALOGD("Window went away: %s", oldWindowHandle->getName().c_str()); } Loading
services/inputflinger/dispatcher/InputDispatcher.h +8 −7 Original line number Diff line number Diff line Loading @@ -221,12 +221,11 @@ private: void removeConnectionLocked(const sp<Connection>& connection) REQUIRES(mLock); struct IBinderHash { std::size_t operator()(const sp<IBinder>& b) const { return std::hash<IBinder*>{}(b.get()); } template <typename T> struct StrongPointerHash { std::size_t operator()(const sp<T>& b) const { return std::hash<T*>{}(b.get()); } }; std::unordered_map<sp<IBinder>, std::shared_ptr<InputChannel>, IBinderHash> std::unordered_map<sp<IBinder>, std::shared_ptr<InputChannel>, StrongPointerHash<IBinder>> mInputChannelsByToken GUARDED_BY(mLock); // Finds the display ID of the gesture monitor identified by the provided token. Loading Loading @@ -327,10 +326,11 @@ private: // to loop through all displays. sp<InputWindowHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken, int displayId) const REQUIRES(mLock); sp<InputWindowHandle> getWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock); std::shared_ptr<InputChannel> getInputChannelLocked(const sp<IBinder>& windowToken) const REQUIRES(mLock); sp<InputWindowHandle> getFocusedWindowHandleLocked(int displayId) const REQUIRES(mLock); bool hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock); bool hasResponsiveConnectionLocked(InputWindowHandle& windowHandle) const REQUIRES(mLock); /* Loading Loading @@ -371,7 +371,8 @@ private: std::string mLastAnrState GUARDED_BY(mLock); // The connection tokens of the channels that the user last interacted, for debugging std::unordered_set<sp<IBinder>, IBinderHash> mInteractionConnectionTokens GUARDED_BY(mLock); std::unordered_set<sp<IBinder>, StrongPointerHash<IBinder>> mInteractionConnectionTokens GUARDED_BY(mLock); void updateInteractionTokensLocked(const EventEntry& entry, const std::vector<InputTarget>& targets) REQUIRES(mLock); Loading