Use ftl::Flags for InputReaderConfiguration::Change
Convert the config flags into an enum class and use ftl::Flags when
dealing with configuration changes.
Bug: 245989146
Test: Presubmit
Change-Id: I0aed947ce433a1def11a60e73a14575561374700
diff --git a/services/inputflinger/tests/InputMapperTest.cpp b/services/inputflinger/tests/InputMapperTest.cpp
index ae30006..ad48a79 100644
--- a/services/inputflinger/tests/InputMapperTest.cpp
+++ b/services/inputflinger/tests/InputMapperTest.cpp
@@ -50,12 +50,12 @@
mFakeEventHub->addConfigurationProperty(EVENTHUB_ID, key, value);
}
-std::list<NotifyArgs> InputMapperTest::configureDevice(uint32_t changes) {
- if (!changes ||
- (changes &
- (InputReaderConfiguration::CHANGE_DISPLAY_INFO |
- InputReaderConfiguration::CHANGE_POINTER_CAPTURE |
- InputReaderConfiguration::CHANGE_DEVICE_TYPE))) {
+std::list<NotifyArgs> InputMapperTest::configureDevice(ConfigurationChanges changes) {
+ using namespace ftl::flag_operators;
+ if (!changes.any() ||
+ (changes.any(InputReaderConfiguration::Change::DISPLAY_INFO |
+ InputReaderConfiguration::Change::POINTER_CAPTURE |
+ InputReaderConfiguration::Change::DEVICE_TYPE))) {
mReader->requestRefreshConfiguration(changes);
mReader->loopOnce();
}
@@ -94,7 +94,7 @@
ViewportType viewportType) {
mFakePolicy->addDisplayViewport(displayId, width, height, orientation, /* isActive= */ true,
uniqueId, physicalPort, viewportType);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
}
void InputMapperTest::clearViewports() {
diff --git a/services/inputflinger/tests/InputMapperTest.h b/services/inputflinger/tests/InputMapperTest.h
index df601ea..d969034 100644
--- a/services/inputflinger/tests/InputMapperTest.h
+++ b/services/inputflinger/tests/InputMapperTest.h
@@ -54,7 +54,7 @@
void TearDown() override;
void addConfigurationProperty(const char* key, const char* value);
- std::list<NotifyArgs> configureDevice(uint32_t changes);
+ std::list<NotifyArgs> configureDevice(ConfigurationChanges changes);
std::shared_ptr<InputDevice> newDevice(int32_t deviceId, const std::string& name,
const std::string& location, int32_t eventHubId,
ftl::Flags<InputDeviceClass> classes, int bus = 0);
@@ -62,7 +62,7 @@
T& addMapperAndConfigure(Args... args) {
T& mapper =
mDevice->addMapper<T>(EVENTHUB_ID, mFakePolicy->getReaderConfiguration(), args...);
- configureDevice(0);
+ configureDevice(/*changes=*/{});
std::list<NotifyArgs> resetArgList = mDevice->reset(ARBITRARY_TIME);
resetArgList += mapper.reset(ARBITRARY_TIME);
// Loop the reader to flush the input listener queue.
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index da3fe5b..0b50504 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -265,13 +265,13 @@
}
std::list<NotifyArgs> reconfigure(nsecs_t, const InputReaderConfiguration& config,
- uint32_t changes) override {
+ ConfigurationChanges changes) override {
std::scoped_lock<std::mutex> lock(mLock);
mConfigureWasCalled = true;
// Find the associated viewport if exist.
const std::optional<uint8_t> displayPort = getDeviceContext().getAssociatedDisplayPort();
- if (displayPort && (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+ if (displayPort && changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) {
mViewport = config.getDisplayViewportByPort(*displayPort);
}
@@ -610,12 +610,12 @@
void disableDevice(int32_t deviceId) {
mFakePolicy->addDisabledDevice(deviceId);
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_ENABLED_STATE);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::ENABLED_STATE);
}
void enableDevice(int32_t deviceId) {
mFakePolicy->removeDisabledDevice(deviceId);
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_ENABLED_STATE);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::ENABLED_STATE);
}
FakeInputMapper& addDeviceWithFakeInputMapper(int32_t deviceId, int32_t eventHubId,
@@ -1043,7 +1043,7 @@
mFakePolicy->addDisplayViewport(SECONDARY_DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT,
ui::ROTATION_0, /*isActive=*/true, "local:1", hdmi1,
ViewportType::EXTERNAL);
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::DISPLAY_INFO);
mReader->loopOnce();
// Add the device, and make sure all of the callbacks are triggered.
@@ -1142,21 +1142,21 @@
NotifyPointerCaptureChangedArgs args;
auto request = mFakePolicy->setPointerCapture(true);
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::POINTER_CAPTURE);
mReader->loopOnce();
mFakeListener->assertNotifyCaptureWasCalled(&args);
ASSERT_TRUE(args.request.enable) << "Pointer Capture should be enabled.";
ASSERT_EQ(args.request, request) << "Pointer Capture sequence number should match.";
mFakePolicy->setPointerCapture(false);
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::POINTER_CAPTURE);
mReader->loopOnce();
mFakeListener->assertNotifyCaptureWasCalled(&args);
ASSERT_FALSE(args.request.enable) << "Pointer Capture should be disabled.";
// Verify that the Pointer Capture state is not updated when the configuration value
// does not change.
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::POINTER_CAPTURE);
mReader->loopOnce();
mFakeListener->assertNotifyCaptureWasNotCalled();
}
@@ -1527,7 +1527,7 @@
ViewportType viewportType) {
mFakePolicy->addDisplayViewport(displayId, width, height, orientation, /*isActive=*/true,
uniqueId, physicalPort, viewportType);
- mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ mReader->requestRefreshConfiguration(InputReaderConfiguration::Change::DISPLAY_INFO);
}
void assertReceivedMotion(int32_t action, const std::vector<Point>& points) {
@@ -2070,7 +2070,7 @@
TYPED_TEST(StylusButtonIntegrationTest, DISABLED_StylusButtonMotionEventsDisabled) {
TestFixture::mFakePolicy->setStylusButtonMotionEventsEnabled(false);
TestFixture::mReader->requestRefreshConfiguration(
- InputReaderConfiguration::CHANGE_STYLUS_BUTTON_REPORTING);
+ InputReaderConfiguration::Change::STYLUS_BUTTON_REPORTING);
const Point centerPoint = TestFixture::mTouchscreen->getCenterPoint();
const auto touchscreenId = TestFixture::mTouchscreenInfo.getId();
@@ -2341,7 +2341,7 @@
TEST_F(InputDeviceTest, WhenNoMappersAreRegistered_DeviceIsIgnored) {
// Configuration.
InputReaderConfiguration config;
- std::list<NotifyArgs> unused = mDevice->configure(ARBITRARY_TIME, config, 0);
+ std::list<NotifyArgs> unused = mDevice->configure(ARBITRARY_TIME, config, /*changes=*/{});
// Reset.
unused += mDevice->reset(ARBITRARY_TIME);
@@ -2402,7 +2402,7 @@
mapper2.setMetaState(AMETA_SHIFT_ON);
InputReaderConfiguration config;
- std::list<NotifyArgs> unused = mDevice->configure(ARBITRARY_TIME, config, 0);
+ std::list<NotifyArgs> unused = mDevice->configure(ARBITRARY_TIME, config, /*changes=*/{});
std::optional<std::string> propertyValue = mDevice->getConfiguration().getString("key");
ASSERT_TRUE(propertyValue.has_value())
@@ -2484,7 +2484,8 @@
// First Configuration.
std::list<NotifyArgs> unused =
- mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), 0);
+ mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
+ /*changes=*/{});
// Device should be enabled by default.
ASSERT_TRUE(mDevice->isEnabled());
@@ -2495,7 +2496,7 @@
mFakePolicy->addInputPortAssociation(DEVICE_LOCATION, hdmi);
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
// Device should be disabled because it is associated with a specific display via
// input port <-> display port association, but the corresponding display is not found
ASSERT_FALSE(mDevice->isEnabled());
@@ -2505,18 +2506,18 @@
ui::ROTATION_0, /*isActive=*/true, UNIQUE_ID, hdmi,
ViewportType::INTERNAL);
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_TRUE(mDevice->isEnabled());
// Device should be disabled after set disable.
mFakePolicy->addDisabledDevice(mDevice->getId());
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_ENABLED_STATE);
+ InputReaderConfiguration::Change::ENABLED_STATE);
ASSERT_FALSE(mDevice->isEnabled());
// Device should still be disabled even found the associated display.
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_FALSE(mDevice->isEnabled());
}
@@ -2526,14 +2527,15 @@
mDevice->addMapper<FakeInputMapper>(EVENTHUB_ID, mFakePolicy->getReaderConfiguration(),
AINPUT_SOURCE_KEYBOARD);
std::list<NotifyArgs> unused =
- mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), 0);
+ mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
+ /*changes=*/{});
ASSERT_TRUE(mDevice->isEnabled());
// Device should be disabled because it is associated with a specific display, but the
// corresponding display is not found.
mFakePolicy->addInputUniqueIdAssociation(DEVICE_LOCATION, DISPLAY_UNIQUE_ID);
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_FALSE(mDevice->isEnabled());
// Device should be enabled when a display is found.
@@ -2541,18 +2543,18 @@
ui::ROTATION_0, /* isActive= */ true, DISPLAY_UNIQUE_ID,
NO_PORT, ViewportType::INTERNAL);
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_TRUE(mDevice->isEnabled());
// Device should be disabled after set disable.
mFakePolicy->addDisabledDevice(mDevice->getId());
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_ENABLED_STATE);
+ InputReaderConfiguration::Change::ENABLED_STATE);
ASSERT_FALSE(mDevice->isEnabled());
// Device should still be disabled even found the associated display.
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_FALSE(mDevice->isEnabled());
}
@@ -2561,14 +2563,15 @@
mDevice->addMapper<FakeInputMapper>(EVENTHUB_ID, mFakePolicy->getReaderConfiguration(),
AINPUT_SOURCE_KEYBOARD);
std::list<NotifyArgs> unused =
- mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), 0);
+ mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
+ /*changes=*/{});
mFakePolicy->addInputUniqueIdAssociation(DEVICE_LOCATION, DISPLAY_UNIQUE_ID);
mFakePolicy->addDisplayViewport(SECONDARY_DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT,
ui::ROTATION_0, /* isActive= */ true, DISPLAY_UNIQUE_ID,
NO_PORT, ViewportType::INTERNAL);
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_EQ(DISPLAY_UNIQUE_ID, mDevice->getAssociatedDisplayUniqueId());
}
@@ -3423,7 +3426,7 @@
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
std::list<NotifyArgs> unused =
device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- /*changes=*/0);
+ /*changes=*/{});
unused += device2->reset(ARBITRARY_TIME);
// Prepared displays and associated info.
@@ -3436,7 +3439,7 @@
// No associated display viewport found, should disable the device.
unused += device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_FALSE(device2->isEnabled());
// Prepare second display.
@@ -3447,7 +3450,7 @@
SECONDARY_UNIQUE_ID, hdmi2, ViewportType::EXTERNAL);
// Default device will reconfigure above, need additional reconfiguration for another device.
unused += device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ InputReaderConfiguration::Change::DISPLAY_INFO);
// Device should be enabled after the associated display is found.
ASSERT_TRUE(mDevice->isEnabled());
@@ -3535,7 +3538,7 @@
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
std::list<NotifyArgs> unused =
device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- /*changes=*/0);
+ /*changes=*/{});
unused += device2->reset(ARBITRARY_TIME);
ASSERT_TRUE(mFakeEventHub->getLedState(SECOND_EVENTHUB_ID, LED_CAPSL));
@@ -3598,7 +3601,7 @@
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
std::list<NotifyArgs> unused =
device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- /*changes=*/0);
+ /*changes=*/{});
unused += device2->reset(ARBITRARY_TIME);
// Initial metastate is AMETA_NONE.
@@ -3667,7 +3670,7 @@
// Disable device, it should synthesize cancellation events for down events.
mFakePolicy->addDisabledDevice(DEVICE_ID);
- configureDevice(InputReaderConfiguration::CHANGE_ENABLED_STATE);
+ configureDevice(InputReaderConfiguration::Change::ENABLED_STATE);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
@@ -3681,12 +3684,13 @@
AINPUT_SOURCE_KEYBOARD,
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
std::list<NotifyArgs> unused =
- mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), 0);
+ mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
+ /*changes=*/{});
mFakePolicy->addKeyboardLayoutAssociation(DEVICE_LOCATION, DEVICE_KEYBOARD_LAYOUT_INFO);
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUT_ASSOCIATION);
+ InputReaderConfiguration::Change::KEYBOARD_LAYOUT_ASSOCIATION);
InputDeviceInfo deviceInfo = mDevice->getDeviceInfo();
ASSERT_EQ(DEVICE_KEYBOARD_LAYOUT_INFO.languageTag,
@@ -3703,7 +3707,7 @@
addMapperAndConfigure<KeyboardInputMapper>(AINPUT_SOURCE_KEYBOARD,
AINPUT_KEYBOARD_TYPE_ALPHABETIC);
InputReaderConfiguration config;
- std::list<NotifyArgs> unused = mDevice->configure(ARBITRARY_TIME, config, 0);
+ std::list<NotifyArgs> unused = mDevice->configure(ARBITRARY_TIME, config, /*changes=*/{});
ASSERT_EQ("en", mDevice->getDeviceInfo().getKeyboardLayoutInfo()->languageTag);
ASSERT_EQ("extended", mDevice->getDeviceInfo().getKeyboardLayoutInfo()->layoutType);
@@ -4509,7 +4513,7 @@
// and events are generated the usual way.
const uint32_t generation = mReader->getContext()->getGeneration();
mFakePolicy->setPointerCapture(false);
- configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE);
ASSERT_TRUE(mReader->getContext()->getGeneration() != generation);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
@@ -4558,7 +4562,7 @@
// Enable Pointer Capture
mFakePolicy->setPointerCapture(true);
- configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE);
NotifyPointerCaptureChangedArgs captureArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyCaptureWasCalled(&captureArgs));
ASSERT_TRUE(captureArgs.request.enable);
@@ -4600,7 +4604,7 @@
// Enable Pointer Capture.
mFakePolicy->setPointerCapture(true);
- configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE);
NotifyPointerCaptureChangedArgs captureArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyCaptureWasCalled(&captureArgs));
ASSERT_TRUE(captureArgs.request.enable);
@@ -4626,7 +4630,7 @@
// The InputDevice is not associated with any display.
prepareSecondaryDisplay();
mFakePolicy->setDefaultPointerDisplayId(SECONDARY_DISPLAY_ID);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
mFakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
mFakePointerController->setPosition(100, 200);
@@ -4653,7 +4657,7 @@
prepareSecondaryDisplay();
mFakePolicy->setDefaultPointerDisplayId(SECONDARY_DISPLAY_ID);
mFakePolicy->addInputUniqueIdAssociation(DEVICE_LOCATION, SECONDARY_DISPLAY_UNIQUE_ID);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
mFakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
mFakePointerController->setPosition(100, 200);
@@ -4678,7 +4682,7 @@
// Associate the InputDevice with the secondary display.
prepareSecondaryDisplay();
mFakePolicy->addInputUniqueIdAssociation(DEVICE_LOCATION, SECONDARY_DISPLAY_UNIQUE_ID);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
// The mapper should not generate any events because it is associated with a display that is
// different from the pointer display.
@@ -5845,7 +5849,7 @@
viewport->physicalRight = 30;
viewport->physicalBottom = 610;
mFakePolicy->updateViewport(*viewport);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
// Start the touch.
process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, BTN_TOUCH, 1);
@@ -6570,7 +6574,7 @@
auto viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL);
viewport->isActive = false;
mFakePolicy->updateViewport(*viewport);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
// We should receive a cancel event for the ongoing gesture.
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
@@ -6595,7 +6599,7 @@
// Make the viewport active again. The device should resume processing events.
viewport->isActive = true;
mFakePolicy->updateViewport(*viewport);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
// The device is reset because it changes back to direct mode, without generating any events.
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
@@ -6763,7 +6767,7 @@
// Send update to the mapper.
std::list<NotifyArgs> unused2 =
mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DEVICE_TYPE /*changes*/);
+ InputReaderConfiguration::Change::DEVICE_TYPE /*changes*/);
// Check whether device type update was successful.
ASSERT_EQ(AINPUT_SOURCE_TOUCH_NAVIGATION, mDevice->getSources());
@@ -6784,7 +6788,7 @@
viewport->physicalRight = DISPLAY_WIDTH / 2;
viewport->physicalBottom = DISPLAY_HEIGHT / 2;
mFakePolicy->updateViewport(*viewport);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
@@ -6873,7 +6877,7 @@
v.uniqueId = UNIQUE_ID;
v.type = ViewportType::INTERNAL;
mFakePolicy->updateViewport(v);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
}
void assertReceivedMove(const Point& point) {
@@ -7233,7 +7237,7 @@
mStylusState.pressure = 0.f;
mStylusState.toolType = ToolType::STYLUS;
mReader->getContext()->setExternalStylusDevices({mExternalStylusDeviceInfo});
- configureDevice(InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE);
+ configureDevice(InputReaderConfiguration::Change::EXTERNAL_STYLUS_PRESENCE);
processExternalStylusState(mapper);
return mapper;
}
@@ -9289,7 +9293,7 @@
// Don't set touch.enableForInactiveViewport to verify the default behavior.
mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0,
/*isActive=*/false, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
prepareAxes(POSITION);
MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
@@ -9309,7 +9313,7 @@
addConfigurationProperty("touch.enableForInactiveViewport", "1");
mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0,
/*isActive=*/false, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
prepareAxes(POSITION);
MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
@@ -9331,7 +9335,7 @@
ASSERT_TRUE(optionalDisplayViewport.has_value());
DisplayViewport displayViewport = *optionalDisplayViewport;
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
prepareAxes(POSITION);
MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
@@ -9347,7 +9351,7 @@
// Deactivate display viewport
displayViewport.isActive = false;
ASSERT_TRUE(mFakePolicy->updateViewport(displayViewport));
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
// The ongoing touch should be canceled immediately
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
@@ -9362,7 +9366,7 @@
// Reactivate display viewport
displayViewport.isActive = true;
ASSERT_TRUE(mFakePolicy->updateViewport(displayViewport));
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
// Finger move again starts new gesture
x += 10, y += 10;
@@ -9405,7 +9409,7 @@
mFakePolicy->getReaderConfiguration());
std::list<NotifyArgs> unused =
device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- /*changes=*/0);
+ /*changes=*/{});
unused += device2->reset(ARBITRARY_TIME);
// Setup PointerController.
@@ -9426,8 +9430,8 @@
// Default device will reconfigure above, need additional reconfiguration for another device.
unused += device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_DISPLAY_INFO |
- InputReaderConfiguration::CHANGE_SHOW_TOUCHES);
+ InputReaderConfiguration::Change::DISPLAY_INFO |
+ InputReaderConfiguration::Change::SHOW_TOUCHES);
// Two fingers down at default display.
int32_t x1 = 100, y1 = 125, x2 = 300, y2 = 500;
@@ -9458,7 +9462,7 @@
// Disable the show touches configuration and ensure the spots are cleared.
mFakePolicy->setShowTouches(false);
unused += device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::CHANGE_SHOW_TOUCHES);
+ InputReaderConfiguration::Change::SHOW_TOUCHES);
ASSERT_TRUE(fakePointerController->getSpots().empty());
}
@@ -10368,7 +10372,7 @@
// non captured touchpad should be a mouse source
mFakePolicy->setPointerCapture(false);
- configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources());
}
@@ -10453,7 +10457,7 @@
// captured touchpad should be a touchpad device
mFakePolicy->setPointerCapture(true);
- configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ configureDevice(InputReaderConfiguration::Change::POINTER_CAPTURE);
ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper.getSources());
}
@@ -10839,7 +10843,7 @@
auto viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL);
viewport->isActive = false;
mFakePolicy->updateViewport(*viewport);
- configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL),
WithSource(AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS),
@@ -10947,14 +10951,6 @@
mFakePolicy.clear();
}
- std::list<NotifyArgs> configureDevice(uint32_t changes) {
- if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
- mReader->requestRefreshConfiguration(changes);
- mReader->loopOnce();
- }
- return mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), changes);
- }
-
std::shared_ptr<InputDevice> newDevice(int32_t deviceId, const std::string& name,
const std::string& location, int32_t eventHubId,
ftl::Flags<InputDeviceClass> classes) {
diff --git a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
index 8ed1f31..8098ef2 100644
--- a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
@@ -53,12 +53,14 @@
[&]() -> void {
std::list<NotifyArgs> unused =
mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
- fdp->ConsumeIntegral<int32_t>());
+ InputReaderConfiguration::Change(
+ fdp->ConsumeIntegral<int32_t>()));
},
[&]() -> void {
// Need to reconfigure with 0 or you risk a NPE.
std::list<NotifyArgs> unused =
- mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig, 0);
+ mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
+ InputReaderConfiguration::Change(0));
InputDeviceInfo info;
mapper.populateDeviceInfo(info);
},
@@ -71,7 +73,8 @@
// Need to reconfigure with 0 or you risk a NPE.
std::list<NotifyArgs> unused =
- mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig, 0);
+ mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
+ InputReaderConfiguration::Change(0));
RawEvent rawEvent{fdp->ConsumeIntegral<nsecs_t>(),
fdp->ConsumeIntegral<nsecs_t>(),
fdp->ConsumeIntegral<int32_t>(),
@@ -90,7 +93,8 @@
[&]() -> void {
// Need to reconfigure with 0 or you risk a NPE.
std::list<NotifyArgs> unused =
- mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig, 0);
+ mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
+ InputReaderConfiguration::Change(0));
mapper.getAssociatedDisplayId();
},
})();
diff --git a/services/inputflinger/tests/fuzzers/FuzzContainer.h b/services/inputflinger/tests/fuzzers/FuzzContainer.h
index d42d11c..84ac0fd 100644
--- a/services/inputflinger/tests/fuzzers/FuzzContainer.h
+++ b/services/inputflinger/tests/fuzzers/FuzzContainer.h
@@ -59,7 +59,7 @@
void configureDevice() {
nsecs_t arbitraryTime = mFdp->ConsumeIntegral<nsecs_t>();
std::list<NotifyArgs> out;
- out += mFuzzDevice->configure(arbitraryTime, mPolicyConfig, 0);
+ out += mFuzzDevice->configure(arbitraryTime, mPolicyConfig, /*changes=*/{});
out += mFuzzDevice->reset(arbitraryTime);
for (const NotifyArgs& args : out) {
mFuzzListener.notify(args);
diff --git a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
index baece3c..9223287 100644
--- a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp
@@ -82,7 +82,7 @@
return reader->hasKeys(deviceId, sourceMask, keyCodes, outFlags);
}
- void requestRefreshConfiguration(uint32_t changes) {
+ void requestRefreshConfiguration(ConfigurationChanges changes) {
reader->requestRefreshConfiguration(changes);
}
@@ -232,7 +232,8 @@
fdp->ConsumeIntegral<uint32_t>(), keyCodes, outFlags.data());
},
[&]() -> void {
- reader->requestRefreshConfiguration(fdp->ConsumeIntegral<uint32_t>());
+ reader->requestRefreshConfiguration(
+ InputReaderConfiguration::Change(fdp->ConsumeIntegral<uint32_t>()));
},
[&]() -> void {
reader->cancelVibrate(fdp->ConsumeIntegral<int32_t>(),
diff --git a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
index 0a6327d..616e870 100644
--- a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
@@ -65,7 +65,8 @@
[&]() -> void {
std::list<NotifyArgs> unused =
mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
- fdp->ConsumeIntegral<uint32_t>());
+ InputReaderConfiguration::Change(
+ fdp->ConsumeIntegral<uint32_t>()));
},
[&]() -> void {
std::list<NotifyArgs> unused = mapper.reset(fdp->ConsumeIntegral<nsecs_t>());
diff --git a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
index fdf9f41..212462d 100644
--- a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
@@ -80,7 +80,8 @@
[&]() -> void {
std::list<NotifyArgs> unused =
mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
- fdp->ConsumeIntegral<uint32_t>());
+ InputReaderConfiguration::Change(
+ fdp->ConsumeIntegral<uint32_t>()));
},
[&]() -> void {
std::list<NotifyArgs> unused = mapper.reset(fdp->ConsumeIntegral<nsecs_t>());