Loading services/inputflinger/reader/mapper/CursorInputMapper.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ namespace android { // The default velocity control parameters that has no effect. static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{}; static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); // --- CursorMotionAccumulator --- CursorMotionAccumulator::CursorMotionAccumulator() { Loading Loading @@ -76,9 +78,14 @@ void CursorMotionAccumulator::finishSync() { CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig) : CursorInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {} CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer) : InputMapper(deviceContext, readerConfig), mLastEventTime(std::numeric_limits<nsecs_t>::min()), mEnablePointerChoreographer(input_flags::enable_pointer_choreographer()), mEnablePointerChoreographer(enablePointerChoreographer), mEnableNewMousePointerBallistics(input_flags::enable_new_mouse_pointer_ballistics()) {} CursorInputMapper::~CursorInputMapper() { Loading services/inputflinger/reader/mapper/CursorInputMapper.h +4 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,10 @@ private: explicit CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); // Constructor for testing. explicit CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer); void dumpParameters(std::string& dump); void configureBasicParams(); void configureOnPointerCapture(const InputReaderConfiguration& config); Loading services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ namespace android { namespace { static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); /** * Log details of each gesture output by the gestures library. * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires Loading Loading @@ -232,6 +234,11 @@ private: TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig) : TouchpadInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {} TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer) : InputMapper(deviceContext, readerConfig), mGestureInterpreter(NewGestureInterpreter(), DeleteGestureInterpreter), mPointerController(getContext()->getPointerController(getDeviceId())), Loading @@ -240,7 +247,7 @@ TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, mGestureConverter(*getContext(), deviceContext, getDeviceId()), mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()), mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())), mEnablePointerChoreographer(input_flags::enable_pointer_choreographer()) { mEnablePointerChoreographer(enablePointerChoreographer) { RawAbsoluteAxisInfo slotAxisInfo; deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo); if (!slotAxisInfo.valid || slotAxisInfo.maxValue <= 0) { Loading services/inputflinger/reader/mapper/TouchpadInputMapper.h +4 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,10 @@ private: void resetGestureInterpreter(nsecs_t when); explicit TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); // Constructor for testing. explicit TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer); void updatePalmDetectionMetrics(); [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime, SelfContainedHardwareState schs); Loading services/inputflinger/tests/CursorInputMapper_test.cpp +23 −11 Original line number Diff line number Diff line Loading @@ -157,9 +157,12 @@ protected: mFakePolicy->addDisplayViewport(createPrimaryViewport(ui::Rotation::Rotation0)); } virtual bool isPointerChoreographerEnabled() { return false; } void createMapper() { createDevice(); mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration); mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration, isPointerChoreographerEnabled()); } void setPointerCapture(bool enabled) { Loading Loading @@ -194,10 +197,11 @@ protected: class CursorInputMapperUnitTest : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(false); input_flags::enable_new_mouse_pointer_ballistics(false); CursorInputMapperUnitTestBase::SetUp(); } bool isPointerChoreographerEnabled() override { return false; } }; TEST_F(CursorInputMapperUnitTest, GetSourcesReturnsMouseInPointerMode) { Loading Loading @@ -321,10 +325,10 @@ TEST_F(CursorInputMapperUnitTest, ProcessPointerCapture) { // Disable pointer capture. Afterwards, events should be generated the usual way. setPointerCapture(false); const auto expectedCoords = input_flags::enable_pointer_choreographer() const auto expectedCoords = CursorInputMapperUnitTest::isPointerChoreographerEnabled() ? WithCoords(0, 0) : WithCoords(INITIAL_CURSOR_X + 10.0f, INITIAL_CURSOR_Y + 20.0f); const auto expectedCursorPosition = input_flags::enable_pointer_choreographer() const auto expectedCursorPosition = CursorInputMapperUnitTest::isPointerChoreographerEnabled() ? WithCursorPosition(INVALID_CURSOR_POSITION, INVALID_CURSOR_POSITION) : WithCursorPosition(INITIAL_CURSOR_X + 10.0f, INITIAL_CURSOR_Y + 20.0f); args.clear(); Loading Loading @@ -708,7 +712,9 @@ TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdWithAssociatedViewport) { createDevice(); // Associate the InputDevice with the secondary display. ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport); mMapper = createInputMapper<CursorInputMapper>(deviceContext, mReaderConfiguration); mMapper = createInputMapper< CursorInputMapper>(deviceContext, mReaderConfiguration, CursorInputMapperUnitTest::isPointerChoreographerEnabled()); // Ensure input events are generated for the secondary display. std::list<NotifyArgs> args; Loading @@ -731,7 +737,9 @@ TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdIgnoresEventsForMismatchedPo createDevice(); // Associate the InputDevice with the secondary display. ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport); mMapper = createInputMapper<CursorInputMapper>(deviceContext, mReaderConfiguration); mMapper = createInputMapper< CursorInputMapper>(deviceContext, mReaderConfiguration, CursorInputMapperUnitTest::isPointerChoreographerEnabled()); // The mapper should not generate any events because it is associated with a display that is // different from the pointer display. Loading Loading @@ -837,7 +845,9 @@ class CursorInputMapperButtonKeyTest : public CursorInputMapperUnitTest, public testing::WithParamInterface< std::tuple<int32_t /*evdevCode*/, int32_t /*expectedButtonState*/, int32_t /*expectedKeyCode*/>> {}; int32_t /*expectedKeyCode*/>> { virtual bool isPointerChoreographerEnabled() override { return false; } }; TEST_P(CursorInputMapperButtonKeyTest, ProcessShouldHandleButtonKey) { auto [evdevCode, expectedButtonState, expectedKeyCode] = GetParam(); Loading Loading @@ -956,10 +966,11 @@ TEST_F(CursorInputMapperUnitTest, PointerCaptureDisablesVelocityProcessing) { class CursorInputMapperUnitTestWithChoreographer : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(true); input_flags::enable_new_mouse_pointer_ballistics(false); CursorInputMapperUnitTestBase::SetUp(); } bool isPointerChoreographerEnabled() override { return true; } }; TEST_F(CursorInputMapperUnitTestWithChoreographer, PopulateDeviceInfoReturnsRangeFromPolicy) { Loading Loading @@ -1288,10 +1299,11 @@ TEST_F(CursorInputMapperUnitTestWithChoreographer, ConfigureDisplayIdNoAssociate class CursorInputMapperUnitTestWithNewBallistics : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(true); input_flags::enable_new_mouse_pointer_ballistics(true); CursorInputMapperUnitTestBase::SetUp(); } bool isPointerChoreographerEnabled() override { return true; } }; TEST_F(CursorInputMapperUnitTestWithNewBallistics, PointerCaptureDisablesVelocityProcessing) { Loading Loading @@ -1413,7 +1425,6 @@ constexpr nsecs_t MAX_BLUETOOTH_SMOOTHING_DELTA = ms2ns(32); class BluetoothCursorInputMapperUnitTest : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(false); SetUpWithBus(BUS_BLUETOOTH); mFakePointerController = std::make_shared<FakePointerController>(); Loading Loading @@ -1531,12 +1542,13 @@ TEST_F(BluetoothCursorInputMapperUnitTest, TimestampSmootheningNotUsed) { class BluetoothCursorInputMapperUnitTestWithChoreographer : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(true); SetUpWithBus(BUS_BLUETOOTH); mFakePointerController = std::make_shared<FakePointerController>(); mFakePolicy->setPointerController(mFakePointerController); } bool isPointerChoreographerEnabled() override { return true; } }; TEST_F(BluetoothCursorInputMapperUnitTestWithChoreographer, TimestampSmoothening) { Loading Loading
services/inputflinger/reader/mapper/CursorInputMapper.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ namespace android { // The default velocity control parameters that has no effect. static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{}; static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); // --- CursorMotionAccumulator --- CursorMotionAccumulator::CursorMotionAccumulator() { Loading Loading @@ -76,9 +78,14 @@ void CursorMotionAccumulator::finishSync() { CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig) : CursorInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {} CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer) : InputMapper(deviceContext, readerConfig), mLastEventTime(std::numeric_limits<nsecs_t>::min()), mEnablePointerChoreographer(input_flags::enable_pointer_choreographer()), mEnablePointerChoreographer(enablePointerChoreographer), mEnableNewMousePointerBallistics(input_flags::enable_new_mouse_pointer_ballistics()) {} CursorInputMapper::~CursorInputMapper() { Loading
services/inputflinger/reader/mapper/CursorInputMapper.h +4 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,10 @@ private: explicit CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); // Constructor for testing. explicit CursorInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer); void dumpParameters(std::string& dump); void configureBasicParams(); void configureOnPointerCapture(const InputReaderConfiguration& config); Loading
services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ namespace android { namespace { static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); /** * Log details of each gesture output by the gestures library. * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires Loading Loading @@ -232,6 +234,11 @@ private: TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig) : TouchpadInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {} TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer) : InputMapper(deviceContext, readerConfig), mGestureInterpreter(NewGestureInterpreter(), DeleteGestureInterpreter), mPointerController(getContext()->getPointerController(getDeviceId())), Loading @@ -240,7 +247,7 @@ TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, mGestureConverter(*getContext(), deviceContext, getDeviceId()), mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()), mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())), mEnablePointerChoreographer(input_flags::enable_pointer_choreographer()) { mEnablePointerChoreographer(enablePointerChoreographer) { RawAbsoluteAxisInfo slotAxisInfo; deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo); if (!slotAxisInfo.valid || slotAxisInfo.maxValue <= 0) { Loading
services/inputflinger/reader/mapper/TouchpadInputMapper.h +4 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,10 @@ private: void resetGestureInterpreter(nsecs_t when); explicit TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); // Constructor for testing. explicit TouchpadInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, bool enablePointerChoreographer); void updatePalmDetectionMetrics(); [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime, SelfContainedHardwareState schs); Loading
services/inputflinger/tests/CursorInputMapper_test.cpp +23 −11 Original line number Diff line number Diff line Loading @@ -157,9 +157,12 @@ protected: mFakePolicy->addDisplayViewport(createPrimaryViewport(ui::Rotation::Rotation0)); } virtual bool isPointerChoreographerEnabled() { return false; } void createMapper() { createDevice(); mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration); mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration, isPointerChoreographerEnabled()); } void setPointerCapture(bool enabled) { Loading Loading @@ -194,10 +197,11 @@ protected: class CursorInputMapperUnitTest : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(false); input_flags::enable_new_mouse_pointer_ballistics(false); CursorInputMapperUnitTestBase::SetUp(); } bool isPointerChoreographerEnabled() override { return false; } }; TEST_F(CursorInputMapperUnitTest, GetSourcesReturnsMouseInPointerMode) { Loading Loading @@ -321,10 +325,10 @@ TEST_F(CursorInputMapperUnitTest, ProcessPointerCapture) { // Disable pointer capture. Afterwards, events should be generated the usual way. setPointerCapture(false); const auto expectedCoords = input_flags::enable_pointer_choreographer() const auto expectedCoords = CursorInputMapperUnitTest::isPointerChoreographerEnabled() ? WithCoords(0, 0) : WithCoords(INITIAL_CURSOR_X + 10.0f, INITIAL_CURSOR_Y + 20.0f); const auto expectedCursorPosition = input_flags::enable_pointer_choreographer() const auto expectedCursorPosition = CursorInputMapperUnitTest::isPointerChoreographerEnabled() ? WithCursorPosition(INVALID_CURSOR_POSITION, INVALID_CURSOR_POSITION) : WithCursorPosition(INITIAL_CURSOR_X + 10.0f, INITIAL_CURSOR_Y + 20.0f); args.clear(); Loading Loading @@ -708,7 +712,9 @@ TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdWithAssociatedViewport) { createDevice(); // Associate the InputDevice with the secondary display. ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport); mMapper = createInputMapper<CursorInputMapper>(deviceContext, mReaderConfiguration); mMapper = createInputMapper< CursorInputMapper>(deviceContext, mReaderConfiguration, CursorInputMapperUnitTest::isPointerChoreographerEnabled()); // Ensure input events are generated for the secondary display. std::list<NotifyArgs> args; Loading @@ -731,7 +737,9 @@ TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdIgnoresEventsForMismatchedPo createDevice(); // Associate the InputDevice with the secondary display. ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport); mMapper = createInputMapper<CursorInputMapper>(deviceContext, mReaderConfiguration); mMapper = createInputMapper< CursorInputMapper>(deviceContext, mReaderConfiguration, CursorInputMapperUnitTest::isPointerChoreographerEnabled()); // The mapper should not generate any events because it is associated with a display that is // different from the pointer display. Loading Loading @@ -837,7 +845,9 @@ class CursorInputMapperButtonKeyTest : public CursorInputMapperUnitTest, public testing::WithParamInterface< std::tuple<int32_t /*evdevCode*/, int32_t /*expectedButtonState*/, int32_t /*expectedKeyCode*/>> {}; int32_t /*expectedKeyCode*/>> { virtual bool isPointerChoreographerEnabled() override { return false; } }; TEST_P(CursorInputMapperButtonKeyTest, ProcessShouldHandleButtonKey) { auto [evdevCode, expectedButtonState, expectedKeyCode] = GetParam(); Loading Loading @@ -956,10 +966,11 @@ TEST_F(CursorInputMapperUnitTest, PointerCaptureDisablesVelocityProcessing) { class CursorInputMapperUnitTestWithChoreographer : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(true); input_flags::enable_new_mouse_pointer_ballistics(false); CursorInputMapperUnitTestBase::SetUp(); } bool isPointerChoreographerEnabled() override { return true; } }; TEST_F(CursorInputMapperUnitTestWithChoreographer, PopulateDeviceInfoReturnsRangeFromPolicy) { Loading Loading @@ -1288,10 +1299,11 @@ TEST_F(CursorInputMapperUnitTestWithChoreographer, ConfigureDisplayIdNoAssociate class CursorInputMapperUnitTestWithNewBallistics : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(true); input_flags::enable_new_mouse_pointer_ballistics(true); CursorInputMapperUnitTestBase::SetUp(); } bool isPointerChoreographerEnabled() override { return true; } }; TEST_F(CursorInputMapperUnitTestWithNewBallistics, PointerCaptureDisablesVelocityProcessing) { Loading Loading @@ -1413,7 +1425,6 @@ constexpr nsecs_t MAX_BLUETOOTH_SMOOTHING_DELTA = ms2ns(32); class BluetoothCursorInputMapperUnitTest : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(false); SetUpWithBus(BUS_BLUETOOTH); mFakePointerController = std::make_shared<FakePointerController>(); Loading Loading @@ -1531,12 +1542,13 @@ TEST_F(BluetoothCursorInputMapperUnitTest, TimestampSmootheningNotUsed) { class BluetoothCursorInputMapperUnitTestWithChoreographer : public CursorInputMapperUnitTestBase { protected: void SetUp() override { input_flags::enable_pointer_choreographer(true); SetUpWithBus(BUS_BLUETOOTH); mFakePointerController = std::make_shared<FakePointerController>(); mFakePolicy->setPointerController(mFakePointerController); } bool isPointerChoreographerEnabled() override { return true; } }; TEST_F(BluetoothCursorInputMapperUnitTestWithChoreographer, TimestampSmoothening) { Loading