@@ -246,7 +246,7 @@ static nsecs_t processEventTimestamp(const struct input_event& event) {
246246/* *
247247 * Returns the sysfs root path of the input device.
248248 */
249- static std::optional<std::filesystem::path> getSysfsRootPath (const char * devicePath) {
249+ static std::optional<std::filesystem::path> getSysfsRootForEvdevDevicePath (const char * devicePath) {
250250 std::error_code errorCode;
251251
252252 // Stat the device path to get the major and minor number of the character file
@@ -1619,7 +1619,7 @@ void EventHub::assignDescriptorLocked(InputDeviceIdentifier& identifier) {
16191619std::shared_ptr<const EventHub::AssociatedDevice> EventHub::obtainAssociatedDeviceLocked (
16201620 const std::filesystem::path& devicePath, const std::shared_ptr<PropertyMap>& config) const {
16211621 const std::optional<std::filesystem::path> sysfsRootPathOpt =
1622- getSysfsRootPath (devicePath.c_str ());
1622+ getSysfsRootForEvdevDevicePath (devicePath.c_str ());
16231623 if (!sysfsRootPathOpt) {
16241624 return nullptr ;
16251625 }
@@ -2666,6 +2666,18 @@ status_t EventHub::disableDevice(int32_t deviceId) {
26662666 return device->disable ();
26672667}
26682668
2669+ std::filesystem::path EventHub::getSysfsRootPath (int32_t deviceId) const {
2670+ std::scoped_lock _l (mLock );
2671+ Device* device = getDeviceLocked (deviceId);
2672+ if (device == nullptr ) {
2673+ ALOGE (" Invalid device id=%" PRId32 " provided to %s" , deviceId, __func__);
2674+ return {};
2675+ }
2676+
2677+ return device->associatedDevice ? device->associatedDevice ->sysfsRootPath
2678+ : std::filesystem::path{};
2679+ }
2680+
26692681// TODO(b/274755573): Shift to uevent handling on native side and remove this method
26702682// Currently using Java UEventObserver to trigger this which uses UEvent infrastructure that uses a
26712683// NETLINK socket to observe UEvents. We can create similar infrastructure on Eventhub side to
@@ -2710,6 +2722,10 @@ void EventHub::handleSysfsNodeChangeNotificationsLocked() {
27102722 auto reloadedDevice = AssociatedDevice (dev.associatedDevice ->sysfsRootPath ,
27112723 dev.associatedDevice ->baseDevConfig );
27122724 const bool changed = *dev.associatedDevice != reloadedDevice;
2725+ if (changed) {
2726+ ALOGI (" sysfsNodeChanged: Identified change in sysfs nodes for device: %s" ,
2727+ dev.identifier .name .c_str ());
2728+ }
27132729 testedDevices.emplace (dev.associatedDevice , changed);
27142730 return changed;
27152731 };
0 commit comments