adb: Use correct language ID when retrieving USB serial number.
Fixes http://code.google.com/p/android/issues/detail?id=2609 Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
parent
b3edd0720e
commit
3d9b265b7d
1 changed files with 32 additions and 12 deletions
|
|
@ -269,26 +269,46 @@ static int find_usb_device(const char *base,
|
||||||
if (device->iSerialNumber) {
|
if (device->iSerialNumber) {
|
||||||
struct usbdevfs_ctrltransfer ctrl;
|
struct usbdevfs_ctrltransfer ctrl;
|
||||||
__u16 buffer[128];
|
__u16 buffer[128];
|
||||||
int result;
|
__u16 languages[128];
|
||||||
|
int i, result;
|
||||||
|
int languageCount = 0;
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(languages, 0, sizeof(languages));
|
||||||
memset(&ctrl, 0, sizeof(ctrl));
|
memset(&ctrl, 0, sizeof(ctrl));
|
||||||
|
|
||||||
|
// read list of supported languages
|
||||||
ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE;
|
ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE;
|
||||||
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
|
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
|
||||||
ctrl.wValue = (USB_DT_STRING << 8) | device->iSerialNumber;
|
ctrl.wValue = (USB_DT_STRING << 8) | 0;
|
||||||
ctrl.wIndex = 0;
|
ctrl.wIndex = 0;
|
||||||
ctrl.wLength = sizeof(buffer);
|
ctrl.wLength = sizeof(languages);
|
||||||
ctrl.data = buffer;
|
ctrl.data = languages;
|
||||||
|
|
||||||
result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
|
result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
|
||||||
if (result > 0) {
|
if (result > 0)
|
||||||
int i;
|
languageCount = (result - 2) / 2;
|
||||||
// skip first word, and copy the rest to the serial string, changing shorts to bytes.
|
|
||||||
result /= 2;
|
for (i = 1; i <= languageCount; i++) {
|
||||||
for (i = 1; i < result; i++)
|
memset(buffer, 0, sizeof(buffer));
|
||||||
serial[i - 1] = buffer[i];
|
memset(&ctrl, 0, sizeof(ctrl));
|
||||||
serial[i - 1] = 0;
|
|
||||||
|
ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE;
|
||||||
|
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
|
||||||
|
ctrl.wValue = (USB_DT_STRING << 8) | device->iSerialNumber;
|
||||||
|
ctrl.wIndex = languages[i];
|
||||||
|
ctrl.wLength = sizeof(buffer);
|
||||||
|
ctrl.data = buffer;
|
||||||
|
|
||||||
|
result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
|
||||||
|
if (result > 0) {
|
||||||
|
int i;
|
||||||
|
// skip first word, and copy the rest to the serial string, changing shorts to bytes.
|
||||||
|
result /= 2;
|
||||||
|
for (i = 1; i < result; i++)
|
||||||
|
serial[i - 1] = buffer[i];
|
||||||
|
serial[i - 1] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue