Shift notifyConfigurationChanged policy call to InputReader
WM expects input devices to be updated on receiving notify
configuration changed callback, but currently the policy callback
for input devices changed is sent after configuration changed,
causing stale device info provided to WM.
Bug: 350416243
Test: atest inputflinger_tests
Flag: NONE bugfix
Change-Id: If6c9d50459c4b1d72d0a2774b4fc833d6522a095
diff --git a/services/inputflinger/tests/FakeInputReaderPolicy.cpp b/services/inputflinger/tests/FakeInputReaderPolicy.cpp
index 6099c91..56a8918 100644
--- a/services/inputflinger/tests/FakeInputReaderPolicy.cpp
+++ b/services/inputflinger/tests/FakeInputReaderPolicy.cpp
@@ -65,6 +65,23 @@
ASSERT_FALSE(mDeviceIdOfNotifiedStylusGesture);
}
+void FakeInputReaderPolicy::assertConfigurationChanged() {
+ std::unique_lock lock(mLock);
+ base::ScopedLockAssertion assumeLocked(mLock);
+
+ const bool configurationChanged =
+ mConfigurationChangedCondition.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) {
+ return mConfigurationChanged;
+ });
+ ASSERT_TRUE(configurationChanged) << "Timed out waiting for configuration change";
+ mConfigurationChanged = false;
+}
+
+void FakeInputReaderPolicy::assertConfigurationNotChanged() {
+ std::scoped_lock lock(mLock);
+ ASSERT_FALSE(mConfigurationChanged);
+}
+
void FakeInputReaderPolicy::clearViewports() {
mViewports.clear();
mConfig.setDisplayViewports(mViewports);
@@ -234,6 +251,12 @@
mDevicesChangedCondition.notify_all();
}
+void FakeInputReaderPolicy::notifyConfigurationChanged(nsecs_t when) {
+ std::scoped_lock lock(mLock);
+ mConfigurationChanged = true;
+ mConfigurationChangedCondition.notify_all();
+}
+
std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay(
const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) {
return nullptr;