Index: device/hid/hid_service_mac.cc |
diff --git a/device/hid/hid_service_mac.cc b/device/hid/hid_service_mac.cc |
index dec4e70a1153e0b7e476a0dc7349afc38784aa48..fb12d96eae1d0d54f9b118f8e0d797bd1db4aca2 100644 |
--- a/device/hid/hid_service_mac.cc |
+++ b/device/hid/hid_service_mac.cc |
@@ -140,12 +140,13 @@ void HidServiceMac::Connect(const HidDeviceId& device_id, |
} |
scoped_refptr<HidDeviceInfo> device_info = map_entry->second; |
- io_string_t service_path; |
- strncpy(service_path, device_id.c_str(), sizeof service_path); |
+ base::ScopedCFTypeRef<CFDictionaryRef> matching_dict( |
+ IORegistryEntryIDMatching(device_id)); |
+ |
base::mac::ScopedIOObject<io_service_t> service( |
- IORegistryEntryFromPath(kIOMasterPortDefault, service_path)); |
+ IOServiceGetMatchingService(kIOMasterPortDefault, matching_dict.get())); |
if (!service.get()) { |
- HID_LOG(EVENT) << "IOService not found for path: " << device_id; |
+ HID_LOG(EVENT) << "IOService not found for ID: " << device_id; |
task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr)); |
return; |
} |
@@ -212,11 +213,10 @@ void HidServiceMac::RemoveDevices() { |
io_service_t device; |
while ((device = IOIteratorNext(devices_removed_iterator_)) != |
IO_OBJECT_NULL) { |
- io_string_t service_path; |
- IOReturn result = |
- IORegistryEntryGetPath(device, kIOServicePlane, service_path); |
+ uint64_t entry_id; |
+ IOReturn result = IORegistryEntryGetRegistryEntryID(device, &entry_id); |
if (result == kIOReturnSuccess) { |
- RemoveDevice(service_path); |
+ RemoveDevice(entry_id); |
} |
// Release reference retained by AddDevices above. |
@@ -229,32 +229,30 @@ void HidServiceMac::RemoveDevices() { |
// static |
scoped_refptr<HidDeviceInfo> HidServiceMac::CreateDeviceInfo( |
io_service_t service) { |
- io_string_t service_path; |
- IOReturn result = |
- IORegistryEntryGetPath(service, kIOServicePlane, service_path); |
+ uint64_t entry_id; |
+ IOReturn result = IORegistryEntryGetRegistryEntryID(service, &entry_id); |
if (result != kIOReturnSuccess) { |
- HID_LOG(EVENT) << "Failed to get IOService path: " << HexErrorCode(result); |
+ HID_LOG(EVENT) << "Failed to get IORegistryEntry ID: " |
+ << HexErrorCode(result); |
return nullptr; |
} |
base::ScopedCFTypeRef<IOHIDDeviceRef> hid_device( |
IOHIDDeviceCreate(kCFAllocatorDefault, service)); |
if (!hid_device) { |
- HID_LOG(EVENT) << "Unable to create IOHIDDevice object for " << service_path |
- << "."; |
+ HID_LOG(EVENT) << "Unable to create IOHIDDevice object for new device."; |
return nullptr; |
} |
std::vector<uint8> report_descriptor; |
if (!TryGetHidDataProperty(hid_device, CFSTR(kIOHIDReportDescriptorKey), |
&report_descriptor)) { |
- HID_LOG(EVENT) << "Unable to get report descriptor for " << service_path |
- << "."; |
+ HID_LOG(EVENT) << "Unable to get report descriptor for new device."; |
return nullptr; |
} |
return new HidDeviceInfo( |
- service_path, GetHidIntProperty(hid_device, CFSTR(kIOHIDVendorIDKey)), |
+ entry_id, GetHidIntProperty(hid_device, CFSTR(kIOHIDVendorIDKey)), |
GetHidIntProperty(hid_device, CFSTR(kIOHIDProductIDKey)), |
GetHidStringProperty(hid_device, CFSTR(kIOHIDProductKey)), |
GetHidStringProperty(hid_device, CFSTR(kIOHIDSerialNumberKey)), |