diff options
author | Guang Zhu <guangzhu@google.com> | 2009-08-06 17:21:52 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-08-07 06:36:42 -0400 |
commit | 1a1f8189866196c5bd1ace378cf6b0ca69bff267 (patch) | |
tree | 20d0195c270e4023aa0978b5f831cd75beb27999 /adb | |
parent | 6bc6794f97aa4368237f23c3d3f7cafd6a796bf3 (diff) | |
download | system_core-1a1f8189866196c5bd1ace378cf6b0ca69bff267.zip system_core-1a1f8189866196c5bd1ace378cf6b0ca69bff267.tar.gz system_core-1a1f8189866196c5bd1ace378cf6b0ca69bff267.tar.bz2 |
adb: Use correct language ID when retrieving USB serial number.
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'adb')
-rw-r--r-- | adb/usb_osx.c | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/adb/usb_osx.c b/adb/usb_osx.c index 4892c38..de7125f 100644 --- a/adb/usb_osx.c +++ b/adb/usb_osx.c @@ -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]; - - 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); - - 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; - } - } + if (serialIndex > 0) { + IOUSBDevRequest req; + UInt16 buffer[256]; + UInt16 languages[128]; + + memset(languages, 0, sizeof(languages)); + + 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); + + 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, |