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

Commit da73e660 authored by Ambrus Weisz's avatar Ambrus Weisz Committed by Automerger Merge Worker
Browse files

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

Merge "Reconfigure device in TouchInputMapper when the type is changed." into udc-dev am: ff8db1b9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/21606183



Change-Id: I0b4685b49de5a87fab4a98229a1821b831ec3578
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6c2468ca ff8db1b9
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -277,7 +277,11 @@ std::list<NotifyArgs> InputDevice::configure(nsecs_t when, const InputReaderConf
    mHasMic = mClasses.test(InputDeviceClass::MIC);
    mHasMic = mClasses.test(InputDeviceClass::MIC);


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


    mConfig = *config;
    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.
        // Configure basic parameters.
        configureParameters();
        configureParameters();


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


class TouchDisplayProjectionTest : public SingleTouchInputMapperTest {
class TouchDisplayProjectionTest : public SingleTouchInputMapperTest {