system/corennnnn
リビジョン | 1a1f8189866196c5bd1ace378cf6b0ca69bff267 (tree) |
---|---|
日時 | 2009-08-07 19:36:42 |
作者 | Guang Zhu <guangzhu@goog...> |
コミッター | Mike Lockwood |
adb: Use correct language ID when retrieving USB serial number.
Signed-off-by: Mike Lockwood <lockwood@android.com>
@@ -194,30 +194,54 @@ AndroidInterfaceAdded(void *refCon, io_iterator_t iterator) | ||
194 | 194 | kr = (*dev)->GetDeviceProduct(dev, &product); |
195 | 195 | kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex); |
196 | 196 | |
197 | - if (serialIndex > 0) { | |
198 | - IOUSBDevRequest req; | |
199 | - UInt16 buffer[256]; | |
200 | - | |
201 | - req.bmRequestType = | |
202 | - USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); | |
203 | - req.bRequest = kUSBRqGetDescriptor; | |
204 | - req.wValue = (kUSBStringDesc << 8) | serialIndex; | |
205 | - req.wIndex = 0; | |
206 | - req.pData = buffer; | |
207 | - req.wLength = sizeof(buffer); | |
208 | - kr = (*dev)->DeviceRequest(dev, &req); | |
209 | - | |
210 | - if (kr == kIOReturnSuccess && req.wLenDone > 0) { | |
211 | - int i, count; | |
212 | - | |
213 | - // skip first word, and copy the rest to the serial string, | |
214 | - // changing shorts to bytes. | |
215 | - count = (req.wLenDone - 1) / 2; | |
216 | - for (i = 0; i < count; i++) | |
217 | - serial[i] = buffer[i + 1]; | |
218 | - serial[i] = 0; | |
219 | - } | |
220 | - } | |
197 | + if (serialIndex > 0) { | |
198 | + IOUSBDevRequest req; | |
199 | + UInt16 buffer[256]; | |
200 | + UInt16 languages[128]; | |
201 | + | |
202 | + memset(languages, 0, sizeof(languages)); | |
203 | + | |
204 | + req.bmRequestType = | |
205 | + USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); | |
206 | + req.bRequest = kUSBRqGetDescriptor; | |
207 | + req.wValue = (kUSBStringDesc << 8) | 0; | |
208 | + req.wIndex = 0; | |
209 | + req.pData = languages; | |
210 | + req.wLength = sizeof(languages); | |
211 | + kr = (*dev)->DeviceRequest(dev, &req); | |
212 | + | |
213 | + if (kr == kIOReturnSuccess && req.wLenDone > 0) { | |
214 | + | |
215 | + int langCount = (req.wLenDone - 2) / 2, lang; | |
216 | + | |
217 | + for (lang = 1; lang <= langCount; lang++) { | |
218 | + | |
219 | + memset(buffer, 0, sizeof(buffer)); | |
220 | + memset(&req, 0, sizeof(req)); | |
221 | + | |
222 | + req.bmRequestType = | |
223 | + USBmakebmRequestType(kUSBIn, kUSBStandard, kUSBDevice); | |
224 | + req.bRequest = kUSBRqGetDescriptor; | |
225 | + req.wValue = (kUSBStringDesc << 8) | serialIndex; | |
226 | + req.wIndex = languages[lang]; | |
227 | + req.pData = buffer; | |
228 | + req.wLength = sizeof(buffer); | |
229 | + kr = (*dev)->DeviceRequest(dev, &req); | |
230 | + | |
231 | + if (kr == kIOReturnSuccess && req.wLenDone > 0) { | |
232 | + int i, count; | |
233 | + | |
234 | + // skip first word, and copy the rest to the serial string, | |
235 | + // changing shorts to bytes. | |
236 | + count = (req.wLenDone - 1) / 2; | |
237 | + for (i = 0; i < count; i++) | |
238 | + serial[i] = buffer[i + 1]; | |
239 | + serial[i] = 0; | |
240 | + break; | |
241 | + } | |
242 | + } | |
243 | + } | |
244 | + } | |
221 | 245 | (*dev)->Release(dev); |
222 | 246 | |
223 | 247 | DBG("INFO: Found vid=%04x pid=%04x serial=%s\n", vendor, product, |