Loading services/inputflinger/InputListener.cpp +32 −35 Original line number Diff line number Diff line Loading @@ -47,16 +47,14 @@ Visitor(V...) -> Visitor<V...>; void InputListenerInterface::notify(const NotifyArgs& generalArgs) { Visitor v{ [&](const NotifyInputDevicesChangedArgs& args) { notifyInputDevicesChanged(args); }, [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(&args); }, [&](const NotifyKeyArgs& args) { notifyKey(&args); }, [&](const NotifyMotionArgs& args) { notifyMotion(&args); }, [&](const NotifySwitchArgs& args) { notifySwitch(&args); }, [&](const NotifySensorArgs& args) { notifySensor(&args); }, [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(&args); }, [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(&args); }, [&](const NotifyPointerCaptureChangedArgs& args) { notifyPointerCaptureChanged(&args); }, [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(args); }, [&](const NotifyKeyArgs& args) { notifyKey(args); }, [&](const NotifyMotionArgs& args) { notifyMotion(args); }, [&](const NotifySwitchArgs& args) { notifySwitch(args); }, [&](const NotifySensorArgs& args) { notifySensor(args); }, [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(args); }, [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(args); }, [&](const NotifyPointerCaptureChangedArgs& args) { notifyPointerCaptureChanged(args); }, }; std::visit(v, generalArgs); } Loading @@ -78,45 +76,44 @@ void QueuedInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChan mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyConfigurationChanged( const NotifyConfigurationChangedArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyKey(const NotifyKeyArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyMotion(const NotifyMotionArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifySwitch(const NotifySwitchArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifySensor(const NotifySensorArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifySensor(const NotifySensorArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::flush() { Loading services/inputflinger/InputProcessor.cpp +14 −14 Original line number Diff line number Diff line Loading @@ -419,63 +419,63 @@ void InputProcessor::notifyInputDevicesChanged(const NotifyInputDevicesChangedAr mQueuedListener.flush(); } void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) { void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) { // pass through mQueuedListener.notifyConfigurationChanged(args); mQueuedListener.flush(); } void InputProcessor::notifyKey(const NotifyKeyArgs* args) { void InputProcessor::notifyKey(const NotifyKeyArgs& args) { // pass through mQueuedListener.notifyKey(args); mQueuedListener.flush(); } void InputProcessor::notifyMotion(const NotifyMotionArgs* args) { void InputProcessor::notifyMotion(const NotifyMotionArgs& args) { { // acquire lock std::scoped_lock lock(mLock); // MotionClassifier is only used for touch events, for now const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(*args); const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(args); if (!sendToMotionClassifier) { mQueuedListener.notifyMotion(args); } else { NotifyMotionArgs newArgs(*args); NotifyMotionArgs newArgs(args); const MotionClassification newClassification = mMotionClassifier->classify(newArgs); LOG_ALWAYS_FATAL_IF(args->classification != MotionClassification::NONE && LOG_ALWAYS_FATAL_IF(args.classification != MotionClassification::NONE && newClassification != MotionClassification::NONE, "Conflicting classifications %s (new) and %s (old)!", motionClassificationToString(newClassification), motionClassificationToString(args->classification)); motionClassificationToString(args.classification)); newArgs.classification = newClassification; mQueuedListener.notifyMotion(&newArgs); mQueuedListener.notifyMotion(newArgs); } } // release lock mQueuedListener.flush(); } void InputProcessor::notifySensor(const NotifySensorArgs* args) { void InputProcessor::notifySensor(const NotifySensorArgs& args) { // pass through mQueuedListener.notifySensor(args); mQueuedListener.flush(); } void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs* args) { void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs& args) { // pass through mQueuedListener.notifyVibratorState(args); mQueuedListener.flush(); } void InputProcessor::notifySwitch(const NotifySwitchArgs* args) { void InputProcessor::notifySwitch(const NotifySwitchArgs& args) { // pass through mQueuedListener.notifySwitch(args); mQueuedListener.flush(); } void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs* args) { void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs& args) { { // acquire lock std::scoped_lock lock(mLock); if (mMotionClassifier) { mMotionClassifier->reset(*args); mMotionClassifier->reset(args); } } // release lock Loading @@ -484,7 +484,7 @@ void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs* args) { mQueuedListener.flush(); } void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) { void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) { // pass through mQueuedListener.notifyPointerCaptureChanged(args); mQueuedListener.flush(); Loading services/inputflinger/InputProcessor.h +8 −8 Original line number Diff line number Diff line Loading @@ -246,14 +246,14 @@ public: explicit InputProcessor(InputListenerInterface& listener); void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override; void notifyKey(const NotifyKeyArgs* args) override; void notifyMotion(const NotifyMotionArgs* args) override; void notifySwitch(const NotifySwitchArgs* args) override; void notifySensor(const NotifySensorArgs* args) override; void notifyVibratorState(const NotifyVibratorStateArgs* args) override; void notifyDeviceReset(const NotifyDeviceResetArgs* args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override; void notifyKey(const NotifyKeyArgs& args) override; void notifyMotion(const NotifyMotionArgs& args) override; void notifySwitch(const NotifySwitchArgs& args) override; void notifySensor(const NotifySensorArgs& args) override; void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void dump(std::string& dump) override; void monitor() override; Loading services/inputflinger/UnwantedInteractionBlocker.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -329,24 +329,24 @@ UnwantedInteractionBlocker::UnwantedInteractionBlocker(InputListenerInterface& l : mQueuedListener(listener), mEnablePalmRejection(enablePalmRejection) {} void UnwantedInteractionBlocker::notifyConfigurationChanged( const NotifyConfigurationChangedArgs* args) { const NotifyConfigurationChangedArgs& args) { mQueuedListener.notifyConfigurationChanged(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs* args) { void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs& args) { mQueuedListener.notifyKey(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs* args) { ALOGD_IF(DEBUG_INBOUND_MOTION, "%s: %s", __func__, args->dump().c_str()); void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs& args) { ALOGD_IF(DEBUG_INBOUND_MOTION, "%s: %s", __func__, args.dump().c_str()); { // acquire lock std::scoped_lock lock(mLock); const std::vector<NotifyMotionArgs> processedArgs = mPreferStylusOverTouchBlocker.processMotion(*args); mPreferStylusOverTouchBlocker.processMotion(args); for (const NotifyMotionArgs& loopArgs : processedArgs) { notifyMotionLocked(&loopArgs); notifyMotionLocked(loopArgs); } } // release lock Loading @@ -356,56 +356,56 @@ void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs* args) { void UnwantedInteractionBlocker::enqueueOutboundMotionLocked(const NotifyMotionArgs& args) { ALOGD_IF(DEBUG_OUTBOUND_MOTION, "%s: %s", __func__, args.dump().c_str()); mQueuedListener.notifyMotion(&args); mQueuedListener.notifyMotion(args); } void UnwantedInteractionBlocker::notifyMotionLocked(const NotifyMotionArgs* args) { auto it = mPalmRejectors.find(args->deviceId); const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args->source); void UnwantedInteractionBlocker::notifyMotionLocked(const NotifyMotionArgs& args) { auto it = mPalmRejectors.find(args.deviceId); const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args.source); if (!sendToPalmRejector) { enqueueOutboundMotionLocked(*args); enqueueOutboundMotionLocked(args); return; } std::vector<NotifyMotionArgs> processedArgs = it->second.processMotion(*args); std::vector<NotifyMotionArgs> processedArgs = it->second.processMotion(args); for (const NotifyMotionArgs& loopArgs : processedArgs) { enqueueOutboundMotionLocked(loopArgs); } } void UnwantedInteractionBlocker::notifySwitch(const NotifySwitchArgs* args) { void UnwantedInteractionBlocker::notifySwitch(const NotifySwitchArgs& args) { mQueuedListener.notifySwitch(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifySensor(const NotifySensorArgs* args) { void UnwantedInteractionBlocker::notifySensor(const NotifySensorArgs& args) { mQueuedListener.notifySensor(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyVibratorState(const NotifyVibratorStateArgs* args) { void UnwantedInteractionBlocker::notifyVibratorState(const NotifyVibratorStateArgs& args) { mQueuedListener.notifyVibratorState(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyDeviceReset(const NotifyDeviceResetArgs* args) { void UnwantedInteractionBlocker::notifyDeviceReset(const NotifyDeviceResetArgs& args) { { // acquire lock std::scoped_lock lock(mLock); auto it = mPalmRejectors.find(args->deviceId); auto it = mPalmRejectors.find(args.deviceId); if (it != mPalmRejectors.end()) { AndroidPalmFilterDeviceInfo info = it->second.getPalmFilterDeviceInfo(); // Re-create the object instead of resetting it mPalmRejectors.erase(it); mPalmRejectors.emplace(args->deviceId, info); mPalmRejectors.emplace(args.deviceId, info); } mQueuedListener.notifyDeviceReset(args); mPreferStylusOverTouchBlocker.notifyDeviceReset(*args); mPreferStylusOverTouchBlocker.notifyDeviceReset(args); } // release lock // Send events to the next stage without holding the lock mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyPointerCaptureChanged( const NotifyPointerCaptureChangedArgs* args) { const NotifyPointerCaptureChangedArgs& args) { mQueuedListener.notifyPointerCaptureChanged(args); mQueuedListener.flush(); } Loading services/inputflinger/UnwantedInteractionBlocker.h +9 −9 Original line number Diff line number Diff line Loading @@ -91,14 +91,14 @@ public: explicit UnwantedInteractionBlocker(InputListenerInterface& listener, bool enablePalmRejection); void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override; void notifyKey(const NotifyKeyArgs* args) override; void notifyMotion(const NotifyMotionArgs* args) override; void notifySwitch(const NotifySwitchArgs* args) override; void notifySensor(const NotifySensorArgs* args) override; void notifyVibratorState(const NotifyVibratorStateArgs* args) override; void notifyDeviceReset(const NotifyDeviceResetArgs* args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override; void notifyKey(const NotifyKeyArgs& args) override; void notifyMotion(const NotifyMotionArgs& args) override; void notifySwitch(const NotifySwitchArgs& args) override; void notifySensor(const NotifySensorArgs& args) override; void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void dump(std::string& dump) override; void monitor() override; Loading @@ -119,7 +119,7 @@ private: // Use a separate palm rejector for every touch device. std::map<int32_t /*deviceId*/, PalmRejector> mPalmRejectors GUARDED_BY(mLock); // TODO(b/210159205): delete this when simultaneous stylus and touch is supported void notifyMotionLocked(const NotifyMotionArgs* args) REQUIRES(mLock); void notifyMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock); // Call this function for outbound events so that they can be logged when logging is enabled. void enqueueOutboundMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock); Loading Loading
services/inputflinger/InputListener.cpp +32 −35 Original line number Diff line number Diff line Loading @@ -47,16 +47,14 @@ Visitor(V...) -> Visitor<V...>; void InputListenerInterface::notify(const NotifyArgs& generalArgs) { Visitor v{ [&](const NotifyInputDevicesChangedArgs& args) { notifyInputDevicesChanged(args); }, [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(&args); }, [&](const NotifyKeyArgs& args) { notifyKey(&args); }, [&](const NotifyMotionArgs& args) { notifyMotion(&args); }, [&](const NotifySwitchArgs& args) { notifySwitch(&args); }, [&](const NotifySensorArgs& args) { notifySensor(&args); }, [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(&args); }, [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(&args); }, [&](const NotifyPointerCaptureChangedArgs& args) { notifyPointerCaptureChanged(&args); }, [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(args); }, [&](const NotifyKeyArgs& args) { notifyKey(args); }, [&](const NotifyMotionArgs& args) { notifyMotion(args); }, [&](const NotifySwitchArgs& args) { notifySwitch(args); }, [&](const NotifySensorArgs& args) { notifySensor(args); }, [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(args); }, [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(args); }, [&](const NotifyPointerCaptureChangedArgs& args) { notifyPointerCaptureChanged(args); }, }; std::visit(v, generalArgs); } Loading @@ -78,45 +76,44 @@ void QueuedInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChan mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyConfigurationChanged( const NotifyConfigurationChangedArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyKey(const NotifyKeyArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyMotion(const NotifyMotionArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifySwitch(const NotifySwitchArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifySensor(const NotifySensorArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifySensor(const NotifySensorArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) { traceEvent(__func__, args->id); mArgsQueue.emplace_back(*args); void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) { traceEvent(__func__, args.id); mArgsQueue.emplace_back(args); } void QueuedInputListener::flush() { Loading
services/inputflinger/InputProcessor.cpp +14 −14 Original line number Diff line number Diff line Loading @@ -419,63 +419,63 @@ void InputProcessor::notifyInputDevicesChanged(const NotifyInputDevicesChangedAr mQueuedListener.flush(); } void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) { void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) { // pass through mQueuedListener.notifyConfigurationChanged(args); mQueuedListener.flush(); } void InputProcessor::notifyKey(const NotifyKeyArgs* args) { void InputProcessor::notifyKey(const NotifyKeyArgs& args) { // pass through mQueuedListener.notifyKey(args); mQueuedListener.flush(); } void InputProcessor::notifyMotion(const NotifyMotionArgs* args) { void InputProcessor::notifyMotion(const NotifyMotionArgs& args) { { // acquire lock std::scoped_lock lock(mLock); // MotionClassifier is only used for touch events, for now const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(*args); const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(args); if (!sendToMotionClassifier) { mQueuedListener.notifyMotion(args); } else { NotifyMotionArgs newArgs(*args); NotifyMotionArgs newArgs(args); const MotionClassification newClassification = mMotionClassifier->classify(newArgs); LOG_ALWAYS_FATAL_IF(args->classification != MotionClassification::NONE && LOG_ALWAYS_FATAL_IF(args.classification != MotionClassification::NONE && newClassification != MotionClassification::NONE, "Conflicting classifications %s (new) and %s (old)!", motionClassificationToString(newClassification), motionClassificationToString(args->classification)); motionClassificationToString(args.classification)); newArgs.classification = newClassification; mQueuedListener.notifyMotion(&newArgs); mQueuedListener.notifyMotion(newArgs); } } // release lock mQueuedListener.flush(); } void InputProcessor::notifySensor(const NotifySensorArgs* args) { void InputProcessor::notifySensor(const NotifySensorArgs& args) { // pass through mQueuedListener.notifySensor(args); mQueuedListener.flush(); } void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs* args) { void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs& args) { // pass through mQueuedListener.notifyVibratorState(args); mQueuedListener.flush(); } void InputProcessor::notifySwitch(const NotifySwitchArgs* args) { void InputProcessor::notifySwitch(const NotifySwitchArgs& args) { // pass through mQueuedListener.notifySwitch(args); mQueuedListener.flush(); } void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs* args) { void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs& args) { { // acquire lock std::scoped_lock lock(mLock); if (mMotionClassifier) { mMotionClassifier->reset(*args); mMotionClassifier->reset(args); } } // release lock Loading @@ -484,7 +484,7 @@ void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs* args) { mQueuedListener.flush(); } void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) { void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) { // pass through mQueuedListener.notifyPointerCaptureChanged(args); mQueuedListener.flush(); Loading
services/inputflinger/InputProcessor.h +8 −8 Original line number Diff line number Diff line Loading @@ -246,14 +246,14 @@ public: explicit InputProcessor(InputListenerInterface& listener); void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override; void notifyKey(const NotifyKeyArgs* args) override; void notifyMotion(const NotifyMotionArgs* args) override; void notifySwitch(const NotifySwitchArgs* args) override; void notifySensor(const NotifySensorArgs* args) override; void notifyVibratorState(const NotifyVibratorStateArgs* args) override; void notifyDeviceReset(const NotifyDeviceResetArgs* args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override; void notifyKey(const NotifyKeyArgs& args) override; void notifyMotion(const NotifyMotionArgs& args) override; void notifySwitch(const NotifySwitchArgs& args) override; void notifySensor(const NotifySensorArgs& args) override; void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void dump(std::string& dump) override; void monitor() override; Loading
services/inputflinger/UnwantedInteractionBlocker.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -329,24 +329,24 @@ UnwantedInteractionBlocker::UnwantedInteractionBlocker(InputListenerInterface& l : mQueuedListener(listener), mEnablePalmRejection(enablePalmRejection) {} void UnwantedInteractionBlocker::notifyConfigurationChanged( const NotifyConfigurationChangedArgs* args) { const NotifyConfigurationChangedArgs& args) { mQueuedListener.notifyConfigurationChanged(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs* args) { void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs& args) { mQueuedListener.notifyKey(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs* args) { ALOGD_IF(DEBUG_INBOUND_MOTION, "%s: %s", __func__, args->dump().c_str()); void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs& args) { ALOGD_IF(DEBUG_INBOUND_MOTION, "%s: %s", __func__, args.dump().c_str()); { // acquire lock std::scoped_lock lock(mLock); const std::vector<NotifyMotionArgs> processedArgs = mPreferStylusOverTouchBlocker.processMotion(*args); mPreferStylusOverTouchBlocker.processMotion(args); for (const NotifyMotionArgs& loopArgs : processedArgs) { notifyMotionLocked(&loopArgs); notifyMotionLocked(loopArgs); } } // release lock Loading @@ -356,56 +356,56 @@ void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs* args) { void UnwantedInteractionBlocker::enqueueOutboundMotionLocked(const NotifyMotionArgs& args) { ALOGD_IF(DEBUG_OUTBOUND_MOTION, "%s: %s", __func__, args.dump().c_str()); mQueuedListener.notifyMotion(&args); mQueuedListener.notifyMotion(args); } void UnwantedInteractionBlocker::notifyMotionLocked(const NotifyMotionArgs* args) { auto it = mPalmRejectors.find(args->deviceId); const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args->source); void UnwantedInteractionBlocker::notifyMotionLocked(const NotifyMotionArgs& args) { auto it = mPalmRejectors.find(args.deviceId); const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args.source); if (!sendToPalmRejector) { enqueueOutboundMotionLocked(*args); enqueueOutboundMotionLocked(args); return; } std::vector<NotifyMotionArgs> processedArgs = it->second.processMotion(*args); std::vector<NotifyMotionArgs> processedArgs = it->second.processMotion(args); for (const NotifyMotionArgs& loopArgs : processedArgs) { enqueueOutboundMotionLocked(loopArgs); } } void UnwantedInteractionBlocker::notifySwitch(const NotifySwitchArgs* args) { void UnwantedInteractionBlocker::notifySwitch(const NotifySwitchArgs& args) { mQueuedListener.notifySwitch(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifySensor(const NotifySensorArgs* args) { void UnwantedInteractionBlocker::notifySensor(const NotifySensorArgs& args) { mQueuedListener.notifySensor(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyVibratorState(const NotifyVibratorStateArgs* args) { void UnwantedInteractionBlocker::notifyVibratorState(const NotifyVibratorStateArgs& args) { mQueuedListener.notifyVibratorState(args); mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyDeviceReset(const NotifyDeviceResetArgs* args) { void UnwantedInteractionBlocker::notifyDeviceReset(const NotifyDeviceResetArgs& args) { { // acquire lock std::scoped_lock lock(mLock); auto it = mPalmRejectors.find(args->deviceId); auto it = mPalmRejectors.find(args.deviceId); if (it != mPalmRejectors.end()) { AndroidPalmFilterDeviceInfo info = it->second.getPalmFilterDeviceInfo(); // Re-create the object instead of resetting it mPalmRejectors.erase(it); mPalmRejectors.emplace(args->deviceId, info); mPalmRejectors.emplace(args.deviceId, info); } mQueuedListener.notifyDeviceReset(args); mPreferStylusOverTouchBlocker.notifyDeviceReset(*args); mPreferStylusOverTouchBlocker.notifyDeviceReset(args); } // release lock // Send events to the next stage without holding the lock mQueuedListener.flush(); } void UnwantedInteractionBlocker::notifyPointerCaptureChanged( const NotifyPointerCaptureChangedArgs* args) { const NotifyPointerCaptureChangedArgs& args) { mQueuedListener.notifyPointerCaptureChanged(args); mQueuedListener.flush(); } Loading
services/inputflinger/UnwantedInteractionBlocker.h +9 −9 Original line number Diff line number Diff line Loading @@ -91,14 +91,14 @@ public: explicit UnwantedInteractionBlocker(InputListenerInterface& listener, bool enablePalmRejection); void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override; void notifyKey(const NotifyKeyArgs* args) override; void notifyMotion(const NotifyMotionArgs* args) override; void notifySwitch(const NotifySwitchArgs* args) override; void notifySensor(const NotifySensorArgs* args) override; void notifyVibratorState(const NotifyVibratorStateArgs* args) override; void notifyDeviceReset(const NotifyDeviceResetArgs* args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override; void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override; void notifyKey(const NotifyKeyArgs& args) override; void notifyMotion(const NotifyMotionArgs& args) override; void notifySwitch(const NotifySwitchArgs& args) override; void notifySensor(const NotifySensorArgs& args) override; void notifyVibratorState(const NotifyVibratorStateArgs& args) override; void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; void dump(std::string& dump) override; void monitor() override; Loading @@ -119,7 +119,7 @@ private: // Use a separate palm rejector for every touch device. std::map<int32_t /*deviceId*/, PalmRejector> mPalmRejectors GUARDED_BY(mLock); // TODO(b/210159205): delete this when simultaneous stylus and touch is supported void notifyMotionLocked(const NotifyMotionArgs* args) REQUIRES(mLock); void notifyMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock); // Call this function for outbound events so that they can be logged when logging is enabled. void enqueueOutboundMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock); Loading