Preparation work for adb to support USB vendor Ids provided by SDK add-ons.
Added usb_vendors.* which handles creating (and deleting) a list of vendor ids.
This list is meant to be used everywhere the built-in lists (usb_osx), or the
built-in vendor IDs (transport_usb) were used.
For now the list is only built with the built-in VENDOR_ID_*. Next step
is to read a small file created from all the SDK add-on.
Other misc changes: made is_adb_interface present only if ADB_HOST is true
to prevent accessing a list that doesn't exist (usb_vendors is only
compiled for the host version of adb).
diff --git a/adb/transport_usb.c b/adb/transport_usb.c
index 01c4a7e..50ebff7 100644
--- a/adb/transport_usb.c
+++ b/adb/transport_usb.c
@@ -23,6 +23,10 @@
#define TRACE_TAG TRACE_TRANSPORT
#include "adb.h"
+#if ADB_HOST
+#include "usb_vendors.h"
+#endif
+
/* XXX better define? */
#ifdef __ppc__
#define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
@@ -125,23 +129,23 @@
#endif
}
+#if ADB_HOST
int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol)
{
- if (vid == VENDOR_ID_GOOGLE) {
- /* might support adb */
- } else if (vid == VENDOR_ID_HTC) {
- /* might support adb */
- } else {
- /* not supported */
- return 0;
- }
+ unsigned i;
+ for (i = 0; i < vendorIdCount; i++) {
+ if (vid == vendorIds[i]) {
+ /* class:vendor (0xff) subclass:android (0x42) proto:adb (0x01) */
+ if(usb_class == 0xff) {
+ if((usb_subclass == 0x42) && (usb_protocol == 0x01)) {
+ return 1;
+ }
+ }
- /* class:vendor (0xff) subclass:android (0x42) proto:adb (0x01) */
- if(usb_class == 0xff) {
- if((usb_subclass == 0x42) && (usb_protocol == 0x01)) {
- return 1;
+ return 0;
}
}
return 0;
}
+#endif