From a546ba8dfb64ef493c06dae1402fb02b024f8262 Mon Sep 17 00:00:00 2001 From: Harry Cutts Date: Fri, 13 Jan 2023 17:21:00 +0000 Subject: Add plumbing from settings to gesture properties Because we don't have the Android curve parameters yet (or the code to put them into the custom curve gesture properties), the fifteen different speed settings get mapped onto the five ChromeOS curves built-in to the gestures library Bug: 251196347, 247080509, 265798483 Test: Use settings command in ADB shell to change values Change-Id: I414d6e63c56d8e42c5848ca4aa150510956c70e3 --- services/inputflinger/InputReaderBase.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'services/inputflinger/InputReaderBase.cpp') diff --git a/services/inputflinger/InputReaderBase.cpp b/services/inputflinger/InputReaderBase.cpp index a864cf8202..2450235ec1 100644 --- a/services/inputflinger/InputReaderBase.cpp +++ b/services/inputflinger/InputReaderBase.cpp @@ -73,6 +73,9 @@ std::string InputReaderConfiguration::changesToString(uint32_t changes) { if (changes & CHANGE_ENABLED_STATE) { result += "ENABLED_STATE | "; } + if (changes & CHANGE_TOUCHPAD_SETTINGS) { + result += "TOUCHPAD_SETTINGS | "; + } if (changes & CHANGE_MUST_REOPEN) { result += "MUST_REOPEN | "; } -- cgit v1.2.3-59-g8ed1b From 4bf6d455dc8f1d0b22614028062c5d0a21130139 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Tue, 18 Apr 2023 21:26:56 +0000 Subject: 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 --- services/inputflinger/InputReaderBase.cpp | 44 ---- services/inputflinger/include/InputReaderBase.h | 256 ++++++++++----------- services/inputflinger/reader/InputDevice.cpp | 18 +- services/inputflinger/reader/InputReader.cpp | 34 +-- services/inputflinger/reader/include/InputDevice.h | 2 +- services/inputflinger/reader/include/InputReader.h | 6 +- .../reader/mapper/CursorInputMapper.cpp | 10 +- .../inputflinger/reader/mapper/CursorInputMapper.h | 2 +- .../reader/mapper/ExternalStylusInputMapper.cpp | 2 +- .../reader/mapper/ExternalStylusInputMapper.h | 2 +- .../inputflinger/reader/mapper/InputMapper.cpp | 2 +- services/inputflinger/reader/mapper/InputMapper.h | 2 +- .../reader/mapper/JoystickInputMapper.cpp | 4 +- .../reader/mapper/JoystickInputMapper.h | 2 +- .../reader/mapper/KeyboardInputMapper.cpp | 9 +- .../reader/mapper/KeyboardInputMapper.h | 2 +- .../reader/mapper/RotaryEncoderInputMapper.cpp | 6 +- .../reader/mapper/RotaryEncoderInputMapper.h | 2 +- .../reader/mapper/SensorInputMapper.cpp | 4 +- .../inputflinger/reader/mapper/SensorInputMapper.h | 2 +- .../reader/mapper/TouchInputMapper.cpp | 27 +-- .../inputflinger/reader/mapper/TouchInputMapper.h | 2 +- .../reader/mapper/TouchpadInputMapper.cpp | 8 +- .../reader/mapper/TouchpadInputMapper.h | 2 +- services/inputflinger/tests/InputMapperTest.cpp | 14 +- services/inputflinger/tests/InputMapperTest.h | 4 +- services/inputflinger/tests/InputReader_test.cpp | 128 +++++------ .../tests/fuzzers/CursorInputFuzzer.cpp | 12 +- .../inputflinger/tests/fuzzers/FuzzContainer.h | 2 +- .../tests/fuzzers/InputReaderFuzzer.cpp | 5 +- .../tests/fuzzers/KeyboardInputFuzzer.cpp | 3 +- .../tests/fuzzers/MultiTouchInputFuzzer.cpp | 3 +- 32 files changed, 290 insertions(+), 331 deletions(-) (limited to 'services/inputflinger/InputReaderBase.cpp') diff --git a/services/inputflinger/InputReaderBase.cpp b/services/inputflinger/InputReaderBase.cpp index 2450235ec1..4ec5b898b1 100644 --- a/services/inputflinger/InputReaderBase.cpp +++ b/services/inputflinger/InputReaderBase.cpp @@ -38,50 +38,6 @@ namespace android { // --- InputReaderConfiguration --- -std::string InputReaderConfiguration::changesToString(uint32_t changes) { - if (changes == 0) { - return ""; - } - std::string result; - if (changes & CHANGE_POINTER_SPEED) { - result += "POINTER_SPEED | "; - } - if (changes & CHANGE_POINTER_GESTURE_ENABLEMENT) { - result += "POINTER_GESTURE_ENABLEMENT | "; - } - if (changes & CHANGE_DISPLAY_INFO) { - result += "DISPLAY_INFO | "; - } - if (changes & CHANGE_SHOW_TOUCHES) { - result += "SHOW_TOUCHES | "; - } - if (changes & CHANGE_KEYBOARD_LAYOUTS) { - result += "KEYBOARD_LAYOUTS | "; - } - if (changes & CHANGE_DEVICE_ALIAS) { - result += "DEVICE_ALIAS | "; - } - if (changes & CHANGE_TOUCH_AFFINE_TRANSFORMATION) { - result += "TOUCH_AFFINE_TRANSFORMATION | "; - } - if (changes & CHANGE_EXTERNAL_STYLUS_PRESENCE) { - result += "EXTERNAL_STYLUS_PRESENCE | "; - } - if (changes & CHANGE_POINTER_CAPTURE) { - result += "POINTER_CAPTURE | "; - } - if (changes & CHANGE_ENABLED_STATE) { - result += "ENABLED_STATE | "; - } - if (changes & CHANGE_TOUCHPAD_SETTINGS) { - result += "TOUCHPAD_SETTINGS | "; - } - if (changes & CHANGE_MUST_REOPEN) { - result += "MUST_REOPEN | "; - } - return result; -} - std::optional InputReaderConfiguration::getDisplayViewportByUniqueId( const std::string& uniqueDisplayId) const { if (uniqueDisplayId.empty()) { diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h index 1750c64eca..a93a2ea615 100644 --- a/services/inputflinger/include/InputReaderBase.h +++ b/services/inputflinger/include/InputReaderBase.h @@ -42,118 +42,6 @@ namespace android { -// --- InputReaderInterface --- - -/* The interface for the InputReader shared library. - * - * Manages one or more threads that process raw input events and sends cooked event data to an - * input listener. - * - * The implementation must guarantee thread safety for this interface. However, since the input - * listener is NOT thread safe, all calls to the listener must happen from the same thread. - */ -class InputReaderInterface { -public: - InputReaderInterface() { } - virtual ~InputReaderInterface() { } - - /* Dumps the state of the input reader. - * - * This method may be called on any thread (usually by the input manager). */ - virtual void dump(std::string& dump) = 0; - - /* Called by the heartbeat to ensures that the reader has not deadlocked. */ - virtual void monitor() = 0; - - /* Returns true if the input device is enabled. */ - virtual bool isInputDeviceEnabled(int32_t deviceId) = 0; - - /* Makes the reader start processing events from the kernel. */ - virtual status_t start() = 0; - - /* Makes the reader stop processing any more events. */ - virtual status_t stop() = 0; - - /* Gets information about all input devices. - * - * This method may be called on any thread (usually by the input manager). - */ - virtual std::vector getInputDevices() const = 0; - - /* Query current input state. */ - virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, - int32_t scanCode) = 0; - virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, - int32_t keyCode) = 0; - virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, - int32_t sw) = 0; - - virtual void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode, - int32_t toKeyCode) const = 0; - - virtual int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const = 0; - - /* Toggle Caps Lock */ - virtual void toggleCapsLockState(int32_t deviceId) = 0; - - /* Determine whether physical keys exist for the given framework-domain key codes. */ - virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, - const std::vector& keyCodes, uint8_t* outFlags) = 0; - - /* Requests that a reconfiguration of all input devices. - * The changes flag is a bitfield that indicates what has changed and whether - * the input devices must all be reopened. */ - virtual void requestRefreshConfiguration(uint32_t changes) = 0; - - /* Controls the vibrator of a particular input device. */ - virtual void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat, - int32_t token) = 0; - virtual void cancelVibrate(int32_t deviceId, int32_t token) = 0; - - virtual bool isVibrating(int32_t deviceId) = 0; - - virtual std::vector getVibratorIds(int32_t deviceId) = 0; - /* Get battery level of a particular input device. */ - virtual std::optional getBatteryCapacity(int32_t deviceId) = 0; - /* Get battery status of a particular input device. */ - virtual std::optional getBatteryStatus(int32_t deviceId) = 0; - /* Get the device path for the battery of an input device. */ - virtual std::optional getBatteryDevicePath(int32_t deviceId) = 0; - - virtual std::vector getLights(int32_t deviceId) = 0; - - virtual std::vector getSensors(int32_t deviceId) = 0; - - /* Return true if the device can send input events to the specified display. */ - virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0; - - /* Enable sensor in input reader mapper. */ - virtual bool enableSensor(int32_t deviceId, InputDeviceSensorType sensorType, - std::chrono::microseconds samplingPeriod, - std::chrono::microseconds maxBatchReportLatency) = 0; - - /* Disable sensor in input reader mapper. */ - virtual void disableSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0; - - /* Flush sensor data in input reader mapper. */ - virtual void flushSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0; - - /* Set color for the light */ - virtual bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) = 0; - /* Set player ID for the light */ - virtual bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) = 0; - /* Get light color */ - virtual std::optional getLightColor(int32_t deviceId, int32_t lightId) = 0; - /* Get light player ID */ - virtual std::optional getLightPlayerId(int32_t deviceId, int32_t lightId) = 0; - - /* Get the Bluetooth address of an input device, if known. */ - virtual std::optional getBluetoothAddress(int32_t deviceId) const = 0; - - /* Sysfs node change reported. Recreate device if required to incorporate the new sysfs nodes */ - virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0; -}; - // --- InputReaderConfiguration --- /* @@ -163,51 +51,51 @@ public: */ struct InputReaderConfiguration { // Describes changes that have occurred. - enum { + enum class Change : uint32_t { // The mouse pointer speed changed. - CHANGE_POINTER_SPEED = 1 << 0, + POINTER_SPEED = 1u << 0, // The pointer gesture control changed. - CHANGE_POINTER_GESTURE_ENABLEMENT = 1 << 1, + POINTER_GESTURE_ENABLEMENT = 1u << 1, // The display size or orientation changed. - CHANGE_DISPLAY_INFO = 1 << 2, + DISPLAY_INFO = 1u << 2, // The visible touches option changed. - CHANGE_SHOW_TOUCHES = 1 << 3, + SHOW_TOUCHES = 1u << 3, // The keyboard layouts must be reloaded. - CHANGE_KEYBOARD_LAYOUTS = 1 << 4, + KEYBOARD_LAYOUTS = 1u << 4, // The device name alias supplied by the may have changed for some devices. - CHANGE_DEVICE_ALIAS = 1 << 5, + DEVICE_ALIAS = 1u << 5, // The location calibration matrix changed. - CHANGE_TOUCH_AFFINE_TRANSFORMATION = 1 << 6, + TOUCH_AFFINE_TRANSFORMATION = 1u << 6, // The presence of an external stylus has changed. - CHANGE_EXTERNAL_STYLUS_PRESENCE = 1 << 7, + EXTERNAL_STYLUS_PRESENCE = 1u << 7, // The pointer capture mode has changed. - CHANGE_POINTER_CAPTURE = 1 << 8, + POINTER_CAPTURE = 1u << 8, // The set of disabled input devices (disabledDevices) has changed. - CHANGE_ENABLED_STATE = 1 << 9, + ENABLED_STATE = 1u << 9, // The device type has been updated. - CHANGE_DEVICE_TYPE = 1 << 10, + DEVICE_TYPE = 1u << 10, // The keyboard layout association has changed. - CHANGE_KEYBOARD_LAYOUT_ASSOCIATION = 1 << 11, + KEYBOARD_LAYOUT_ASSOCIATION = 1u << 11, // The stylus button reporting configurations has changed. - CHANGE_STYLUS_BUTTON_REPORTING = 1 << 12, + STYLUS_BUTTON_REPORTING = 1u << 12, // The touchpad settings changed. - CHANGE_TOUCHPAD_SETTINGS = 1 << 13, + TOUCHPAD_SETTINGS = 1u << 13, // All devices must be reopened. - CHANGE_MUST_REOPEN = 1 << 31, + MUST_REOPEN = 1u << 31, }; // Gets the amount of time to disable virtual keys after the screen is touched @@ -367,8 +255,6 @@ struct InputReaderConfiguration { stylusButtonMotionEventsEnabled(true), stylusPointerIconEnabled(false) {} - static std::string changesToString(uint32_t changes); - std::optional getDisplayViewportByType(ViewportType type) const; std::optional getDisplayViewportByUniqueId(const std::string& uniqueDisplayId) const; @@ -383,6 +269,116 @@ private: std::vector mDisplays; }; +using ConfigurationChanges = ftl::Flags; + +// --- InputReaderInterface --- + +/* The interface for the InputReader shared library. + * + * Manages one or more threads that process raw input events and sends cooked event data to an + * input listener. + * + * The implementation must guarantee thread safety for this interface. However, since the input + * listener is NOT thread safe, all calls to the listener must happen from the same thread. + */ +class InputReaderInterface { +public: + InputReaderInterface() {} + virtual ~InputReaderInterface() {} + /* Dumps the state of the input reader. + * + * This method may be called on any thread (usually by the input manager). */ + virtual void dump(std::string& dump) = 0; + + /* Called by the heartbeat to ensures that the reader has not deadlocked. */ + virtual void monitor() = 0; + + /* Returns true if the input device is enabled. */ + virtual bool isInputDeviceEnabled(int32_t deviceId) = 0; + + /* Makes the reader start processing events from the kernel. */ + virtual status_t start() = 0; + + /* Makes the reader stop processing any more events. */ + virtual status_t stop() = 0; + + /* Gets information about all input devices. + * + * This method may be called on any thread (usually by the input manager). + */ + virtual std::vector getInputDevices() const = 0; + + /* Query current input state. */ + virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, int32_t scanCode) = 0; + virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, int32_t keyCode) = 0; + virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) = 0; + + virtual void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode, + int32_t toKeyCode) const = 0; + + virtual int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const = 0; + + /* Toggle Caps Lock */ + virtual void toggleCapsLockState(int32_t deviceId) = 0; + + /* Determine whether physical keys exist for the given framework-domain key codes. */ + virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, + const std::vector& keyCodes, uint8_t* outFlags) = 0; + + /* Requests that a reconfiguration of all input devices. + * The changes flag is a bitfield that indicates what has changed and whether + * the input devices must all be reopened. */ + virtual void requestRefreshConfiguration(ConfigurationChanges changes) = 0; + + /* Controls the vibrator of a particular input device. */ + virtual void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat, + int32_t token) = 0; + virtual void cancelVibrate(int32_t deviceId, int32_t token) = 0; + + virtual bool isVibrating(int32_t deviceId) = 0; + + virtual std::vector getVibratorIds(int32_t deviceId) = 0; + /* Get battery level of a particular input device. */ + virtual std::optional getBatteryCapacity(int32_t deviceId) = 0; + /* Get battery status of a particular input device. */ + virtual std::optional getBatteryStatus(int32_t deviceId) = 0; + /* Get the device path for the battery of an input device. */ + virtual std::optional getBatteryDevicePath(int32_t deviceId) = 0; + + virtual std::vector getLights(int32_t deviceId) = 0; + + virtual std::vector getSensors(int32_t deviceId) = 0; + + /* Return true if the device can send input events to the specified display. */ + virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0; + + /* Enable sensor in input reader mapper. */ + virtual bool enableSensor(int32_t deviceId, InputDeviceSensorType sensorType, + std::chrono::microseconds samplingPeriod, + std::chrono::microseconds maxBatchReportLatency) = 0; + + /* Disable sensor in input reader mapper. */ + virtual void disableSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0; + + /* Flush sensor data in input reader mapper. */ + virtual void flushSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0; + + /* Set color for the light */ + virtual bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) = 0; + /* Set player ID for the light */ + virtual bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) = 0; + /* Get light color */ + virtual std::optional getLightColor(int32_t deviceId, int32_t lightId) = 0; + /* Get light player ID */ + virtual std::optional getLightPlayerId(int32_t deviceId, int32_t lightId) = 0; + + /* Get the Bluetooth address of an input device, if known. */ + virtual std::optional getBluetoothAddress(int32_t deviceId) const = 0; + + /* Sysfs node change reported. Recreate device if required to incorporate the new sysfs nodes */ + virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0; +}; + // --- TouchAffineTransformation --- struct TouchAffineTransformation { diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp index b5ee0445c2..b86906b2cd 100644 --- a/services/inputflinger/reader/InputDevice.cpp +++ b/services/inputflinger/reader/InputDevice.cpp @@ -180,7 +180,7 @@ void InputDevice::removeEventHubDevice(int32_t eventHubId) { std::list InputDevice::configure(nsecs_t when, const InputReaderConfiguration& readerConfig, - uint32_t changes) { + ConfigurationChanges changes) { std::list out; mSources = 0; mClasses = ftl::Flags(0); @@ -201,12 +201,14 @@ std::list InputDevice::configure(nsecs_t when, mIsExternal = mClasses.test(InputDeviceClass::EXTERNAL); mHasMic = mClasses.test(InputDeviceClass::MIC); + using Change = InputReaderConfiguration::Change; + if (!isIgnored()) { // 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(Change::DEVICE_TYPE)) { mConfiguration.clear(); for_each_subdevice([this](InputDeviceContext& context) { std::optional configuration = @@ -220,7 +222,7 @@ std::list InputDevice::configure(nsecs_t when, getValueByKey(readerConfig.deviceTypeAssociations, mIdentifier.location); } - if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS)) { + if (!changes.any() || changes.test(Change::KEYBOARD_LAYOUTS)) { if (!mClasses.test(InputDeviceClass::VIRTUAL)) { std::shared_ptr keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); @@ -237,7 +239,7 @@ std::list InputDevice::configure(nsecs_t when, } } - if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_ALIAS)) { + if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); if (mAlias != alias) { @@ -247,7 +249,7 @@ std::list InputDevice::configure(nsecs_t when, } } - if (changes & InputReaderConfiguration::CHANGE_ENABLED_STATE) { + if (changes.test(Change::ENABLED_STATE)) { // Do not execute this code on the first configure, because 'setEnabled' would call // InputMapper::reset, and you can't reset a mapper before it has been configured. // The mappers are configured for the first time at the bottom of this function. @@ -256,7 +258,7 @@ std::list InputDevice::configure(nsecs_t when, out += setEnabled(enabled, when); } - if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { + if (!changes.any() || changes.test(Change::DISPLAY_INFO)) { // In most situations, no port or name will be specified. mAssociatedDisplayPort = std::nullopt; mAssociatedDisplayUniqueId = std::nullopt; @@ -305,7 +307,7 @@ std::list InputDevice::configure(nsecs_t when, } } - if (changes) { + if (changes.any()) { // For first-time configuration, only allow device to be disabled after mappers have // finished configuring. This is because we need to read some of the properties from // the device's open fd. @@ -320,7 +322,7 @@ std::list InputDevice::configure(nsecs_t when, // If a device is just plugged but it might be disabled, we need to update some info like // axis range of touch from each InputMapper first, then disable it. - if (!changes) { + if (!changes.any()) { out += setEnabled(readerConfig.disabledDevices.find(mId) == readerConfig.disabledDevices.end(), when); diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp index 0afe79dcc4..ea95f7857a 100644 --- a/services/inputflinger/reader/InputReader.cpp +++ b/services/inputflinger/reader/InputReader.cpp @@ -85,7 +85,7 @@ InputReader::InputReader(std::shared_ptr eventHub, mDisableVirtualKeysTimeout(LLONG_MIN), mNextTimeout(LLONG_MAX), mConfigurationChangesToRefresh(0) { - refreshConfigurationLocked(0); + refreshConfigurationLocked(/*changes=*/{}); updateGlobalMetaStateLocked(); } @@ -122,9 +122,9 @@ void InputReader::loopOnce() { oldGeneration = mGeneration; timeoutMillis = -1; - uint32_t changes = mConfigurationChangesToRefresh; - if (changes) { - mConfigurationChangesToRefresh = 0; + auto changes = mConfigurationChangesToRefresh; + if (changes.any()) { + mConfigurationChangesToRefresh.clear(); timeoutMillis = 0; refreshConfigurationLocked(changes); } else if (mNextTimeout != LLONG_MAX) { @@ -236,7 +236,7 @@ void InputReader::addDeviceLocked(nsecs_t when, int32_t eventHubId) { InputDeviceIdentifier identifier = mEventHub->getDeviceIdentifier(eventHubId); std::shared_ptr device = createDeviceLocked(eventHubId, identifier); - notifyAll(device->configure(when, mConfig, 0)); + notifyAll(device->configure(when, mConfig, /*changes=*/{})); notifyAll(device->reset(when)); if (device->isIgnored()) { @@ -312,7 +312,7 @@ void InputReader::removeDeviceLocked(nsecs_t when, int32_t eventHubId) { std::list resetEvents; if (device->hasEventHubDevices()) { - resetEvents += device->configure(when, mConfig, 0); + resetEvents += device->configure(when, mConfig, /*changes=*/{}); } resetEvents += device->reset(when); notifyAll(std::move(resetEvents)); @@ -390,21 +390,21 @@ void InputReader::handleConfigurationChangedLocked(nsecs_t when) { mQueuedListener.notifyConfigurationChanged({mContext.getNextId(), when}); } -void InputReader::refreshConfigurationLocked(uint32_t changes) { +void InputReader::refreshConfigurationLocked(ConfigurationChanges changes) { mPolicy->getReaderConfiguration(&mConfig); mEventHub->setExcludedDevices(mConfig.excludedDeviceNames); - if (!changes) return; + using Change = InputReaderConfiguration::Change; + if (!changes.any()) return; - ALOGI("Reconfiguring input devices, changes=%s", - InputReaderConfiguration::changesToString(changes).c_str()); + ALOGI("Reconfiguring input devices, changes=%s", changes.string().c_str()); nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); - if (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO) { + if (changes.test(Change::DISPLAY_INFO)) { updatePointerDisplayLocked(); } - if (changes & InputReaderConfiguration::CHANGE_MUST_REOPEN) { + if (changes.test(Change::MUST_REOPEN)) { mEventHub->requestReopenDevices(); } else { for (auto& devicePair : mDevices) { @@ -413,7 +413,7 @@ void InputReader::refreshConfigurationLocked(uint32_t changes) { } } - if (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE) { + if (changes.test(Change::POINTER_CAPTURE)) { if (mCurrentPointerCaptureRequest == mConfig.pointerCaptureRequest) { ALOGV("Skipping notifying pointer capture changes: " "There was no change in the pointer capture state."); @@ -457,7 +457,7 @@ int32_t InputReader::getLedMetaStateLocked() { } void InputReader::notifyExternalStylusPresenceChangedLocked() { - refreshConfigurationLocked(InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE); + refreshConfigurationLocked(InputReaderConfiguration::Change::EXTERNAL_STYLUS_PRESENCE); } void InputReader::getExternalStylusDevicesLocked(std::vector& outDevices) { @@ -671,11 +671,11 @@ int32_t InputReader::getKeyCodeForKeyLocation(int32_t deviceId, int32_t location return device->getKeyCodeForKeyLocation(locationKeyCode); } -void InputReader::requestRefreshConfiguration(uint32_t changes) { +void InputReader::requestRefreshConfiguration(ConfigurationChanges changes) { std::scoped_lock _l(mLock); - if (changes) { - bool needWake = !mConfigurationChangesToRefresh; + if (changes.any()) { + bool needWake = !mConfigurationChangesToRefresh.any(); mConfigurationChangesToRefresh |= changes; if (needWake) { diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h index 2091e16cf7..73351c407a 100644 --- a/services/inputflinger/reader/include/InputDevice.h +++ b/services/inputflinger/reader/include/InputDevice.h @@ -85,7 +85,7 @@ public: void removeEventHubDevice(int32_t eventHubId); [[nodiscard]] std::list configure(nsecs_t when, const InputReaderConfiguration& readerConfig, - uint32_t changes); + ConfigurationChanges changes); [[nodiscard]] std::list reset(nsecs_t when); [[nodiscard]] std::list process(const RawEvent* rawEvents, size_t count); [[nodiscard]] std::list timeoutExpired(nsecs_t when); diff --git a/services/inputflinger/reader/include/InputReader.h b/services/inputflinger/reader/include/InputReader.h index 120e15070c..9112913565 100644 --- a/services/inputflinger/reader/include/InputReader.h +++ b/services/inputflinger/reader/include/InputReader.h @@ -77,7 +77,7 @@ public: bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector& keyCodes, uint8_t* outFlags) override; - void requestRefreshConfiguration(uint32_t changes) override; + void requestRefreshConfiguration(ConfigurationChanges changes) override; void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat, int32_t token) override; @@ -233,8 +233,8 @@ private: nsecs_t mNextTimeout GUARDED_BY(mLock); void requestTimeoutAtTimeLocked(nsecs_t when) REQUIRES(mLock); - uint32_t mConfigurationChangesToRefresh GUARDED_BY(mLock); - void refreshConfigurationLocked(uint32_t changes) REQUIRES(mLock); + ConfigurationChanges mConfigurationChangesToRefresh GUARDED_BY(mLock); + void refreshConfigurationLocked(ConfigurationChanges changes) REQUIRES(mLock); void notifyAll(std::list&& argsList); diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp index adc893b12b..8ef5ff6358 100644 --- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp +++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp @@ -139,26 +139,26 @@ void CursorInputMapper::dump(std::string& dump) { std::list CursorInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& readerConfig, - uint32_t changes) { + ConfigurationChanges changes) { std::list 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 a7cdd51df1..caf2e5a4c4 100644 --- a/services/inputflinger/reader/mapper/CursorInputMapper.h +++ b/services/inputflinger/reader/mapper/CursorInputMapper.h @@ -62,7 +62,7 @@ public: virtual void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& readerConfig, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp index 7100f88e79..987d2d0221 100644 --- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp +++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp @@ -49,7 +49,7 @@ void ExternalStylusInputMapper::dump(std::string& dump) { std::list 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 7f926a72e7..841c437543 100644 --- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h +++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h @@ -35,7 +35,7 @@ public: void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/reader/mapper/InputMapper.cpp b/services/inputflinger/reader/mapper/InputMapper.cpp index bd86a5a539..0692dbbe0a 100644 --- a/services/inputflinger/reader/mapper/InputMapper.cpp +++ b/services/inputflinger/reader/mapper/InputMapper.cpp @@ -38,7 +38,7 @@ void InputMapper::populateDeviceInfo(InputDeviceInfo& info) { void InputMapper::dump(std::string& dump) {} std::list 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 211be9fd32..f017317485 100644 --- a/services/inputflinger/reader/mapper/InputMapper.h +++ b/services/inputflinger/reader/mapper/InputMapper.h @@ -55,7 +55,7 @@ public: virtual void dump(std::string& dump); [[nodiscard]] virtual std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes); + ConfigurationChanges changes); [[nodiscard]] virtual std::list reset(nsecs_t when); [[nodiscard]] virtual std::list process(const RawEvent* rawEvent) = 0; [[nodiscard]] virtual std::list timeoutExpired(nsecs_t when); diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp index 3450f86fbf..099a95541e 100644 --- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp +++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp @@ -106,10 +106,10 @@ void JoystickInputMapper::dump(std::string& dump) { std::list JoystickInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) { + ConfigurationChanges changes) { std::list 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 c9e92defbf..49673a2f4e 100644 --- a/services/inputflinger/reader/mapper/JoystickInputMapper.h +++ b/services/inputflinger/reader/mapper/JoystickInputMapper.h @@ -31,7 +31,7 @@ public: virtual void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp index 63ea3a877e..582fb46550 100644 --- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp @@ -134,19 +134,20 @@ std::optional KeyboardInputMapper::findViewport( std::list KeyboardInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) { + ConfigurationChanges changes) { std::list 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 25fad57e31..bd27383296 100644 --- a/services/inputflinger/reader/mapper/KeyboardInputMapper.h +++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.h @@ -33,7 +33,7 @@ public: void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp index 2ffa5cd3e0..13f2e59db9 100644 --- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp +++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp @@ -66,12 +66,12 @@ void RotaryEncoderInputMapper::dump(std::string& dump) { std::list RotaryEncoderInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) { + ConfigurationChanges changes) { std::list 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 internalViewport = config.getDisplayViewportByType(ViewportType::INTERNAL); if (internalViewport) { diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h index 8feaf8e3bc..d3dcbe1bb4 100644 --- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h +++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h @@ -34,7 +34,7 @@ public: virtual void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.cpp b/services/inputflinger/reader/mapper/SensorInputMapper.cpp index f7f23a41a7..a131e3598f 100644 --- a/services/inputflinger/reader/mapper/SensorInputMapper.cpp +++ b/services/inputflinger/reader/mapper/SensorInputMapper.cpp @@ -119,10 +119,10 @@ void SensorInputMapper::dump(std::string& dump) { std::list SensorInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) { + ConfigurationChanges changes) { std::list 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 2f3a39665d..1f82559db8 100644 --- a/services/inputflinger/reader/mapper/SensorInputMapper.h +++ b/services/inputflinger/reader/mapper/SensorInputMapper.h @@ -36,7 +36,7 @@ public: void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list 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 60bf857318..55b869a735 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -290,7 +290,7 @@ void TouchInputMapper::dump(std::string& dump) { std::list TouchInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) { + ConfigurationChanges changes) { std::list out = InputMapper::reconfigure(when, config, changes); mConfig = config; @@ -298,7 +298,7 @@ std::list TouchInputMapper::reconfigure(nsecs_t when, // 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 @@ std::list TouchInputMapper::reconfigure(nsecs_t when, 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 e7d66a1c4d..e023e90758 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.h +++ b/services/inputflinger/reader/mapper/TouchInputMapper.h @@ -155,7 +155,7 @@ public: void dump(std::string& dump) override; [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp index 5a1ced486a..8753b487e3 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp @@ -222,13 +222,13 @@ void TouchpadInputMapper::dump(std::string& dump) { std::list 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 displayId = mPointerController->getDisplayId(); ui::Rotation orientation = ui::ROTATION_0; if (displayId.has_value()) { @@ -238,7 +238,7 @@ std::list TouchpadInputMapper::reconfigure(nsecs_t when, } 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 e05109730a..268b275584 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h @@ -47,7 +47,7 @@ public: [[nodiscard]] std::list reconfigure(nsecs_t when, const InputReaderConfiguration& config, - uint32_t changes) override; + ConfigurationChanges changes) override; [[nodiscard]] std::list reset(nsecs_t when) override; [[nodiscard]] std::list process(const RawEvent* rawEvent) override; diff --git a/services/inputflinger/tests/InputMapperTest.cpp b/services/inputflinger/tests/InputMapperTest.cpp index ae300066d2..ad48a79731 100644 --- a/services/inputflinger/tests/InputMapperTest.cpp +++ b/services/inputflinger/tests/InputMapperTest.cpp @@ -50,12 +50,12 @@ void InputMapperTest::addConfigurationProperty(const char* key, const char* valu mFakeEventHub->addConfigurationProperty(EVENTHUB_ID, key, value); } -std::list InputMapperTest::configureDevice(uint32_t changes) { - if (!changes || - (changes & - (InputReaderConfiguration::CHANGE_DISPLAY_INFO | - InputReaderConfiguration::CHANGE_POINTER_CAPTURE | - InputReaderConfiguration::CHANGE_DEVICE_TYPE))) { +std::list 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 @@ void InputMapperTest::setDisplayInfoAndReconfigure(int32_t displayId, int32_t wi 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 df601ea920..d9690349fb 100644 --- a/services/inputflinger/tests/InputMapperTest.h +++ b/services/inputflinger/tests/InputMapperTest.h @@ -54,7 +54,7 @@ protected: void TearDown() override; void addConfigurationProperty(const char* key, const char* value); - std::list configureDevice(uint32_t changes); + std::list configureDevice(ConfigurationChanges changes); std::shared_ptr newDevice(int32_t deviceId, const std::string& name, const std::string& location, int32_t eventHubId, ftl::Flags classes, int bus = 0); @@ -62,7 +62,7 @@ protected: T& addMapperAndConfigure(Args... args) { T& mapper = mDevice->addMapper(EVENTHUB_ID, mFakePolicy->getReaderConfiguration(), args...); - configureDevice(0); + configureDevice(/*changes=*/{}); std::list 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 da3fe5bc4f..0b505045bd 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -265,13 +265,13 @@ private: } std::list reconfigure(nsecs_t, const InputReaderConfiguration& config, - uint32_t changes) override { + ConfigurationChanges changes) override { std::scoped_lock lock(mLock); mConfigureWasCalled = true; // Find the associated viewport if exist. const std::optional 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 @@ protected: 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 @@ TEST_F(InputReaderTest, Device_CanDispatchToDisplay) { 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 @@ TEST_F(InputReaderTest, ChangingPointerCaptureNotifiesInputListener) { 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 @@ protected: 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& points) { @@ -2070,7 +2070,7 @@ TYPED_TEST(StylusButtonIntegrationTest, DISABLED_StylusButtonsWithinTouchGesture 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, WhenDeviceCreated_EnabledIsFalse) { TEST_F(InputDeviceTest, WhenNoMappersAreRegistered_DeviceIsIgnored) { // Configuration. InputReaderConfiguration config; - std::list unused = mDevice->configure(ARBITRARY_TIME, config, 0); + std::list unused = mDevice->configure(ARBITRARY_TIME, config, /*changes=*/{}); // Reset. unused += mDevice->reset(ARBITRARY_TIME); @@ -2402,7 +2402,7 @@ TEST_F(InputDeviceTest, WhenMappersAreRegistered_DeviceIsNotIgnoredAndForwardsRe mapper2.setMetaState(AMETA_SHIFT_ON); InputReaderConfiguration config; - std::list unused = mDevice->configure(ARBITRARY_TIME, config, 0); + std::list unused = mDevice->configure(ARBITRARY_TIME, config, /*changes=*/{}); std::optional propertyValue = mDevice->getConfiguration().getString("key"); ASSERT_TRUE(propertyValue.has_value()) @@ -2484,7 +2484,8 @@ TEST_F(InputDeviceTest, Configure_AssignsDisplayPort) { // First Configuration. std::list 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 @@ TEST_F(InputDeviceTest, Configure_AssignsDisplayPort) { 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 @@ TEST_F(InputDeviceTest, Configure_AssignsDisplayPort) { 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 @@ TEST_F(InputDeviceTest, Configure_AssignsDisplayUniqueId) { mDevice->addMapper(EVENTHUB_ID, mFakePolicy->getReaderConfiguration(), AINPUT_SOURCE_KEYBOARD); std::list 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 @@ TEST_F(InputDeviceTest, Configure_AssignsDisplayUniqueId) { 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 @@ TEST_F(InputDeviceTest, Configure_UniqueId_CorrectlyMatches) { mDevice->addMapper(EVENTHUB_ID, mFakePolicy->getReaderConfiguration(), AINPUT_SOURCE_KEYBOARD); std::list 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 @@ TEST_F(KeyboardInputMapperTest, Configure_AssignsDisplayPort) { AINPUT_KEYBOARD_TYPE_ALPHABETIC); std::list unused = device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), - /*changes=*/0); + /*changes=*/{}); unused += device2->reset(ARBITRARY_TIME); // Prepared displays and associated info. @@ -3436,7 +3439,7 @@ TEST_F(KeyboardInputMapperTest, Configure_AssignsDisplayPort) { // 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 @@ TEST_F(KeyboardInputMapperTest, Configure_AssignsDisplayPort) { 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 @@ TEST_F(KeyboardInputMapperTest, Process_LockedKeysShouldToggleAfterReattach) { AINPUT_KEYBOARD_TYPE_ALPHABETIC); std::list 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 @@ TEST_F(KeyboardInputMapperTest, Process_LockedKeysShouldToggleInMultiDevices) { AINPUT_KEYBOARD_TYPE_ALPHABETIC); std::list unused = device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), - /*changes=*/0); + /*changes=*/{}); unused += device2->reset(ARBITRARY_TIME); // Initial metastate is AMETA_NONE. @@ -3667,7 +3670,7 @@ TEST_F(KeyboardInputMapperTest, Process_DisabledDevice) { // 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 @@ TEST_F(KeyboardInputMapperTest, Configure_AssignKeyboardLayoutInfo) { AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC); std::list 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 @@ TEST_F(KeyboardInputMapperTest, LayoutInfoCorrectlyMapped) { addMapperAndConfigure(AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC); InputReaderConfiguration config; - std::list unused = mDevice->configure(ARBITRARY_TIME, config, 0); + std::list 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 @@ TEST_F(CursorInputMapperTest, Process_PointerCapture) { // 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 @@ TEST_F(CursorInputMapperTest, PointerCaptureDisablesVelocityProcessing) { // 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 @@ TEST_F(CursorInputMapperTest, PointerCaptureDisablesOrientationChanges) { // 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 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_NoAssociatedViewport) { // 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 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_WithAssociatedViewport) { 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 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_IgnoresEventsForMismatchedPoint // 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 @@ TEST_F(SingleTouchInputMapperTest, Process_IgnoresTouchesOutsidePhysicalFrame) { 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 @@ TEST_F(SingleTouchInputMapperTest, 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 @@ TEST_F(SingleTouchInputMapperTest, // 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 @@ TEST_F(SingleTouchInputMapperTest, WhenDeviceTypeIsChangedToTouchNavigation_upda // Send update to the mapper. std::list 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 @@ TEST_F(SingleTouchInputMapperTest, HoverEventsOutsidePhysicalFrameAreIgnored) { 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(); @@ -6873,7 +6877,7 @@ public: 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 @@ public: 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 @@ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreDropped) { // 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(); @@ -9309,7 +9313,7 @@ TEST_F(MultiTouchInputMapperTest, WhenViewportIsNotActive_TouchesAreProcessed) { 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(); @@ -9331,7 +9335,7 @@ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { ASSERT_TRUE(optionalDisplayViewport.has_value()); DisplayViewport displayViewport = *optionalDisplayViewport; - configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO); + configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO); prepareAxes(POSITION); MultiTouchInputMapper& mapper = addMapperAndConfigure(); @@ -9347,7 +9351,7 @@ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { // 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 @@ TEST_F(MultiTouchInputMapperTest, Process_DeactivateViewport_AbortTouches) { // 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 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { mFakePolicy->getReaderConfiguration()); std::list unused = device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), - /*changes=*/0); + /*changes=*/{}); unused += device2->reset(ARBITRARY_TIME); // Setup PointerController. @@ -9426,8 +9430,8 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { // 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 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) { // 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 @@ TEST_F(MultiTouchInputMapperTest, Process_TouchpadCapture) { // 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 @@ TEST_F(MultiTouchInputMapperTest, WhenCapturedAndNotCaptured_GetSources) { // 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 @@ TEST_F(MultiTouchPointerModeTest, WhenViewportActiveStatusChanged_PointerGesture 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 @@ protected: mFakePolicy.clear(); } - std::list 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 newDevice(int32_t deviceId, const std::string& name, const std::string& location, int32_t eventHubId, ftl::Flags classes) { diff --git a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp index 8ed1f31535..8098ef2edd 100644 --- a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp @@ -53,12 +53,14 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { [&]() -> void { std::list unused = mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, - fdp->ConsumeIntegral()); + InputReaderConfiguration::Change( + fdp->ConsumeIntegral())); }, [&]() -> void { // Need to reconfigure with 0 or you risk a NPE. std::list unused = - mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, 0); + mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, + InputReaderConfiguration::Change(0)); InputDeviceInfo info; mapper.populateDeviceInfo(info); }, @@ -71,7 +73,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { // Need to reconfigure with 0 or you risk a NPE. std::list unused = - mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, 0); + mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, + InputReaderConfiguration::Change(0)); RawEvent rawEvent{fdp->ConsumeIntegral(), fdp->ConsumeIntegral(), fdp->ConsumeIntegral(), @@ -90,7 +93,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { [&]() -> void { // Need to reconfigure with 0 or you risk a NPE. std::list unused = - mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, 0); + mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, + InputReaderConfiguration::Change(0)); mapper.getAssociatedDisplayId(); }, })(); diff --git a/services/inputflinger/tests/fuzzers/FuzzContainer.h b/services/inputflinger/tests/fuzzers/FuzzContainer.h index d42d11c240..84ac0fd262 100644 --- a/services/inputflinger/tests/fuzzers/FuzzContainer.h +++ b/services/inputflinger/tests/fuzzers/FuzzContainer.h @@ -59,7 +59,7 @@ public: void configureDevice() { nsecs_t arbitraryTime = mFdp->ConsumeIntegral(); std::list 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 baece3c110..9223287114 100644 --- a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp @@ -82,7 +82,7 @@ public: return reader->hasKeys(deviceId, sourceMask, keyCodes, outFlags); } - void requestRefreshConfiguration(uint32_t changes) { + void requestRefreshConfiguration(ConfigurationChanges changes) { reader->requestRefreshConfiguration(changes); } @@ -232,7 +232,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { fdp->ConsumeIntegral(), keyCodes, outFlags.data()); }, [&]() -> void { - reader->requestRefreshConfiguration(fdp->ConsumeIntegral()); + reader->requestRefreshConfiguration( + InputReaderConfiguration::Change(fdp->ConsumeIntegral())); }, [&]() -> void { reader->cancelVibrate(fdp->ConsumeIntegral(), diff --git a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp index 0a6327d07a..616e870811 100644 --- a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp @@ -65,7 +65,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { [&]() -> void { std::list unused = mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, - fdp->ConsumeIntegral()); + InputReaderConfiguration::Change( + fdp->ConsumeIntegral())); }, [&]() -> void { std::list unused = mapper.reset(fdp->ConsumeIntegral()); diff --git a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp index fdf9f41873..212462d700 100644 --- a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp @@ -80,7 +80,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { [&]() -> void { std::list unused = mapper.reconfigure(fdp->ConsumeIntegral(), policyConfig, - fdp->ConsumeIntegral()); + InputReaderConfiguration::Change( + fdp->ConsumeIntegral())); }, [&]() -> void { std::list unused = mapper.reset(fdp->ConsumeIntegral()); -- cgit v1.2.3-59-g8ed1b