]> sigrok.org Git - sigrok-androidutils.git/commitdiff
Parse vendor-id and product-id as hexadecimal values
authorDaniel Schaal <redacted>
Tue, 9 May 2017 15:36:52 +0000 (17:36 +0200)
committerUwe Hermann <redacted>
Tue, 9 May 2017 20:39:05 +0000 (22:39 +0200)
Fixes #932

src/org/sigrok/androidutils/UsbSupplicant.java

index 0f219a87c932c2dbc7466762b1865c0dea00b3da..eaec3d69c1b2d3ca673a0b6d337a44ba01e8aff2 100644 (file)
@@ -106,7 +106,7 @@ public class UsbSupplicant
                        for (int i = 0; i < count; i++) {
                                String name = parser.getAttributeName(i);
                                // All attribute values are ints
-                               int value = Integer.parseInt(parser.getAttributeValue(i));
+                               int value = parseAttribute(name, parser.getAttributeValue(i));
 
                                if ("vendor-id".equals(name)) {
                                        vendorId = value;
@@ -124,6 +124,14 @@ public class UsbSupplicant
                                        deviceClass, deviceSubclass, deviceProtocol);
                }
 
+               private static int parseAttribute(String name, String value) {
+                       // vendor-id and product-id are in hexadecimal format.
+                       if ("vendor-id".equals(name) || "product-id".equals(name))
+                               return Integer.parseInt(value, 16);
+                       else
+                               return Integer.parseInt(value);
+               }
+
                private boolean matches(int clasz, int subclass, int protocol) {
                        return ((mClass == -1 || clasz == mClass) &&
                                        (mSubclass == -1 || subclass == mSubclass) &&