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/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
index adc893b..8ef5ff6 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
@@ -139,26 +139,26 @@
std::list<NotifyArgs> CursorInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& readerConfig,
- uint32_t changes) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out = InputMapper::reconfigure(when, readerConfig, changes);
- if (!changes) {
+ if (!changes.any()) {
configureWithZeroChanges(readerConfig);
return out;
}
const bool configurePointerCapture = mParameters.mode != Parameters::Mode::NAVIGATION &&
- (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
+ changes.test(InputReaderConfiguration::Change::POINTER_CAPTURE);
if (configurePointerCapture) {
configureOnPointerCapture(readerConfig);
out.push_back(NotifyDeviceResetArgs(getContext()->getNextId(), when, getDeviceId()));
}
- if ((changes & InputReaderConfiguration::CHANGE_POINTER_SPEED) || configurePointerCapture) {
+ if (changes.test(InputReaderConfiguration::Change::POINTER_SPEED) || configurePointerCapture) {
configureOnChangePointerSpeed(readerConfig);
}
- if ((changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO) || configurePointerCapture) {
+ if (changes.test(InputReaderConfiguration::Change::DISPLAY_INFO) || configurePointerCapture) {
configureOnChangeDisplayInfo(readerConfig);
}
return out;
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.h b/services/inputflinger/reader/mapper/CursorInputMapper.h
index a7cdd51..caf2e5a 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.h
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.h
@@ -62,7 +62,7 @@
virtual void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& readerConfig,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp
index 7100f88..987d2d0 100644
--- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp
@@ -49,7 +49,7 @@
std::list<NotifyArgs> ExternalStylusInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPressureAxis);
mTouchButtonAccumulator.configure();
return {};
diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h
index 7f926a7..841c437 100644
--- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h
+++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h
@@ -35,7 +35,7 @@
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
diff --git a/services/inputflinger/reader/mapper/InputMapper.cpp b/services/inputflinger/reader/mapper/InputMapper.cpp
index bd86a5a..0692dbb 100644
--- a/services/inputflinger/reader/mapper/InputMapper.cpp
+++ b/services/inputflinger/reader/mapper/InputMapper.cpp
@@ -38,7 +38,7 @@
void InputMapper::dump(std::string& dump) {}
std::list<NotifyArgs> InputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
return {};
}
diff --git a/services/inputflinger/reader/mapper/InputMapper.h b/services/inputflinger/reader/mapper/InputMapper.h
index 211be9f..f017317 100644
--- a/services/inputflinger/reader/mapper/InputMapper.h
+++ b/services/inputflinger/reader/mapper/InputMapper.h
@@ -55,7 +55,7 @@
virtual void dump(std::string& dump);
[[nodiscard]] virtual std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes);
+ ConfigurationChanges changes);
[[nodiscard]] virtual std::list<NotifyArgs> reset(nsecs_t when);
[[nodiscard]] virtual std::list<NotifyArgs> process(const RawEvent* rawEvent) = 0;
[[nodiscard]] virtual std::list<NotifyArgs> timeoutExpired(nsecs_t when);
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
index 3450f86..099a955 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
@@ -106,10 +106,10 @@
std::list<NotifyArgs> JoystickInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out = InputMapper::reconfigure(when, config, changes);
- if (!changes) { // first time only
+ if (!changes.any()) { // first time only
// Collect all axes.
for (int32_t abs = 0; abs <= ABS_MAX; abs++) {
if (!(getAbsAxisUsage(abs, getDeviceContext().getDeviceClasses())
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.h b/services/inputflinger/reader/mapper/JoystickInputMapper.h
index c9e92de..49673a2 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.h
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.h
@@ -31,7 +31,7 @@
virtual void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index 63ea3a8..582fb46 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -134,19 +134,20 @@
std::list<NotifyArgs> KeyboardInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out = InputMapper::reconfigure(when, config, changes);
- if (!changes) { // first time only
+ if (!changes.any()) { // first time only
// Configure basic parameters.
configureParameters();
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+ if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) {
mViewport = findViewport(config);
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUT_ASSOCIATION)) {
+ if (!changes.any() ||
+ changes.test(InputReaderConfiguration::Change::KEYBOARD_LAYOUT_ASSOCIATION)) {
mKeyboardLayoutInfo =
getValueByKey(config.keyboardLayoutAssociations, getDeviceContext().getLocation());
}
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.h b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
index 25fad57..bd27383 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.h
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
@@ -33,7 +33,7 @@
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
index 2ffa5cd..13f2e59 100644
--- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
@@ -66,12 +66,12 @@
std::list<NotifyArgs> RotaryEncoderInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out = InputMapper::reconfigure(when, config, changes);
- if (!changes) {
+ if (!changes.any()) {
mRotaryEncoderScrollAccumulator.configure(getDeviceContext());
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+ if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) {
std::optional<DisplayViewport> internalViewport =
config.getDisplayViewportByType(ViewportType::INTERNAL);
if (internalViewport) {
diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h
index 8feaf8e..d3dcbe1 100644
--- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h
+++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h
@@ -34,7 +34,7 @@
virtual void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.cpp b/services/inputflinger/reader/mapper/SensorInputMapper.cpp
index f7f23a4..a131e35 100644
--- a/services/inputflinger/reader/mapper/SensorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/SensorInputMapper.cpp
@@ -119,10 +119,10 @@
std::list<NotifyArgs> SensorInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out = InputMapper::reconfigure(when, config, changes);
- if (!changes) { // first time only
+ if (!changes.any()) { // first time only
mDeviceEnabled = true;
// Check if device has MSC_TIMESTAMP event.
mHasHardwareTimestamp = getDeviceContext().hasMscEvent(MSC_TIMESTAMP);
diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.h b/services/inputflinger/reader/mapper/SensorInputMapper.h
index 2f3a396..1f82559 100644
--- a/services/inputflinger/reader/mapper/SensorInputMapper.h
+++ b/services/inputflinger/reader/mapper/SensorInputMapper.h
@@ -36,7 +36,7 @@
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
bool enableSensor(InputDeviceSensorType sensorType, std::chrono::microseconds samplingPeriod,
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 60bf857..55b869a 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -290,7 +290,7 @@
std::list<NotifyArgs> TouchInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out = InputMapper::reconfigure(when, config, changes);
mConfig = config;
@@ -298,7 +298,7 @@
// Full configuration should happen the first time configure is called and
// when the device type is changed. Changing a device type can affect
// various other parameters so should result in a reconfiguration.
- if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_TYPE)) {
+ if (!changes.any() || changes.test(InputReaderConfiguration::Change::DEVICE_TYPE)) {
// Configure basic parameters.
configureParameters();
@@ -314,33 +314,34 @@
resolveCalibration();
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_TOUCH_AFFINE_TRANSFORMATION)) {
+ if (!changes.any() ||
+ changes.test(InputReaderConfiguration::Change::TOUCH_AFFINE_TRANSFORMATION)) {
// Update location calibration to reflect current settings
updateAffineTransformation();
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) {
+ if (!changes.any() || changes.test(InputReaderConfiguration::Change::POINTER_SPEED)) {
// Update pointer speed.
mPointerVelocityControl.setParameters(mConfig.pointerVelocityControlParameters);
mWheelXVelocityControl.setParameters(mConfig.wheelVelocityControlParameters);
mWheelYVelocityControl.setParameters(mConfig.wheelVelocityControlParameters);
}
+ using namespace ftl::flag_operators;
bool resetNeeded = false;
- if (!changes ||
- (changes &
- (InputReaderConfiguration::CHANGE_DISPLAY_INFO |
- InputReaderConfiguration::CHANGE_POINTER_CAPTURE |
- InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT |
- InputReaderConfiguration::CHANGE_SHOW_TOUCHES |
- InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE |
- InputReaderConfiguration::CHANGE_DEVICE_TYPE))) {
+ if (!changes.any() ||
+ changes.any(InputReaderConfiguration::Change::DISPLAY_INFO |
+ InputReaderConfiguration::Change::POINTER_CAPTURE |
+ InputReaderConfiguration::Change::POINTER_GESTURE_ENABLEMENT |
+ InputReaderConfiguration::Change::SHOW_TOUCHES |
+ InputReaderConfiguration::Change::EXTERNAL_STYLUS_PRESENCE |
+ InputReaderConfiguration::Change::DEVICE_TYPE)) {
// Configure device sources, display dimensions, orientation and
// scaling factors.
configureInputDevice(when, &resetNeeded);
}
- if (changes && resetNeeded) {
+ if (changes.any() && resetNeeded) {
out += reset(when);
// Send reset, unless this is the first time the device has been configured,
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index e7d66a1..e023e90 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -155,7 +155,7 @@
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index 5a1ced4..8753b48 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -222,13 +222,13 @@
std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) {
- if (!changes) {
+ ConfigurationChanges changes) {
+ if (!changes.any()) {
// First time configuration
mPropertyProvider.loadPropertiesFromIdcFile(getDeviceContext().getConfiguration());
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+ if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) {
std::optional<int32_t> displayId = mPointerController->getDisplayId();
ui::Rotation orientation = ui::ROTATION_0;
if (displayId.has_value()) {
@@ -238,7 +238,7 @@
}
mGestureConverter.setOrientation(orientation);
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS)) {
+ if (!changes.any() || changes.test(InputReaderConfiguration::Change::TOUCHPAD_SETTINGS)) {
mPropertyProvider.getProperty("Use Custom Touchpad Pointer Accel Curve")
.setBoolValues({true});
GesturesProp accelCurveProp = mPropertyProvider.getProperty("Pointer Accel Curve");
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index e051097..268b275 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -47,7 +47,7 @@
[[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
const InputReaderConfiguration& config,
- uint32_t changes) override;
+ ConfigurationChanges changes) override;
[[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;