Loading services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ private: void notifyFocusChanged(const sp<IBinder>&, const sp<IBinder>&) override {} void notifyUntrustedTouch(const std::string& obscuringPackage) override {} void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) override { *outConfig = mConfig; } Loading services/inputflinger/dispatcher/Entry.h +1 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,7 @@ struct CommandEntry { std::shared_ptr<InputChannel> inputChannel; sp<IBinder> oldToken; sp<IBinder> newToken; std::string obscuringPackage; }; } // namespace android::inputdispatcher Loading services/inputflinger/dispatcher/InputDispatcher.cpp +22 −8 Original line number Diff line number Diff line Loading @@ -1773,16 +1773,15 @@ InputEventInjectionResult InputDispatcher::findTouchedWindowTargetsLocked( mBlockUntrustedTouchesMode != BlockUntrustedTouchesMode::DISABLED) { TouchOcclusionInfo occlusionInfo = computeTouchOcclusionInfoLocked(newTouchedWindowHandle, x, y); // The order of the operands in the 'if' below is important because even if the feature // is not BLOCK we want isTouchTrustedLocked() to execute in order to log details to // logcat. if (!isTouchTrustedLocked(occlusionInfo) && mBlockUntrustedTouchesMode == BlockUntrustedTouchesMode::BLOCK) { if (!isTouchTrustedLocked(occlusionInfo)) { onUntrustedTouchLocked(occlusionInfo.obscuringPackage); if (mBlockUntrustedTouchesMode == BlockUntrustedTouchesMode::BLOCK) { ALOGW("Dropping untrusted touch event due to %s/%d", occlusionInfo.obscuringPackage.c_str(), occlusionInfo.obscuringUid); newTouchedWindowHandle = nullptr; } } } // Also don't send the new touch event to unresponsive gesture monitors newGestureMonitors = selectResponsiveMonitorsLocked(newGestureMonitors); Loading Loading @@ -4878,6 +4877,13 @@ void InputDispatcher::onAnrLocked(const std::shared_ptr<InputApplicationHandle>& postCommandLocked(std::move(commandEntry)); } void InputDispatcher::onUntrustedTouchLocked(const std::string& obscuringPackage) { std::unique_ptr<CommandEntry> commandEntry = std::make_unique<CommandEntry>( &InputDispatcher::doNotifyUntrustedTouchLockedInterruptible); commandEntry->obscuringPackage = obscuringPackage; postCommandLocked(std::move(commandEntry)); } void InputDispatcher::updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason) { const std::string windowLabel = getApplicationWindowLabel(nullptr, window); Loading Loading @@ -4956,6 +4962,14 @@ void InputDispatcher::doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) } } void InputDispatcher::doNotifyUntrustedTouchLockedInterruptible(CommandEntry* commandEntry) { mLock.unlock(); mPolicy->notifyUntrustedTouch(commandEntry->obscuringPackage); mLock.lock(); } void InputDispatcher::extendAnrTimeoutsLocked( const std::shared_ptr<InputApplicationHandle>& application, const sp<IBinder>& connectionToken, std::chrono::nanoseconds timeoutExtension) { Loading services/inputflinger/dispatcher/InputDispatcher.h +2 −0 Original line number Diff line number Diff line Loading @@ -547,6 +547,7 @@ private: REQUIRES(mLock); void onAnrLocked(const Connection& connection) REQUIRES(mLock); void onAnrLocked(const std::shared_ptr<InputApplicationHandle>& application) REQUIRES(mLock); void onUntrustedTouchLocked(const std::string& obscuringPackage) REQUIRES(mLock); void updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason) REQUIRES(mLock); void updateLastAnrStateLocked(const std::shared_ptr<InputApplicationHandle>& application, Loading @@ -560,6 +561,7 @@ private: void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doNotifyFocusChangedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doNotifyUntrustedTouchLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doInterceptKeyBeforeDispatchingLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); Loading services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ public: virtual void notifyInputChannelBroken(const sp<IBinder>& token) = 0; virtual void notifyFocusChanged(const sp<IBinder>& oldToken, const sp<IBinder>& newToken) = 0; /* Notifies the system that an untrusted touch occurred. */ virtual void notifyUntrustedTouch(const std::string& obscuringPackage) = 0; /* Gets the input dispatcher configuration. */ virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) = 0; Loading Loading
services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ private: void notifyFocusChanged(const sp<IBinder>&, const sp<IBinder>&) override {} void notifyUntrustedTouch(const std::string& obscuringPackage) override {} void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) override { *outConfig = mConfig; } Loading
services/inputflinger/dispatcher/Entry.h +1 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,7 @@ struct CommandEntry { std::shared_ptr<InputChannel> inputChannel; sp<IBinder> oldToken; sp<IBinder> newToken; std::string obscuringPackage; }; } // namespace android::inputdispatcher Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +22 −8 Original line number Diff line number Diff line Loading @@ -1773,16 +1773,15 @@ InputEventInjectionResult InputDispatcher::findTouchedWindowTargetsLocked( mBlockUntrustedTouchesMode != BlockUntrustedTouchesMode::DISABLED) { TouchOcclusionInfo occlusionInfo = computeTouchOcclusionInfoLocked(newTouchedWindowHandle, x, y); // The order of the operands in the 'if' below is important because even if the feature // is not BLOCK we want isTouchTrustedLocked() to execute in order to log details to // logcat. if (!isTouchTrustedLocked(occlusionInfo) && mBlockUntrustedTouchesMode == BlockUntrustedTouchesMode::BLOCK) { if (!isTouchTrustedLocked(occlusionInfo)) { onUntrustedTouchLocked(occlusionInfo.obscuringPackage); if (mBlockUntrustedTouchesMode == BlockUntrustedTouchesMode::BLOCK) { ALOGW("Dropping untrusted touch event due to %s/%d", occlusionInfo.obscuringPackage.c_str(), occlusionInfo.obscuringUid); newTouchedWindowHandle = nullptr; } } } // Also don't send the new touch event to unresponsive gesture monitors newGestureMonitors = selectResponsiveMonitorsLocked(newGestureMonitors); Loading Loading @@ -4878,6 +4877,13 @@ void InputDispatcher::onAnrLocked(const std::shared_ptr<InputApplicationHandle>& postCommandLocked(std::move(commandEntry)); } void InputDispatcher::onUntrustedTouchLocked(const std::string& obscuringPackage) { std::unique_ptr<CommandEntry> commandEntry = std::make_unique<CommandEntry>( &InputDispatcher::doNotifyUntrustedTouchLockedInterruptible); commandEntry->obscuringPackage = obscuringPackage; postCommandLocked(std::move(commandEntry)); } void InputDispatcher::updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason) { const std::string windowLabel = getApplicationWindowLabel(nullptr, window); Loading Loading @@ -4956,6 +4962,14 @@ void InputDispatcher::doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) } } void InputDispatcher::doNotifyUntrustedTouchLockedInterruptible(CommandEntry* commandEntry) { mLock.unlock(); mPolicy->notifyUntrustedTouch(commandEntry->obscuringPackage); mLock.lock(); } void InputDispatcher::extendAnrTimeoutsLocked( const std::shared_ptr<InputApplicationHandle>& application, const sp<IBinder>& connectionToken, std::chrono::nanoseconds timeoutExtension) { Loading
services/inputflinger/dispatcher/InputDispatcher.h +2 −0 Original line number Diff line number Diff line Loading @@ -547,6 +547,7 @@ private: REQUIRES(mLock); void onAnrLocked(const Connection& connection) REQUIRES(mLock); void onAnrLocked(const std::shared_ptr<InputApplicationHandle>& application) REQUIRES(mLock); void onUntrustedTouchLocked(const std::string& obscuringPackage) REQUIRES(mLock); void updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason) REQUIRES(mLock); void updateLastAnrStateLocked(const std::shared_ptr<InputApplicationHandle>& application, Loading @@ -560,6 +561,7 @@ private: void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doNotifyFocusChangedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doNotifyAnrLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doNotifyUntrustedTouchLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doInterceptKeyBeforeDispatchingLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); Loading
services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h +3 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ public: virtual void notifyInputChannelBroken(const sp<IBinder>& token) = 0; virtual void notifyFocusChanged(const sp<IBinder>& oldToken, const sp<IBinder>& newToken) = 0; /* Notifies the system that an untrusted touch occurred. */ virtual void notifyUntrustedTouch(const std::string& obscuringPackage) = 0; /* Gets the input dispatcher configuration. */ virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) = 0; Loading