Revert "Remove notifyConfigurationChanged listener and policy calls"
Revert submission 28338641-remove_notify_configuration_changed
Reason for revert: Droidmonitor created revert due to http://b/353980868 - verifying through ABTD before submission.
Reverted changes: /q/submissionid:28338641-remove_notify_configuration_changed
Change-Id: I06b37a72b5cb67e377a2deb79c14d266afdcf81f
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 9bbc44a..1ba79a9 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -624,6 +624,7 @@
if (configuration) {
mFakeEventHub->addConfigurationMap(eventHubId, configuration);
}
+ mFakeEventHub->finishDeviceScan();
mReader->loopOnce();
mReader->loopOnce();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
@@ -757,6 +758,8 @@
mReader->pushNextDevice(device);
ASSERT_NO_FATAL_FAILURE(addDevice(eventHubId, "fake", deviceClass, nullptr));
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyConfigurationChangedWasCalled(nullptr));
+
NotifyDeviceResetArgs resetArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
ASSERT_EQ(deviceId, resetArgs.deviceId);
@@ -772,6 +775,7 @@
disableDevice(deviceId);
mReader->loopOnce();
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasNotCalled());
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyConfigurationChangedWasNotCalled());
ASSERT_EQ(device->isEnabled(), false);
enableDevice(deviceId);
@@ -956,6 +960,17 @@
ASSERT_TRUE(flags[0] && flags[1] && !flags[2] && !flags[3]);
}
+TEST_F(InputReaderTest, LoopOnce_WhenDeviceScanFinished_SendsConfigurationChanged) {
+ constexpr int32_t eventHubId = 1;
+ addDevice(eventHubId, "ignored", InputDeviceClass::KEYBOARD, nullptr);
+
+ NotifyConfigurationChangedArgs args;
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyConfigurationChangedWasCalled(&args));
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
+ ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
+}
+
TEST_F(InputReaderTest, LoopOnce_ForwardsRawEventsToMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
@@ -1060,6 +1075,7 @@
// The device is added after the input port associations are processed since
// we do not yet support dynamic device-to-display associations.
ASSERT_NO_FATAL_FAILURE(addDevice(eventHubId, "fake", deviceClass, nullptr));
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyConfigurationChangedWasCalled());
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled());
ASSERT_NO_FATAL_FAILURE(mapper.assertConfigureWasCalled());
@@ -1089,6 +1105,8 @@
ASSERT_NO_FATAL_FAILURE(addDevice(eventHubIds[0], "fake1", deviceClass, nullptr));
ASSERT_NO_FATAL_FAILURE(addDevice(eventHubIds[1], "fake2", deviceClass, nullptr));
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyConfigurationChangedWasCalled(nullptr));
+
NotifyDeviceResetArgs resetArgs;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
ASSERT_EQ(deviceId, resetArgs.deviceId);
@@ -1461,7 +1479,9 @@
// to the test device will show up in mReader. We wait for those input devices to
// show up before beginning the tests.
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyInputDevicesChangedWasCalled());
+ ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyConfigurationChangedWasCalled());
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
}
};
@@ -1481,10 +1501,12 @@
// consider it as a valid device.
std::unique_ptr<UinputDevice> invalidDevice = createUinputDevice<InvalidUinputDevice>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesNotChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationNotChanged());
ASSERT_EQ(numDevices, mFakePolicy->getInputDevices().size());
invalidDevice.reset();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesNotChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationNotChanged());
ASSERT_EQ(numDevices, mFakePolicy->getInputDevices().size());
}
@@ -1493,6 +1515,7 @@
std::unique_ptr<UinputHomeKey> keyboard = createUinputDevice<UinputHomeKey>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
ASSERT_EQ(initialNumDevices + 1, mFakePolicy->getInputDevices().size());
const auto device = waitForDevice(keyboard->getName());
@@ -1503,6 +1526,7 @@
keyboard.reset();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
ASSERT_EQ(initialNumDevices, mFakePolicy->getInputDevices().size());
}
@@ -1510,14 +1534,21 @@
std::unique_ptr<UinputHomeKey> keyboard = createUinputDevice<UinputHomeKey>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ NotifyConfigurationChangedArgs configChangedArgs;
+ ASSERT_NO_FATAL_FAILURE(
+ mTestListener->assertNotifyConfigurationChangedWasCalled(&configChangedArgs));
+ int32_t prevId = configChangedArgs.id;
+ nsecs_t prevTimestamp = configChangedArgs.eventTime;
+
NotifyKeyArgs keyArgs;
keyboard->pressAndReleaseHomeKey();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyKeyWasCalled(&keyArgs));
ASSERT_EQ(AKEY_EVENT_ACTION_DOWN, keyArgs.action);
+ ASSERT_NE(prevId, keyArgs.id);
+ prevId = keyArgs.id;
+ ASSERT_LE(prevTimestamp, keyArgs.eventTime);
ASSERT_LE(keyArgs.eventTime, keyArgs.readTime);
-
- int32_t prevId = keyArgs.id;
- nsecs_t prevTimestamp = keyArgs.eventTime;
+ prevTimestamp = keyArgs.eventTime;
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyKeyWasCalled(&keyArgs));
ASSERT_EQ(AKEY_EVENT_ACTION_UP, keyArgs.action);
@@ -1640,6 +1671,8 @@
mDevice = createUinputDevice<UinputTouchScreen>(Rect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT));
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
+ ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyConfigurationChangedWasCalled());
const auto info = waitForDevice(mDevice->getName());
ASSERT_TRUE(info);
mDeviceInfo = *info;
@@ -1708,6 +1741,8 @@
UNIQUE_ID, isInputPortAssociation ? DISPLAY_PORT : NO_PORT,
ViewportType::INTERNAL);
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
+ ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyConfigurationChangedWasCalled());
const auto info = waitForDevice(mDevice->getName());
ASSERT_TRUE(info);
mDeviceInfo = *info;
@@ -2040,6 +2075,7 @@
// Connecting an external stylus mid-gesture should not interrupt the ongoing gesture stream.
auto externalStylus = createUinputDevice<UinputExternalStylus>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
const auto stylusInfo = waitForDevice(externalStylus->getName());
ASSERT_TRUE(stylusInfo);
@@ -2052,6 +2088,7 @@
// Disconnecting an external stylus mid-gesture should not interrupt the ongoing gesture stream.
externalStylus.reset();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasNotCalled());
// Up
@@ -2109,6 +2146,8 @@
mStylusDeviceLifecycleTracker = createUinputDevice<T>();
mStylus = mStylusDeviceLifecycleTracker.get();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
+ ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyConfigurationChangedWasCalled());
const auto info = waitForDevice(mStylus->getName());
ASSERT_TRUE(info);
mStylusInfo = *info;
@@ -2378,6 +2417,7 @@
std::unique_ptr<UinputExternalStylusWithPressure> stylus =
createUinputDevice<UinputExternalStylusWithPressure>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
const auto stylusInfo = waitForDevice(stylus->getName());
ASSERT_TRUE(stylusInfo);
@@ -2395,6 +2435,7 @@
std::unique_ptr<UinputExternalStylusWithPressure> stylus =
createUinputDevice<UinputExternalStylusWithPressure>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
const auto stylusInfo = waitForDevice(stylus->getName());
ASSERT_TRUE(stylusInfo);
@@ -2440,6 +2481,7 @@
std::unique_ptr<UinputExternalStylusWithPressure> stylus =
createUinputDevice<UinputExternalStylusWithPressure>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
const auto stylusInfo = waitForDevice(stylus->getName());
ASSERT_TRUE(stylusInfo);
@@ -2519,6 +2561,7 @@
// touch pointers.
std::unique_ptr<UinputExternalStylus> stylus = createUinputDevice<UinputExternalStylus>();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertConfigurationChanged());
const auto stylusInfo = waitForDevice(stylus->getName());
ASSERT_TRUE(stylusInfo);