View | Details | Raw Unified | Return to bug 199185 | Differences between
and this patch

Collapse All | Expand All

(-)devel/android-tools-adb/files/patch-usb_libusb.c (-2 / +61 lines)
Lines 1-5 Link Here
1
--- usb_libusb.c.orig	2013-08-01 17:14:17.000000000 +0800
1
--- usb_libusb.c.orig	2015-04-13 15:24:18 UTC
2
+++ usb_libusb.c	2013-08-01 17:14:46.000000000 +0800
2
+++ usb_libusb.c
3
@@ -37,7 +37,7 @@
3
@@ -37,7 +37,7 @@
4
 #define   TRACE_TAG  TRACE_USB
4
 #define   TRACE_TAG  TRACE_USB
5
 #include "adb.h"
5
 #include "adb.h"
Lines 22-24 Link Here
22
 
22
 
23
     return (1);
23
     return (1);
24
 }
24
 }
25
@@ -484,51 +488,13 @@ check_device(libusb_device *dev) 
26
             goto fail;
27
         }
28
 
29
-        if (desc.iSerialNumber) {
30
-            // reading serial
31
-            uint16_t    buffer[128] = {0};
32
-            uint16_t    languages[128] = {0};
33
-            int languageCount = 0;
34
-
35
-            memset(languages, 0, sizeof(languages));
36
-            r = libusb_control_transfer(uh.devh, 
37
-                LIBUSB_ENDPOINT_IN |  LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE,
38
-                LIBUSB_REQUEST_GET_DESCRIPTOR, LIBUSB_DT_STRING << 8,
39
-		0, (uint8_t *)languages, sizeof(languages), 0);
40
-
41
-            if (r <= 0) {
42
-                D("check_device(): Failed to get languages count\n");
43
-                goto fail;
44
-            } 
45
-            
46
-            languageCount = (r - 2) / 2;
47
-            
48
-            for (i = 1; i <= languageCount; ++i) {
49
-                memset(buffer, 0, sizeof(buffer));
50
-
51
-                r = libusb_control_transfer(uh.devh, 
52
-                    LIBUSB_ENDPOINT_IN |  LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE,
53
-                    LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc.iSerialNumber,
54
-		    languages[i], (uint8_t *)buffer, sizeof(buffer), 0);
55
-            
56
-                if (r > 0) { /* converting serial */
57
-                    int j = 0;
58
-                    r /= 2;
59
-                
60
-                    for (j = 1; j < r; ++j)
61
-                        serial[j - 1] = buffer[j];
62
-                
63
-                    serial[j - 1] = '\0';
64
-                    break; /* languagesCount cycle */
65
-                }
66
-            }
67
-            
68
-            if (register_device(&uh, serial) == 0) {
69
-                D("check_device(): Failed to register device\n");
70
-                goto fail_interface;
71
-            }
72
-            
73
-            libusb_ref_device(dev);
74
+        if (desc.iSerialNumber != 0) {
75
+            libusb_get_string_descriptor_ascii(uh.devh, desc.iSerialNumber,
76
+                                               (unsigned char *)uh.serial, sizeof(uh.serial));
77
+        }
78
+        if (register_device(&uh, uh.serial) == 0) {
79
+            D("check_device(): Failed to register device\n");
80
+            goto fail_interface;
81
         }
82
     }
83
     
(-)devel/android-tools-adb-devel/files/usb_libusb.cpp (-45 / +7 lines)
Lines 484-535 check_device(libusb_device *dev) Link Here
484
            goto fail;
484
            goto fail;
485
        }
485
        }
486
486
487
        if (desc.iSerialNumber) {
487
        if (desc.iSerialNumber != 0) {
488
            // reading serial
488
            libusb_get_string_descriptor_ascii(uh.devh, desc.iSerialNumber,
489
            uint16_t    buffer[128] = {0};
489
                                               (unsigned char *)uh.serial, sizeof(uh.serial));
490
            uint16_t    languages[128] = {0};
491
            int languageCount = 0;
492
493
            memset(languages, 0, sizeof(languages));
494
            r = libusb_control_transfer(uh.devh,
495
                                        LIBUSB_ENDPOINT_IN |  LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE,
496
                                        LIBUSB_REQUEST_GET_DESCRIPTOR, LIBUSB_DT_STRING << 8,
497
                                        0, (uint8_t *)languages, sizeof(languages), 0);
498
499
            if (r <= 0) {
500
                D("check_device(): Failed to get languages count\n");
501
                goto fail;
502
            }
503
504
            languageCount = (r - 2) / 2;
505
506
            for (i = 1; i <= languageCount; ++i) {
507
                memset(buffer, 0, sizeof(buffer));
508
509
                r = libusb_control_transfer(uh.devh,
510
                                            LIBUSB_ENDPOINT_IN |  LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE,
511
                                            LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc.iSerialNumber,
512
                                            languages[i], (uint8_t *)buffer, sizeof(buffer), 0);
513
514
                if (r > 0) { /* converting serial */
515
                    int j = 0;
516
                    r /= 2;
517
518
                    for (j = 1; j < r; ++j)
519
                        serial[j - 1] = buffer[j];
520
521
                    serial[j - 1] = '\0';
522
                    break; /* languagesCount cycle */
523
                }
524
            }
525
526
            if (register_device(&uh, serial) == 0) {
527
                D("check_device(): Failed to register device\n");
528
                goto fail_interface;
529
            }
530
531
            libusb_ref_device(dev);
532
        }
490
        }
491
        if (register_device(&uh, uh.serial) == 0) {
492
            D("check_device(): Failed to register device\n");
493
            goto fail_interface;
494
        }
533
    }
495
    }
534
496
535
    return;
497
    return;

Return to bug 199185