Revert "InputMapper refactor: Configure empty InputDevice"
Revert submission 23779328
Reason for revert: Found touch issues on devices in latest qpr-build
Reverted changes: /q/submissionid:23779328
Change-Id: If3cfc122d571198c8c93c0c5438f70037f8e677e
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index aee1415..2bf6342 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -171,23 +171,18 @@
mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});
}
-[[nodiscard]] std::list<NotifyArgs> InputDevice::addEventHubDevice(
- nsecs_t when, int32_t eventHubId, const InputReaderConfiguration& readerConfig) {
+void InputDevice::addEventHubDevice(int32_t eventHubId,
+ const InputReaderConfiguration& readerConfig) {
if (mDevices.find(eventHubId) != mDevices.end()) {
- return {};
+ return;
}
+ std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId));
+ std::vector<std::unique_ptr<InputMapper>> mappers = createMappers(*contextPtr, readerConfig);
- // Add an empty device configure and keep it enabled to allow mapper population
- // with correct configuration/context
- addEmptyEventHubDevice(eventHubId);
- std::list<NotifyArgs> out = configure(when, readerConfig, {}, /*forceEnable=*/true);
-
- DevicePair& devicePair = mDevices[eventHubId];
- devicePair.second = createMappers(*devicePair.first, readerConfig);
-
+ // insert the context into the devices set
+ mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});
// Must change generation to flag this device as changed
bumpGeneration();
- return out;
}
void InputDevice::removeEventHubDevice(int32_t eventHubId) {
@@ -200,7 +195,7 @@
std::list<NotifyArgs> InputDevice::configure(nsecs_t when,
const InputReaderConfiguration& readerConfig,
- ConfigurationChanges changes, bool forceEnable) {
+ ConfigurationChanges changes) {
std::list<NotifyArgs> out;
mSources = 0;
mClasses = ftl::Flags<InputDeviceClass>(0);
@@ -313,17 +308,25 @@
}
}
- if (!changes.any() || changes.test(Change::ENABLED_STATE) ||
- changes.test(Change::DISPLAY_INFO)) {
+ if (changes.test(Change::ENABLED_STATE) || changes.test(Change::DISPLAY_INFO)) {
// Whether a device is enabled can depend on the display association,
// so update the enabled state when there is a change in display info.
- out += updateEnableState(when, readerConfig, forceEnable);
+ // NOTE: The first configuration of a mapper must happen with the device enabled.
+ // Do not execute this code on the first configure to prevent mappers
+ // from being configured with the device disabled.
+ out += updateEnableState(when, readerConfig, false);
}
for_each_mapper([this, when, &readerConfig, changes, &out](InputMapper& mapper) {
out += mapper.reconfigure(when, readerConfig, changes);
mSources |= mapper.getSources();
});
+
+ // If a device is just plugged but it might be disabled, we need to update some info like
+ // axis range of touch from each InputMapper first, then disable it.
+ if (!changes.any()) {
+ out += updateEnableState(when, readerConfig);
+ }
}
return out;
}