summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2024-02-14 06:03:02 +0000
committer Prabir Pradhan <prabirmsp@google.com> 2024-02-15 19:11:28 +0000
commit55c5ee21ac21cbbc3b4f8b2faf9ffae126ada33c (patch)
tree5158df3079937d09a8d296bdf311f175ffe64db7
parenta51f1d637bf1315737467500dfcfe54319eafe4f (diff)
InputReader: Bump generation when associated display changes
When the display association changes, we need to bump the device generation because the associated display is part of the java InputDevice, so we need to notify listeners about changes in the associated display. Bug: 324299318 Test: atest VirtualDpadTest --iterations Change-Id: Id5da99804b3e170d03fb1ca4c126b782a7587c7c
-rw-r--r--services/inputflinger/reader/InputDevice.cpp6
-rw-r--r--services/inputflinger/tests/InputReader_test.cpp3
2 files changed, 9 insertions, 0 deletions
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index f3f15df151..2baf576903 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -265,6 +265,8 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when,
}
if (!changes.any() || changes.test(Change::DISPLAY_INFO)) {
+ const auto oldAssociatedDisplayId = getAssociatedDisplayId();
+
// In most situations, no port or name will be specified.
mAssociatedDisplayPort = std::nullopt;
mAssociatedDisplayUniqueId = std::nullopt;
@@ -306,6 +308,10 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when,
getName().c_str(), mAssociatedDisplayUniqueId->c_str());
}
}
+
+ if (getAssociatedDisplayId() != oldAssociatedDisplayId) {
+ bumpGeneration();
+ }
}
for_each_mapper([this, when, &readerConfig, changes, &out](InputMapper& mapper) {
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index c1dc7ffcfb..476f755bae 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -2893,9 +2893,12 @@ TEST_F(InputDeviceTest, Configure_UniqueId_CorrectlyMatches) {
mFakePolicy->addDisplayViewport(SECONDARY_DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT,
ui::ROTATION_0, /* isActive= */ true, DISPLAY_UNIQUE_ID,
NO_PORT, ViewportType::INTERNAL);
+ const auto initialGeneration = mDevice->getGeneration();
unused += mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
InputReaderConfiguration::Change::DISPLAY_INFO);
ASSERT_EQ(DISPLAY_UNIQUE_ID, mDevice->getAssociatedDisplayUniqueId());
+ ASSERT_GT(mDevice->getGeneration(), initialGeneration);
+ ASSERT_EQ(mDevice->getDeviceInfo().getAssociatedDisplayId(), SECONDARY_DISPLAY_ID);
}
/**