Loading services/inputflinger/reader/EventHub.cpp +22 −6 Original line number Diff line number Diff line Loading @@ -1418,17 +1418,28 @@ std::shared_ptr<const EventHub::AssociatedDevice> EventHub::obtainAssociatedDevi } const auto& path = *sysfsRootPathOpt; for (const auto& [id, dev] : mDevices) { if (dev->associatedDevice && dev->associatedDevice->sysfsRootPath == path) { return dev->associatedDevice; } } return std::make_shared<AssociatedDevice>( std::shared_ptr<const AssociatedDevice> associatedDevice = std::make_shared<AssociatedDevice>( AssociatedDevice{.sysfsRootPath = path, .countryCode = readCountryCodeLocked(path), .batteryInfos = readBatteryConfiguration(path), .lightInfos = readLightsConfiguration(path)}); bool associatedDeviceChanged = false; for (const auto& [id, dev] : mDevices) { if (dev->associatedDevice && dev->associatedDevice->sysfsRootPath == path) { if (*associatedDevice != *dev->associatedDevice) { associatedDeviceChanged = true; dev->associatedDevice = associatedDevice; } associatedDevice = dev->associatedDevice; } } ALOGI_IF(associatedDeviceChanged, "The AssociatedDevice changed for path '%s'. Using new AssociatedDevice: %s", path.c_str(), associatedDevice->dump().c_str()); return associatedDevice; } void EventHub::vibrate(int32_t deviceId, const VibrationElement& element) { Loading Loading @@ -2650,4 +2661,9 @@ void EventHub::monitor() const { std::unique_lock<std::mutex> lock(mLock); } std::string EventHub::AssociatedDevice::dump() const { return StringPrintf("path=%s, numBatteries=%zu, numLight=%zu", sysfsRootPath.c_str(), batteryInfos.size(), lightInfos.size()); } } // namespace android services/inputflinger/reader/include/EventHub.h +11 −1 Original line number Diff line number Diff line Loading @@ -195,6 +195,9 @@ struct RawLightInfo { ftl::Flags<InputLightClass> flags; std::array<int32_t, COLOR_NUM> rgbIndex; std::filesystem::path path; bool operator==(const RawLightInfo&) const = default; bool operator!=(const RawLightInfo&) const = default; }; /* Describes a raw battery. */ Loading @@ -203,6 +206,9 @@ struct RawBatteryInfo { std::string name; ftl::Flags<InputBatteryClass> flags; std::filesystem::path path; bool operator==(const RawBatteryInfo&) const = default; bool operator!=(const RawBatteryInfo&) const = default; }; /* Loading Loading @@ -551,6 +557,10 @@ private: hardware::input::InputDeviceCountryCode countryCode; std::unordered_map<int32_t /*batteryId*/, RawBatteryInfo> batteryInfos; std::unordered_map<int32_t /*lightId*/, RawLightInfo> lightInfos; bool operator==(const AssociatedDevice&) const = default; bool operator!=(const AssociatedDevice&) const = default; std::string dump() const; }; struct Device { Loading Loading @@ -584,7 +594,7 @@ private: // A shared_ptr of a device associated with the input device. // The input devices that have the same sysfs path have the same associated device. const std::shared_ptr<const AssociatedDevice> associatedDevice; std::shared_ptr<const AssociatedDevice> associatedDevice; int32_t controllerNumber; Loading Loading
services/inputflinger/reader/EventHub.cpp +22 −6 Original line number Diff line number Diff line Loading @@ -1418,17 +1418,28 @@ std::shared_ptr<const EventHub::AssociatedDevice> EventHub::obtainAssociatedDevi } const auto& path = *sysfsRootPathOpt; for (const auto& [id, dev] : mDevices) { if (dev->associatedDevice && dev->associatedDevice->sysfsRootPath == path) { return dev->associatedDevice; } } return std::make_shared<AssociatedDevice>( std::shared_ptr<const AssociatedDevice> associatedDevice = std::make_shared<AssociatedDevice>( AssociatedDevice{.sysfsRootPath = path, .countryCode = readCountryCodeLocked(path), .batteryInfos = readBatteryConfiguration(path), .lightInfos = readLightsConfiguration(path)}); bool associatedDeviceChanged = false; for (const auto& [id, dev] : mDevices) { if (dev->associatedDevice && dev->associatedDevice->sysfsRootPath == path) { if (*associatedDevice != *dev->associatedDevice) { associatedDeviceChanged = true; dev->associatedDevice = associatedDevice; } associatedDevice = dev->associatedDevice; } } ALOGI_IF(associatedDeviceChanged, "The AssociatedDevice changed for path '%s'. Using new AssociatedDevice: %s", path.c_str(), associatedDevice->dump().c_str()); return associatedDevice; } void EventHub::vibrate(int32_t deviceId, const VibrationElement& element) { Loading Loading @@ -2650,4 +2661,9 @@ void EventHub::monitor() const { std::unique_lock<std::mutex> lock(mLock); } std::string EventHub::AssociatedDevice::dump() const { return StringPrintf("path=%s, numBatteries=%zu, numLight=%zu", sysfsRootPath.c_str(), batteryInfos.size(), lightInfos.size()); } } // namespace android
services/inputflinger/reader/include/EventHub.h +11 −1 Original line number Diff line number Diff line Loading @@ -195,6 +195,9 @@ struct RawLightInfo { ftl::Flags<InputLightClass> flags; std::array<int32_t, COLOR_NUM> rgbIndex; std::filesystem::path path; bool operator==(const RawLightInfo&) const = default; bool operator!=(const RawLightInfo&) const = default; }; /* Describes a raw battery. */ Loading @@ -203,6 +206,9 @@ struct RawBatteryInfo { std::string name; ftl::Flags<InputBatteryClass> flags; std::filesystem::path path; bool operator==(const RawBatteryInfo&) const = default; bool operator!=(const RawBatteryInfo&) const = default; }; /* Loading Loading @@ -551,6 +557,10 @@ private: hardware::input::InputDeviceCountryCode countryCode; std::unordered_map<int32_t /*batteryId*/, RawBatteryInfo> batteryInfos; std::unordered_map<int32_t /*lightId*/, RawLightInfo> lightInfos; bool operator==(const AssociatedDevice&) const = default; bool operator!=(const AssociatedDevice&) const = default; std::string dump() const; }; struct Device { Loading Loading @@ -584,7 +594,7 @@ private: // A shared_ptr of a device associated with the input device. // The input devices that have the same sysfs path have the same associated device. const std::shared_ptr<const AssociatedDevice> associatedDevice; std::shared_ptr<const AssociatedDevice> associatedDevice; int32_t controllerNumber; Loading