Loading libs/input/rust/lib.rs +9 −1 Original line number Diff line number Diff line Loading @@ -79,12 +79,20 @@ fn process_movement( pointer_properties: &[RustPointerProperties], flags: u32, ) -> String { let motion_flags = MotionFlags::from_bits(flags); if motion_flags.is_none() { panic!( "The conversion of flags 0x{:08x} failed, please check if some flags have not been \ added to MotionFlags.", flags ); } let result = verifier.process_movement( DeviceId(device_id), Source::from_bits(source).unwrap(), action, pointer_properties, MotionFlags::from_bits(flags).unwrap(), motion_flags.unwrap(), ); match result { Ok(()) => "".to_string(), Loading services/inputflinger/dispatcher/InputDispatcher.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -4732,6 +4732,7 @@ void InputDispatcher::notifySwitch(const NotifySwitchArgs& args) { } void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs& args) { // TODO(b/308677868) Remove device reset from the InputListener interface if (debugInboundEventDetails()) { ALOGD("notifyDeviceReset - eventTime=%" PRId64 ", deviceId=%d", args.eventTime, args.deviceId); Loading Loading @@ -4882,6 +4883,30 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev } mLock.lock(); if (policyFlags & POLICY_FLAG_FILTERED) { // The events from InputFilter impersonate real hardware devices. Check these // events for consistency and print an error. An inconsistent event sent from // InputFilter could cause a crash in the later stages of dispatching pipeline. auto [it, _] = mInputFilterVerifiersByDisplay .try_emplace(displayId, StringPrintf("Injection on %" PRId32, displayId)); InputVerifier& verifier = it->second; Result<void> result = verifier.processMovement(resolvedDeviceId, motionEvent.getSource(), motionEvent.getAction(), motionEvent.getPointerCount(), motionEvent.getPointerProperties(), motionEvent.getSamplePointerCoords(), flags); if (!result.ok()) { logDispatchStateLocked(); LOG(ERROR) << "Inconsistent event: " << motionEvent << ", reason: " << result.error(); } } const nsecs_t* sampleEventTimes = motionEvent.getSampleEventTimes(); const size_t pointerCount = motionEvent.getPointerCount(); const std::vector<PointerProperties> Loading Loading @@ -6945,6 +6970,7 @@ void InputDispatcher::displayRemoved(int32_t displayId) { // Remove the associated touch mode state. mTouchModePerDisplay.erase(displayId); mVerifiersByDisplay.erase(displayId); mInputFilterVerifiersByDisplay.erase(displayId); } // release lock // Wake up poll loop since it may need to make new input dispatching choices. Loading services/inputflinger/dispatcher/InputDispatcher.h +2 −1 Original line number Diff line number Diff line Loading @@ -298,7 +298,8 @@ private: void transformMotionEntryForInjectionLocked(MotionEntry&, const ui::Transform& injectedTransform) const REQUIRES(mLock); // Per-display correction of injected events std::map</*displayId*/ int32_t, InputVerifier> mInputFilterVerifiersByDisplay GUARDED_BY(mLock); std::condition_variable mInjectionSyncFinished; void incrementPendingForegroundDispatches(const EventEntry& entry); void decrementPendingForegroundDispatches(const EventEntry& entry); Loading services/surfaceflinger/tests/unittests/CommitTest.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -94,13 +94,15 @@ TEST_F(CommitTest, metadataNotIncluded) { // Create a parent layer with metadata and a child layer without. Metadata should not // be included in the child layer when the flag is not set. std::unordered_map<uint32_t, std::vector<uint8_t>> metadata = {{1, {'a', 'b'}}}; auto parent = std::make_unique<frontend::RequestedLayerState>( createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID)); auto parentArgs = createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID); auto parent = std::make_unique<frontend::RequestedLayerState>(parentArgs); mFlinger.addLayer(parent); mFlinger.injectLegacyLayer(sp<Layer>::make(parentArgs)); auto child = std::make_unique<frontend::RequestedLayerState>(createArgs(11, LayerMetadata(), 1)); auto childArgs = createArgs(11, LayerMetadata(), 1); auto child = std::make_unique<frontend::RequestedLayerState>(childArgs); mFlinger.addLayer(child); mFlinger.injectLegacyLayer(sp<Layer>::make(childArgs)); bool unused; bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0, Loading Loading @@ -136,13 +138,15 @@ TEST_F(CommitTest, metadataIsIncluded) { // Create a parent layer with metadata and a child layer without. Metadata from the // parent should be included in the child layer when the flag is set. std::unordered_map<uint32_t, std::vector<uint8_t>> metadata = {{1, {'a', 'b'}}}; auto parent = std::make_unique<frontend::RequestedLayerState>( createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID)); auto parentArgs = createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID); auto parent = std::make_unique<frontend::RequestedLayerState>(parentArgs); mFlinger.addLayer(parent); mFlinger.injectLegacyLayer(sp<Layer>::make(parentArgs)); auto child = std::make_unique<frontend::RequestedLayerState>(createArgs(11, LayerMetadata(), 1)); auto childArgs = createArgs(11, LayerMetadata(), 1); auto child = std::make_unique<frontend::RequestedLayerState>(childArgs); mFlinger.addLayer(child); mFlinger.injectLegacyLayer(sp<Layer>::make(childArgs)); bool unused; bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0, Loading Loading
libs/input/rust/lib.rs +9 −1 Original line number Diff line number Diff line Loading @@ -79,12 +79,20 @@ fn process_movement( pointer_properties: &[RustPointerProperties], flags: u32, ) -> String { let motion_flags = MotionFlags::from_bits(flags); if motion_flags.is_none() { panic!( "The conversion of flags 0x{:08x} failed, please check if some flags have not been \ added to MotionFlags.", flags ); } let result = verifier.process_movement( DeviceId(device_id), Source::from_bits(source).unwrap(), action, pointer_properties, MotionFlags::from_bits(flags).unwrap(), motion_flags.unwrap(), ); match result { Ok(()) => "".to_string(), Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -4732,6 +4732,7 @@ void InputDispatcher::notifySwitch(const NotifySwitchArgs& args) { } void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs& args) { // TODO(b/308677868) Remove device reset from the InputListener interface if (debugInboundEventDetails()) { ALOGD("notifyDeviceReset - eventTime=%" PRId64 ", deviceId=%d", args.eventTime, args.deviceId); Loading Loading @@ -4882,6 +4883,30 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev } mLock.lock(); if (policyFlags & POLICY_FLAG_FILTERED) { // The events from InputFilter impersonate real hardware devices. Check these // events for consistency and print an error. An inconsistent event sent from // InputFilter could cause a crash in the later stages of dispatching pipeline. auto [it, _] = mInputFilterVerifiersByDisplay .try_emplace(displayId, StringPrintf("Injection on %" PRId32, displayId)); InputVerifier& verifier = it->second; Result<void> result = verifier.processMovement(resolvedDeviceId, motionEvent.getSource(), motionEvent.getAction(), motionEvent.getPointerCount(), motionEvent.getPointerProperties(), motionEvent.getSamplePointerCoords(), flags); if (!result.ok()) { logDispatchStateLocked(); LOG(ERROR) << "Inconsistent event: " << motionEvent << ", reason: " << result.error(); } } const nsecs_t* sampleEventTimes = motionEvent.getSampleEventTimes(); const size_t pointerCount = motionEvent.getPointerCount(); const std::vector<PointerProperties> Loading Loading @@ -6945,6 +6970,7 @@ void InputDispatcher::displayRemoved(int32_t displayId) { // Remove the associated touch mode state. mTouchModePerDisplay.erase(displayId); mVerifiersByDisplay.erase(displayId); mInputFilterVerifiersByDisplay.erase(displayId); } // release lock // Wake up poll loop since it may need to make new input dispatching choices. Loading
services/inputflinger/dispatcher/InputDispatcher.h +2 −1 Original line number Diff line number Diff line Loading @@ -298,7 +298,8 @@ private: void transformMotionEntryForInjectionLocked(MotionEntry&, const ui::Transform& injectedTransform) const REQUIRES(mLock); // Per-display correction of injected events std::map</*displayId*/ int32_t, InputVerifier> mInputFilterVerifiersByDisplay GUARDED_BY(mLock); std::condition_variable mInjectionSyncFinished; void incrementPendingForegroundDispatches(const EventEntry& entry); void decrementPendingForegroundDispatches(const EventEntry& entry); Loading
services/surfaceflinger/tests/unittests/CommitTest.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -94,13 +94,15 @@ TEST_F(CommitTest, metadataNotIncluded) { // Create a parent layer with metadata and a child layer without. Metadata should not // be included in the child layer when the flag is not set. std::unordered_map<uint32_t, std::vector<uint8_t>> metadata = {{1, {'a', 'b'}}}; auto parent = std::make_unique<frontend::RequestedLayerState>( createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID)); auto parentArgs = createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID); auto parent = std::make_unique<frontend::RequestedLayerState>(parentArgs); mFlinger.addLayer(parent); mFlinger.injectLegacyLayer(sp<Layer>::make(parentArgs)); auto child = std::make_unique<frontend::RequestedLayerState>(createArgs(11, LayerMetadata(), 1)); auto childArgs = createArgs(11, LayerMetadata(), 1); auto child = std::make_unique<frontend::RequestedLayerState>(childArgs); mFlinger.addLayer(child); mFlinger.injectLegacyLayer(sp<Layer>::make(childArgs)); bool unused; bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0, Loading Loading @@ -136,13 +138,15 @@ TEST_F(CommitTest, metadataIsIncluded) { // Create a parent layer with metadata and a child layer without. Metadata from the // parent should be included in the child layer when the flag is set. std::unordered_map<uint32_t, std::vector<uint8_t>> metadata = {{1, {'a', 'b'}}}; auto parent = std::make_unique<frontend::RequestedLayerState>( createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID)); auto parentArgs = createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID); auto parent = std::make_unique<frontend::RequestedLayerState>(parentArgs); mFlinger.addLayer(parent); mFlinger.injectLegacyLayer(sp<Layer>::make(parentArgs)); auto child = std::make_unique<frontend::RequestedLayerState>(createArgs(11, LayerMetadata(), 1)); auto childArgs = createArgs(11, LayerMetadata(), 1); auto child = std::make_unique<frontend::RequestedLayerState>(childArgs); mFlinger.addLayer(child); mFlinger.injectLegacyLayer(sp<Layer>::make(childArgs)); bool unused; bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0, Loading