InputMapper refactor: TouchInputMapper
Add a factory method for TouchInputMapper(s) to be configured on
initilisation
Test: m checkinput && atest libinput_tests inputflinger_tests
Bug: 256009910
Change-Id: I738e2947ff98016e00c290365292ab01b04e7d26
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 568d4e8..5645f4c 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -5082,7 +5082,7 @@
TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndNotACursor_ReturnsPointer) {
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources());
}
@@ -5091,7 +5091,7 @@
prepareButtons();
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, mapper.getSources());
}
@@ -5102,7 +5102,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Unknown key.
ASSERT_EQ(AKEY_STATE_UNKNOWN, mapper.getKeyCodeState(AINPUT_SOURCE_ANY, AKEYCODE_A));
@@ -5130,7 +5130,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Unknown key.
ASSERT_EQ(AKEY_STATE_UNKNOWN, mapper.getScanCodeState(AINPUT_SOURCE_ANY, KEY_A));
@@ -5158,7 +5158,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
uint8_t flags[2] = { 0, 0 };
ASSERT_TRUE(
@@ -5173,7 +5173,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -5223,7 +5223,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -5344,7 +5344,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -5419,7 +5419,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -5515,7 +5515,7 @@
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -5605,7 +5605,7 @@
prepareAxes(POSITION);
// InputReader works in the un-rotated coordinate space, so orientation-aware devices do not
// need to be rotated. Touchscreens are orientation-aware by default.
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
@@ -5630,7 +5630,7 @@
// Since InputReader works in the un-rotated coordinate space, only devices that are not
// orientation-aware are affected by display rotation.
addConfigurationProperty("touch.orientationAware", "0");
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
@@ -5699,7 +5699,7 @@
addConfigurationProperty("touch.orientation", "ORIENTATION_0");
clearViewports();
prepareDisplay(ui::ROTATION_0);
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
// Orientation 0.
@@ -5723,7 +5723,7 @@
addConfigurationProperty("touch.orientation", "ORIENTATION_90");
clearViewports();
prepareDisplay(ui::ROTATION_0);
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
// Orientation 90.
@@ -5747,7 +5747,7 @@
addConfigurationProperty("touch.orientation", "ORIENTATION_180");
clearViewports();
prepareDisplay(ui::ROTATION_0);
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
// Orientation 180.
@@ -5771,7 +5771,7 @@
addConfigurationProperty("touch.orientation", "ORIENTATION_270");
clearViewports();
prepareDisplay(ui::ROTATION_0);
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
// Orientation 270.
@@ -5795,7 +5795,7 @@
// orientation-aware are affected by display rotation.
addConfigurationProperty("touch.orientationAware", "0");
addConfigurationProperty("touch.orientation", "ORIENTATION_90");
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs args;
@@ -5862,7 +5862,7 @@
prepareAxes(POSITION);
addConfigurationProperty("touch.orientationAware", "1");
prepareDisplay(ui::ROTATION_0);
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Set a physical frame in the display viewport.
auto viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL);
@@ -5916,7 +5916,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION | PRESSURE | TOOL | DISTANCE | TILT);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// These calculations are based on the input device calibration documentation.
int32_t rawX = 100;
@@ -5961,7 +5961,7 @@
prepareLocationCalibration();
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
int32_t rawX = 100;
int32_t rawY = 200;
@@ -5983,7 +5983,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
NotifyKeyArgs keyArgs;
@@ -6226,7 +6226,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -6362,7 +6362,7 @@
prepareButtons();
prepareAxes(POSITION);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_FINGER, 0, AKEYCODE_UNKNOWN, 0);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -6433,7 +6433,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION | PRESSURE);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -6504,7 +6504,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION | PRESSURE);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Touch down.
processDown(mapper, 100, 200);
@@ -6526,7 +6526,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION | PRESSURE);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Set the initial state for the touch pointer.
mFakeEventHub->setAbsoluteAxisValue(EVENTHUB_ID, ABS_X, 100);
@@ -6554,7 +6554,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
// Down.
@@ -6582,7 +6582,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
NotifyMotionArgs motionArgs;
@@ -6642,7 +6642,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
// Press a stylus button.
@@ -6683,7 +6683,7 @@
mFakePolicy->setStylusButtonMotionEventsEnabled(false);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
// Press a stylus button.
@@ -6720,7 +6720,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
ASSERT_EQ(AINPUT_SOURCE_TOUCH_NAVIGATION, mapper.getSources());
@@ -6736,7 +6736,7 @@
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
mFakePolicy->setPointerController(fakePointerController);
mFakePolicy->setStylusPointerIconEnabled(true);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
processKey(mapper, BTN_TOOL_PEN, 1);
processMove(mapper, 100, 200);
@@ -6760,7 +6760,7 @@
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
mFakePolicy->setPointerController(fakePointerController);
mFakePolicy->setStylusPointerIconEnabled(false);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
processKey(mapper, BTN_TOOL_PEN, 1);
processMove(mapper, 100, 200);
@@ -6778,7 +6778,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Ensure that the device is created as a touchscreen, not touch navigation.
ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, mapper.getSources());
@@ -6812,7 +6812,7 @@
mFakePolicy->updateViewport(*viewport);
configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Hovering inside the physical frame produces events.
processKey(mapper, BTN_TOOL_PEN, 1);
@@ -6918,7 +6918,7 @@
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -6953,7 +6953,7 @@
prepareButtons();
prepareAxes(POSITION);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -7082,7 +7082,7 @@
addConfigurationProperty("touch.orientation", ftl::enum_string(touchscreenOrientation).c_str());
prepareDisplay(ui::ROTATION_0);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// If the touchscreen is installed in a rotated orientation relative to the display (i.e. in
// orientations of either 90 or 270) this means the display's natural resolution will be
@@ -7134,7 +7134,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(displayRotation);
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
const auto& expectedPoints = kMappedCorners.at(displayRotation);
@@ -7172,7 +7172,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
addConfigurationProperty("touch.orientation", "ORIENTATION_270");
- SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
// Ori 270, so width and height swapped
const Rect physicalFrame{0, 0, DISPLAY_HEIGHT, DISPLAY_WIDTH};
@@ -7208,7 +7208,7 @@
prepareDisplay(displayRotation);
__attribute__((unused)) SingleTouchInputMapper& mapper =
- addMapperAndConfigure<SingleTouchInputMapper>();
+ constructAndAddMapper<SingleTouchInputMapper>();
const InputDeviceInfo deviceInfo = mDevice->getDeviceInfo();
// MotionRanges use display pixels as their units
@@ -7253,7 +7253,7 @@
prepareDisplay(ui::ROTATION_0);
prepareButtons();
prepareAxes(POSITION);
- auto& mapper = addMapperAndConfigure<SingleTouchInputMapper>();
+ auto& mapper = constructAndAddMapper<SingleTouchInputMapper>();
mStylusState.when = ARBITRARY_TIME;
mStylusState.pressure = 0.f;
@@ -7742,7 +7742,7 @@
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION);
prepareVirtualKeys();
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -8026,7 +8026,7 @@
mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_WIDTH_MINOR, RAW_TOOL_MIN, RAW_TOOL_MAX,
/*flat*/ 0, /*flat*/ 0, /*resolution*/ 15);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// X and Y axes
assertAxisResolution(mapper, AMOTION_EVENT_AXIS_X, 10 / X_PRECISION);
@@ -8050,7 +8050,7 @@
// We do not add ABS_MT_TOUCH_MAJOR / MINOR or ABS_MT_WIDTH_MAJOR / MINOR axes
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Touch major and minor
assertAxisNotPresent(mapper, AMOTION_EVENT_AXIS_TOUCH_MAJOR);
@@ -8065,7 +8065,7 @@
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID);
prepareVirtualKeys();
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -8236,7 +8236,7 @@
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT);
prepareVirtualKeys();
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
mReader->getContext()->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
@@ -8401,7 +8401,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | TOUCH | TOOL | PRESSURE | ORIENTATION | ID | MINOR | DISTANCE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// These calculations are based on the input device calibration documentation.
int32_t rawX = 100;
@@ -8451,7 +8451,7 @@
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | TOUCH | TOOL | MINOR);
addConfigurationProperty("touch.size.calibration", "geometric");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// These calculations are based on the input device calibration documentation.
int32_t rawX = 100;
@@ -8491,7 +8491,7 @@
addConfigurationProperty("touch.size.scale", "10");
addConfigurationProperty("touch.size.bias", "160");
addConfigurationProperty("touch.size.isSummed", "1");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// These calculations are based on the input device calibration documentation.
// Note: We only provide a single common touch/tool value because the device is assumed
@@ -8541,7 +8541,7 @@
addConfigurationProperty("touch.size.calibration", "area");
addConfigurationProperty("touch.size.scale", "43");
addConfigurationProperty("touch.size.bias", "3");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// These calculations are based on the input device calibration documentation.
int32_t rawX = 100;
@@ -8573,7 +8573,7 @@
prepareAxes(POSITION | PRESSURE);
addConfigurationProperty("touch.pressure.calibration", "amplitude");
addConfigurationProperty("touch.pressure.scale", "0.01");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
InputDeviceInfo info;
mapper.populateDeviceInfo(info);
@@ -8605,7 +8605,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
NotifyKeyArgs keyArgs;
@@ -8848,7 +8848,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
mFakeEventHub->addKey(EVENTHUB_ID, BTN_A, 0, AKEYCODE_STYLUS_BUTTON_PRIMARY, 0);
mFakeEventHub->addKey(EVENTHUB_ID, 0, 0xabcd, AKEYCODE_STYLUS_BUTTON_SECONDARY, 0);
@@ -8905,7 +8905,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9056,7 +9056,7 @@
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9126,7 +9126,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | PRESSURE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9207,7 +9207,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
mFakePolicy->addInputPortAssociation(DEVICE_LOCATION, hdmi1);
mFakePolicy->addInputPortAssociation(usb2, hdmi2);
@@ -9237,7 +9237,7 @@
TEST_F(MultiTouchInputMapperTest, Configure_AssignsDisplayUniqueId) {
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
mFakePolicy->addInputUniqueIdAssociation(DEVICE_LOCATION, VIRTUAL_DISPLAY_UNIQUE_ID);
@@ -9266,7 +9266,7 @@
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Check source is mouse that would obtain the PointerController.
ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources());
@@ -9286,7 +9286,7 @@
TEST_F(MultiTouchInputMapperTest, Process_SendsReadTime) {
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
prepareDisplay(ui::ROTATION_0);
process(mapper, 10, /*readTime=*/11, EV_ABS, ABS_MT_TRACKING_ID, 1);
@@ -9317,7 +9317,7 @@
/*isActive=*/false, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL);
configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
processPosition(mapper, 100, 100);
@@ -9337,7 +9337,7 @@
/*isActive=*/false, UNIQUE_ID, NO_PORT, ViewportType::INTERNAL);
configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
processPosition(mapper, 100, 100);
@@ -9359,7 +9359,7 @@
configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Finger down
int32_t x = 100, y = 100;
@@ -9402,7 +9402,7 @@
// Setup the first touch screen device.
prepareAxes(POSITION | ID | SLOT);
addConfigurationProperty("touch.deviceType", "touchScreen");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Create the second touch screen device, and enable multi fingers.
const std::string USB2 = "USB2";
@@ -9426,9 +9426,9 @@
String8("touchScreen"));
// Setup the second touch screen device.
- MultiTouchInputMapper& mapper2 =
- device2->addMapper<MultiTouchInputMapper>(SECOND_EVENTHUB_ID,
- mFakePolicy->getReaderConfiguration());
+ device2->addEmptyEventHubDevice(SECOND_EVENTHUB_ID);
+ MultiTouchInputMapper& mapper2 = device2->constructAndAddMapper<
+ MultiTouchInputMapper>(SECOND_EVENTHUB_ID, mFakePolicy->getReaderConfiguration());
std::list<NotifyArgs> unused =
device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
/*changes=*/{});
@@ -9493,7 +9493,7 @@
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
// Unrotated video frame
@@ -9517,7 +9517,7 @@
TEST_F(MultiTouchInputMapperTest, VideoFrames_AreNotRotated) {
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Unrotated video frame
TouchVideoFrame frame(3, 2, {1, 2, 3, 4, 5, 6}, {1, 2});
NotifyMotionArgs motionArgs;
@@ -9542,7 +9542,7 @@
// Since InputReader works in the un-rotated coordinate space, only devices that are not
// orientation-aware are affected by display rotation.
addConfigurationProperty("touch.orientationAware", "0");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Unrotated video frame
TouchVideoFrame frame(3, 2, {1, 2, 3, 4, 5, 6}, {1, 2});
NotifyMotionArgs motionArgs;
@@ -9573,7 +9573,7 @@
TEST_F(MultiTouchInputMapperTest, VideoFrames_MultipleFramesAreNotRotated) {
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Unrotated video frames. There's no rule that they must all have the same dimensions,
// so mix these.
TouchVideoFrame frame1(3, 2, {1, 2, 3, 4, 5, 6}, {1, 2});
@@ -9596,7 +9596,7 @@
// Since InputReader works in the un-rotated coordinate space, only devices that are not
// orientation-aware are affected by display rotation.
addConfigurationProperty("touch.orientationAware", "0");
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// Unrotated video frames. There's no rule that they must all have the same dimensions,
// so mix these.
TouchVideoFrame frame1(3, 2, {1, 2, 3, 4, 5, 6}, {1, 2});
@@ -9633,7 +9633,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareAxes(POSITION);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
ASSERT_EQ(mDevice->isEnabled(), false);
@@ -9654,7 +9654,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9699,7 +9699,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9747,7 +9747,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9822,7 +9822,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9920,7 +9920,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -9992,7 +9992,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | PRESSURE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -10049,7 +10049,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | PRESSURE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// First finger down.
processId(mapper, FIRST_TRACKING_ID);
@@ -10090,7 +10090,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | PRESSURE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// First finger touches down and releases.
processId(mapper, FIRST_TRACKING_ID);
@@ -10118,7 +10118,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | PRESSURE | TOOL_TYPE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
// Even if the device supports reporting the ABS_MT_TOOL_TYPE axis, which could give it the
@@ -10173,7 +10173,7 @@
std::make_shared<FakePointerController>();
mFakePolicy->setPointerController(fakePointerController);
mFakePolicy->setStylusPointerIconEnabled(true);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
processId(mapper, FIRST_TRACKING_ID);
processPressure(mapper, RAW_PRESSURE_MIN);
@@ -10200,7 +10200,7 @@
std::make_shared<FakePointerController>();
mFakePolicy->setPointerController(fakePointerController);
mFakePolicy->setStylusPointerIconEnabled(false);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
processId(mapper, FIRST_TRACKING_ID);
processPressure(mapper, RAW_PRESSURE_MIN);
@@ -10228,7 +10228,7 @@
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, mapper.getSources());
@@ -10263,7 +10263,7 @@
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0);
mFakePolicy->setPointerCapture(true);
mFakePolicy->setPointerController(fakePointerController);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// captured touchpad should be a touchpad source
NotifyDeviceResetArgs resetArgs;
@@ -10411,7 +10411,7 @@
mFakeEventHub->addKey(EVENTHUB_ID, BTN_LEFT, 0, AKEYCODE_UNKNOWN, 0);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0);
mFakePolicy->setPointerController(fakePointerController);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// run uncaptured pointer tests - pushes out generic events
// FINGER 0 DOWN
processId(mapper, 3);
@@ -10472,7 +10472,7 @@
mFakeEventHub->addKey(EVENTHUB_ID, BTN_LEFT, 0, AKEYCODE_UNKNOWN, 0);
mFakePolicy->setPointerController(fakePointerController);
mFakePolicy->setPointerCapture(false);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// uncaptured touchpad should be a pointer device
ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources());
@@ -10496,7 +10496,7 @@
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT | PRESSURE);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
nsecs_t kernelEventTime = ARBITRARY_TIME;
nsecs_t expectedEventTime = ARBITRARY_TIME;
@@ -10583,7 +10583,7 @@
// which is greater than fraction of the diagnal length of the touchpad (349).
// Thus, MaxSwipWidth is 750.
preparePointerMode(/*xResolution=*/25, /*yResolution=*/25);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
// Two fingers down at once.
@@ -10643,7 +10643,7 @@
// which is greater than fraction of the diagnal length of the touchpad (349).
// Thus, MaxSwipWidth is the fraction of the diagnal length, 349.
preparePointerMode(/*xResolution=*/5, /*yResolution=*/5);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
// Two fingers down at once.
@@ -10699,7 +10699,7 @@
*/
TEST_F(MultiTouchPointerModeTest, PointerGestureMaxSwipeWidthFreeform) {
preparePointerMode(/*xResolution=*/25, /*yResolution=*/25);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
@@ -10794,7 +10794,7 @@
TEST_F(MultiTouchPointerModeTest, TwoFingerSwipeOffsets) {
preparePointerMode(/*xResolution=*/25, /*yResolution=*/25);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
NotifyMotionArgs motionArgs;
// Place two fingers down.
@@ -10841,7 +10841,7 @@
TEST_F(MultiTouchPointerModeTest, WhenViewportActiveStatusChanged_PointerGestureIsReset) {
preparePointerMode(/*xResolution=*/25, /*yResolution=*/25);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
- MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
+ MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
// Start a stylus gesture.