diff options
| -rw-r--r-- | include/ftl/small_vector.h | 10 | ||||
| -rw-r--r-- | libs/binder/tests/Android.bp | 8 | ||||
| -rw-r--r-- | libs/binder/trusty/include/binder/RpcServerTrusty.h | 2 | ||||
| -rw-r--r-- | services/inputflinger/reader/mapper/TouchInputMapper.cpp | 4 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 115 |
5 files changed, 93 insertions, 46 deletions
diff --git a/include/ftl/small_vector.h b/include/ftl/small_vector.h index 43e9fac5e2..3d5d52e80c 100644 --- a/include/ftl/small_vector.h +++ b/include/ftl/small_vector.h @@ -234,7 +234,7 @@ class SmallVector final : details::ArrayTraits<T>, details::ArrayComparators<Sma } // Extracts the elements as std::vector. - std::vector<T> promote() && { + std::vector<std::remove_const_t<T>> promote() && { if (dynamic()) { return std::get<Dynamic>(std::move(vector_)).promote(); } else { @@ -290,11 +290,11 @@ template <typename T> class SmallVector<T, 0> final : details::ArrayTraits<T>, details::ArrayComparators<SmallVector>, details::ArrayIterators<SmallVector<T, 0>, T>, - std::vector<T> { + std::vector<std::remove_const_t<T>> { using details::ArrayTraits<T>::replace_at; using Iter = details::ArrayIterators<SmallVector, T>; - using Impl = std::vector<T>; + using Impl = std::vector<std::remove_const_t<T>>; friend Iter; @@ -394,12 +394,12 @@ class SmallVector<T, 0> final : details::ArrayTraits<T>, pop_back(); } - std::vector<T> promote() && { return std::move(*this); } + std::vector<std::remove_const_t<T>> promote() && { return std::move(*this); } private: template <typename U, std::size_t M> static Impl convert(SmallVector<U, M>&& other) { - if constexpr (std::is_constructible_v<Impl, std::vector<U>&&>) { + if constexpr (std::is_constructible_v<Impl, std::vector<std::remove_const_t<U>>&&>) { return std::move(other).promote(); } else { SmallVector vector(other.size()); diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp index 21c32acb0a..957871379b 100644 --- a/libs/binder/tests/Android.bp +++ b/libs/binder/tests/Android.bp @@ -46,7 +46,7 @@ cc_test { "libbinder", ], test_suites: [ - "device-tests", + "general-tests", "vts", ], } @@ -137,7 +137,7 @@ cc_test { "libgmock", ], test_suites: [ - "device-tests", + "general-tests", "vts", ], require_root: true, @@ -705,7 +705,7 @@ cc_test { "libutils", ], test_suites: [ - "device-tests", + "general-tests", "vts", ], require_root: true, @@ -762,7 +762,7 @@ cc_test { ], test_suites: [ - "device-tests", + "general-tests", "vts", ], require_root: true, diff --git a/libs/binder/trusty/include/binder/RpcServerTrusty.h b/libs/binder/trusty/include/binder/RpcServerTrusty.h index fe44ea5e28..583ad015e1 100644 --- a/libs/binder/trusty/include/binder/RpcServerTrusty.h +++ b/libs/binder/trusty/include/binder/RpcServerTrusty.h @@ -42,7 +42,7 @@ public: // equivalent. struct PortAcl { uint32_t flags; - std::vector<const uuid> uuids; + std::vector<uuid> uuids; const void* extraData; }; diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp index 3c26d1d73e..539731b060 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -984,8 +984,9 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) viewportChanged = mViewport != newViewport; } + const bool deviceModeChanged = mDeviceMode != oldDeviceMode; bool skipViewportUpdate = false; - if (viewportChanged) { + if (viewportChanged || deviceModeChanged) { const bool viewportOrientationChanged = mViewport.orientation != newViewport.orientation; const bool viewportDisplayIdChanged = mViewport.displayId != newViewport.displayId; mViewport = newViewport; @@ -1027,7 +1028,6 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) } // If moving between pointer modes, need to reset some state. - bool deviceModeChanged = mDeviceMode != oldDeviceMode; if (deviceModeChanged) { mOrientedRanges.clear(); } diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index 835f8b89c3..33ba79e717 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -57,6 +57,7 @@ namespace android { using namespace ftl::flag_operators; using testing::AllOf; +using testing::VariantWith; using std::chrono_literals::operator""ms; using std::chrono_literals::operator""s; @@ -4430,15 +4431,15 @@ protected: void prepareButtons(); void prepareAxes(int axes); - void processDown(SingleTouchInputMapper& mapper, int32_t x, int32_t y); - void processMove(SingleTouchInputMapper& mapper, int32_t x, int32_t y); - void processUp(SingleTouchInputMapper& mappery); - void processPressure(SingleTouchInputMapper& mapper, int32_t pressure); - void processToolMajor(SingleTouchInputMapper& mapper, int32_t toolMajor); - void processDistance(SingleTouchInputMapper& mapper, int32_t distance); - void processTilt(SingleTouchInputMapper& mapper, int32_t tiltX, int32_t tiltY); - void processKey(SingleTouchInputMapper& mapper, int32_t code, int32_t value); - void processSync(SingleTouchInputMapper& mapper); + std::list<NotifyArgs> processDown(SingleTouchInputMapper& mapper, int32_t x, int32_t y); + std::list<NotifyArgs> processMove(SingleTouchInputMapper& mapper, int32_t x, int32_t y); + std::list<NotifyArgs> processUp(SingleTouchInputMapper& mappery); + std::list<NotifyArgs> processPressure(SingleTouchInputMapper& mapper, int32_t pressure); + std::list<NotifyArgs> processToolMajor(SingleTouchInputMapper& mapper, int32_t toolMajor); + std::list<NotifyArgs> processDistance(SingleTouchInputMapper& mapper, int32_t distance); + std::list<NotifyArgs> processTilt(SingleTouchInputMapper& mapper, int32_t tiltX, int32_t tiltY); + std::list<NotifyArgs> processKey(SingleTouchInputMapper& mapper, int32_t code, int32_t value); + std::list<NotifyArgs> processSync(SingleTouchInputMapper& mapper); }; void SingleTouchInputMapperTest::prepareButtons() { @@ -4468,47 +4469,57 @@ void SingleTouchInputMapperTest::prepareAxes(int axes) { } } -void SingleTouchInputMapperTest::processDown(SingleTouchInputMapper& mapper, int32_t x, int32_t y) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, BTN_TOUCH, 1); - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_X, x); - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_Y, y); +std::list<NotifyArgs> SingleTouchInputMapperTest::processDown(SingleTouchInputMapper& mapper, + int32_t x, int32_t y) { + std::list<NotifyArgs> args; + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, BTN_TOUCH, 1); + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_X, x); + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_Y, y); + return args; } -void SingleTouchInputMapperTest::processMove(SingleTouchInputMapper& mapper, int32_t x, int32_t y) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_X, x); - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_Y, y); +std::list<NotifyArgs> SingleTouchInputMapperTest::processMove(SingleTouchInputMapper& mapper, + int32_t x, int32_t y) { + std::list<NotifyArgs> args; + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_X, x); + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_Y, y); + return args; } -void SingleTouchInputMapperTest::processUp(SingleTouchInputMapper& mapper) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, BTN_TOUCH, 0); +std::list<NotifyArgs> SingleTouchInputMapperTest::processUp(SingleTouchInputMapper& mapper) { + return process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, BTN_TOUCH, 0); } -void SingleTouchInputMapperTest::processPressure(SingleTouchInputMapper& mapper, int32_t pressure) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_PRESSURE, pressure); +std::list<NotifyArgs> SingleTouchInputMapperTest::processPressure(SingleTouchInputMapper& mapper, + int32_t pressure) { + return process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_PRESSURE, pressure); } -void SingleTouchInputMapperTest::processToolMajor(SingleTouchInputMapper& mapper, - int32_t toolMajor) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_TOOL_WIDTH, toolMajor); +std::list<NotifyArgs> SingleTouchInputMapperTest::processToolMajor(SingleTouchInputMapper& mapper, + int32_t toolMajor) { + return process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_TOOL_WIDTH, toolMajor); } -void SingleTouchInputMapperTest::processDistance(SingleTouchInputMapper& mapper, int32_t distance) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_DISTANCE, distance); +std::list<NotifyArgs> SingleTouchInputMapperTest::processDistance(SingleTouchInputMapper& mapper, + int32_t distance) { + return process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_DISTANCE, distance); } -void SingleTouchInputMapperTest::processTilt(SingleTouchInputMapper& mapper, int32_t tiltX, - int32_t tiltY) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_TILT_X, tiltX); - process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_TILT_Y, tiltY); +std::list<NotifyArgs> SingleTouchInputMapperTest::processTilt(SingleTouchInputMapper& mapper, + int32_t tiltX, int32_t tiltY) { + std::list<NotifyArgs> args; + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_TILT_X, tiltX); + args += process(mapper, ARBITRARY_TIME, READ_TIME, EV_ABS, ABS_TILT_Y, tiltY); + return args; } -void SingleTouchInputMapperTest::processKey(SingleTouchInputMapper& mapper, int32_t code, - int32_t value) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, code, value); +std::list<NotifyArgs> SingleTouchInputMapperTest::processKey(SingleTouchInputMapper& mapper, + int32_t code, int32_t value) { + return process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, code, value); } -void SingleTouchInputMapperTest::processSync(SingleTouchInputMapper& mapper) { - process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); +std::list<NotifyArgs> SingleTouchInputMapperTest::processSync(SingleTouchInputMapper& mapper) { + return process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); } TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndNotACursor_ReturnsPointer) { @@ -4599,6 +4610,42 @@ TEST_F(SingleTouchInputMapperTest, MarkSupportedKeyCodes) { ASSERT_FALSE(flags[1]); } +TEST_F(SingleTouchInputMapperTest, DeviceTypeChange_RecalculatesRawToDisplayTransform) { + prepareDisplay(ui::ROTATION_0); + prepareAxes(POSITION); + addConfigurationProperty("touch.deviceType", "touchScreen"); + SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>(); + + const int32_t x = 900; + const int32_t y = 75; + std::list<NotifyArgs> args; + args += processDown(mapper, x, y); + args += processSync(mapper); + + // Assert that motion event is received in display coordinate space for deviceType touchScreen. + ASSERT_THAT(args, + ElementsAre(VariantWith<NotifyMotionArgs>( + AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), + WithCoords(toDisplayX(x), toDisplayY(y)))))); + + // Add device type association after the device was created. + mFakePolicy->addDeviceTypeAssociation(DEVICE_LOCATION, "touchNavigation"); + // Send update to the mapper. + std::list<NotifyArgs> unused = + mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), + InputReaderConfiguration::Change::DEVICE_TYPE /*changes*/); + + args.clear(); + args += processDown(mapper, x, y); + args += processSync(mapper); + + // Assert that motion event is received in raw coordinate space for deviceType touchNavigation. + ASSERT_THAT(args, + ElementsAre(VariantWith<NotifyMotionArgs>( + AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), + WithCoords(x - RAW_X_MIN, y - RAW_Y_MIN))))); +} + TEST_F(SingleTouchInputMapperTest, Process_WhenVirtualKeyIsPressedAndReleasedNormally_SendsKeyDownAndKeyUp) { addConfigurationProperty("touch.deviceType", "touchScreen"); prepareDisplay(ui::ROTATION_0); |