Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 737426bf authored by Ambrus Weisz's avatar Ambrus Weisz Committed by Android (Google) Code Review
Browse files

Merge "Reconfigure device in TouchInputMapper when the type is changed."

parents c125ca39 1588a2e5
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -277,7 +277,11 @@ std::list<NotifyArgs> InputDevice::configure(nsecs_t when, const InputReaderConf
    mHasMic = mClasses.test(InputDeviceClass::MIC);

    if (!isIgnored()) {
        if (!changes) { // first time only
        // 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)) {
            mConfiguration.clear();
            for_each_subdevice([this](InputDeviceContext& context) {
                PropertyMap configuration;
+6 −2
Original line number Diff line number Diff line
@@ -293,7 +293,10 @@ std::list<NotifyArgs> TouchInputMapper::configure(nsecs_t when,

    mConfig = *config;

    if (!changes) { // first time only
    // 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)) {
        // Configure basic parameters.
        configureParameters();

@@ -328,7 +331,8 @@ std::list<NotifyArgs> TouchInputMapper::configure(nsecs_t when,
          InputReaderConfiguration::CHANGE_POINTER_CAPTURE |
          InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT |
          InputReaderConfiguration::CHANGE_SHOW_TOUCHES |
          InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE))) {
          InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE |
          InputReaderConfiguration::CHANGE_DEVICE_TYPE))) {
        // Configure device sources, display dimensions, orientation and
        // scaling factors.
        configureInputDevice(when, &resetNeeded);
+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ std::list<NotifyArgs> InputMapperTest::configureDevice(uint32_t changes) {
    if (!changes ||
        (changes &
         (InputReaderConfiguration::CHANGE_DISPLAY_INFO |
          InputReaderConfiguration::CHANGE_POINTER_CAPTURE))) {
          InputReaderConfiguration::CHANGE_POINTER_CAPTURE |
          InputReaderConfiguration::CHANGE_DEVICE_TYPE))) {
        mReader->requestRefreshConfiguration(changes);
        mReader->loopOnce();
    }
+23 −0
Original line number Diff line number Diff line
@@ -6724,6 +6724,29 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenConfigDisabled_ShouldNotShowDirec
    ASSERT_FALSE(fakePointerController->isPointerShown());
}

TEST_F(SingleTouchInputMapperTest, WhenDeviceTypeIsChangedToTouchNavigation_updatesDeviceType) {
    // Initialize the device without setting device source to touch navigation.
    addConfigurationProperty("touch.deviceType", "touchScreen");
    prepareDisplay(ui::ROTATION_0);
    prepareButtons();
    prepareAxes(POSITION);
    SingleTouchInputMapper& mapper = addMapperAndConfigure<SingleTouchInputMapper>();

    // Ensure that the device is created as a touchscreen, not touch navigation.
    ASSERT_EQ(AINPUT_SOURCE_TOUCHSCREEN, mapper.getSources());

    // Add device type association after the device was created.
    mFakePolicy->addDeviceTypeAssociation(DEVICE_LOCATION, "touchNavigation");

    // Send update to the mapper.
    std::list<NotifyArgs> unused2 =
            mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
                               InputReaderConfiguration::CHANGE_DEVICE_TYPE /*changes*/);

    // Check whether device type update was successful.
    ASSERT_EQ(AINPUT_SOURCE_TOUCH_NAVIGATION, mDevice->getSources());
}

// --- TouchDisplayProjectionTest ---

class TouchDisplayProjectionTest : public SingleTouchInputMapperTest {