adb: Use correct language ID when retrieving USB serial number.
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
parent
63e6152748
commit
e64004d327
|
@ -194,30 +194,54 @@ AndroidInterfaceAdded(void *refCon, io_iterator_t iterator)
|
|||
kr = (*dev)->GetDeviceProduct(dev, &product);
|
||||
kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex);
|
||||
|
||||
if (serialIndex > 0) {
|
||||
IOUSBDevRequest req;
|
||||
UInt16 buffer[256];
|
||||
if (serialIndex > 0) {
|
||||
IOUSBDevRequest req;
|
||||
UInt16 buffer[256];
|
||||
UInt16 languages[128];
|
||||
|
||||
req.bmRequestType =
|
||||
USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice);
|
||||
req.bRequest = kUSBRqGetDescriptor;
|
||||
req.wValue = (kUSBStringDesc << 8) | serialIndex;
|
||||
req.wIndex = 0;
|
||||
req.pData = buffer;
|
||||
req.wLength = sizeof(buffer);
|
||||
kr = (*dev)->DeviceRequest(dev, &req);
|
||||
memset(languages, 0, sizeof(languages));
|
||||
|
||||
if (kr == kIOReturnSuccess && req.wLenDone > 0) {
|
||||
int i, count;
|
||||
req.bmRequestType =
|
||||
USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice);
|
||||
req.bRequest = kUSBRqGetDescriptor;
|
||||
req.wValue = (kUSBStringDesc << 8) | 0;
|
||||
req.wIndex = 0;
|
||||
req.pData = languages;
|
||||
req.wLength = sizeof(languages);
|
||||
kr = (*dev)->DeviceRequest(dev, &req);
|
||||
|
||||
// skip first word, and copy the rest to the serial string,
|
||||
// changing shorts to bytes.
|
||||
count = (req.wLenDone - 1) / 2;
|
||||
for (i = 0; i < count; i++)
|
||||
serial[i] = buffer[i + 1];
|
||||
serial[i] = 0;
|
||||
}
|
||||
}
|
||||
if (kr == kIOReturnSuccess && req.wLenDone > 0) {
|
||||
|
||||
int langCount = (req.wLenDone - 2) / 2, lang;
|
||||
|
||||
for (lang = 1; lang <= langCount; lang++) {
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
req.bmRequestType =
|
||||
USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice);
|
||||
req.bRequest = kUSBRqGetDescriptor;
|
||||
req.wValue = (kUSBStringDesc << 8) | serialIndex;
|
||||
req.wIndex = languages[lang];
|
||||
req.pData = buffer;
|
||||
req.wLength = sizeof(buffer);
|
||||
kr = (*dev)->DeviceRequest(dev, &req);
|
||||
|
||||
if (kr == kIOReturnSuccess && req.wLenDone > 0) {
|
||||
int i, count;
|
||||
|
||||
// skip first word, and copy the rest to the serial string,
|
||||
// changing shorts to bytes.
|
||||
count = (req.wLenDone - 1) / 2;
|
||||
for (i = 0; i < count; i++)
|
||||
serial[i] = buffer[i + 1];
|
||||
serial[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(*dev)->Release(dev);
|
||||
|
||||
DBG("INFO: Found vid=%04x pid=%04x serial=%s\n", vendor, product,
|
||||
|
|
Loading…
Reference in New Issue