• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisión8a88939d6473e513cb3c38e74a53c0c5dbdfdded (tree)
Tiempo2009-05-22 03:55:52
AutorXavier Ducrohet <xav@andr...>
CommiterThe Android Open Source Project

Log Message

am a09fbd16: Preparation work for adb to support USB vendor Ids provided by SDK add-ons.

Merge commit 'a09fbd164d2e088bc5433d310e25640ae048d47d'

* commit 'a09fbd164d2e088bc5433d310e25640ae048d47d':

Preparation work for adb to support USB vendor Ids provided by SDK add-ons.

Cambiar Resumen

Diferencia incremental

--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -53,6 +53,7 @@ LOCAL_SRC_FILES := \
5353 $(USB_SRCS) \
5454 shlist.c \
5555 utils.c \
56+ usb_vendors.c \
5657
5758
5859 ifneq ($(USE_SYSDEPS_WIN32),)
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -29,6 +29,8 @@
2929
3030 #if !ADB_HOST
3131 #include <private/android_filesystem_config.h>
32+#else
33+#include "usb_vendors.h"
3234 #endif
3335
3436
@@ -833,6 +835,7 @@ int adb_main(int is_daemon)
833835
834836 #if ADB_HOST
835837 HOST = 1;
838+ usb_vendors_init();
836839 usb_init();
837840 local_init();
838841
@@ -916,6 +919,9 @@ int adb_main(int is_daemon)
916919 fdevent_loop();
917920
918921 usb_cleanup();
922+#if ADB_HOST
923+ usb_vendors_cleanup();
924+#endif
919925
920926 return 0;
921927 }
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -375,7 +375,9 @@ int usb_close(usb_handle *h);
375375 void usb_kick(usb_handle *h);
376376
377377 /* used for USB device detection */
378+#if ADB_HOST
378379 int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol);
380+#endif
379381
380382 unsigned host_to_le32(unsigned n);
381383 int adb_commandline(int argc, char **argv);
--- a/adb/transport_usb.c
+++ b/adb/transport_usb.c
@@ -23,6 +23,10 @@
2323 #define TRACE_TAG TRACE_TRANSPORT
2424 #include "adb.h"
2525
26+#if ADB_HOST
27+#include "usb_vendors.h"
28+#endif
29+
2630 /* XXX better define? */
2731 #ifdef __ppc__
2832 #define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
@@ -125,23 +129,23 @@ void init_usb_transport(atransport *t, usb_handle *h)
125129 #endif
126130 }
127131
132+#if ADB_HOST
128133 int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol)
129134 {
130- if (vid == VENDOR_ID_GOOGLE) {
131- /* might support adb */
132- } else if (vid == VENDOR_ID_HTC) {
133- /* might support adb */
134- } else {
135- /* not supported */
136- return 0;
137- }
138-
139- /* class:vendor (0xff) subclass:android (0x42) proto:adb (0x01) */
140- if(usb_class == 0xff) {
141- if((usb_subclass == 0x42) && (usb_protocol == 0x01)) {
142- return 1;
135+ unsigned i;
136+ for (i = 0; i < vendorIdCount; i++) {
137+ if (vid == vendorIds[i]) {
138+ /* class:vendor (0xff) subclass:android (0x42) proto:adb (0x01) */
139+ if(usb_class == 0xff) {
140+ if((usb_subclass == 0x42) && (usb_protocol == 0x01)) {
141+ return 1;
142+ }
143+ }
144+
145+ return 0;
143146 }
144147 }
145148
146149 return 0;
147150 }
151+#endif
--- a/adb/usb_osx.c
+++ b/adb/usb_osx.c
@@ -28,20 +28,15 @@
2828
2929 #define TRACE_TAG TRACE_USB
3030 #include "adb.h"
31+#include "usb_vendors.h"
3132
3233 #define DBG D
3334
3435 #define ADB_SUBCLASS 0x42
3536 #define ADB_PROTOCOL 0x1
3637
37-int vendorIds[] = {
38- VENDOR_ID_GOOGLE,
39- VENDOR_ID_HTC,
40-};
41-#define NUM_VENDORS (sizeof(vendorIds)/sizeof(vendorIds[0]))
42-
4338 static IONotificationPortRef notificationPort = 0;
44-static io_iterator_t notificationIterators[NUM_VENDORS];
39+static io_iterator_t* notificationIterators;
4540
4641 struct usb_handle
4742 {
@@ -81,7 +76,7 @@ InitUSB()
8176 memset(notificationIterators, 0, sizeof(notificationIterators));
8277
8378 //* loop through all supported vendors
84- for (i = 0; i < NUM_VENDORS; i++) {
79+ for (i = 0; i < vendorIdCount; i++) {
8580 //* Create our matching dictionary to find the Android device's
8681 //* adb interface
8782 //* IOServiceAddMatchingNotification consumes the reference, so we do
@@ -374,7 +369,7 @@ void* RunLoopThread(void* unused)
374369 CFRunLoopRun();
375370 currentRunLoop = 0;
376371
377- for (i = 0; i < NUM_VENDORS; i++) {
372+ for (i = 0; i < vendorIdCount; i++) {
378373 IOObjectRelease(notificationIterators[i]);
379374 }
380375 IONotificationPortDestroy(notificationPort);
@@ -391,6 +386,9 @@ void usb_init()
391386 {
392387 adb_thread_t tid;
393388
389+ notificationIterators = (io_iterator_t*)malloc(
390+ vendorIdCount * sizeof(io_iterator_t));
391+
394392 adb_mutex_init(&start_lock, NULL);
395393 adb_cond_init(&start_cond, NULL);
396394
@@ -415,6 +413,11 @@ void usb_cleanup()
415413 close_usb_devices();
416414 if (currentRunLoop)
417415 CFRunLoopStop(currentRunLoop);
416+
417+ if (notificationIterators != NULL) {
418+ free(notificationIterators);
419+ notificationIterators = NULL;
420+ }
418421 }
419422
420423 int usb_write(usb_handle *handle, const void *buf, int len)
--- /dev/null
+++ b/adb/usb_vendors.c
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#include "usb_vendors.h"
18+
19+#include "sysdeps.h"
20+#include <stdio.h>
21+#include "adb.h"
22+
23+int* vendorIds = NULL;
24+unsigned vendorIdCount = 0;
25+
26+void usb_vendors_init(void) {
27+ /* for now, only put the built-in VENDOR_ID_* */
28+ vendorIdCount = 2;
29+ vendorIds = (int*)malloc(vendorIdCount * sizeof(int));
30+ vendorIds[0] = VENDOR_ID_GOOGLE;
31+ vendorIds[1] = VENDOR_ID_HTC;
32+}
33+
34+void usb_vendors_cleanup(void) {
35+ if (vendorIds != NULL) {
36+ free(vendorIds);
37+ vendorIds = NULL;
38+ vendorIdCount = 0;
39+ }
40+}
--- /dev/null
+++ b/adb/usb_vendors.h
@@ -0,0 +1,26 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#ifndef __USB_VENDORS_H
18+#define __USB_VENDORS_H
19+
20+extern int* vendorIds;
21+extern unsigned vendorIdCount;
22+
23+void usb_vendors_init(void);
24+void usb_vendors_cleanup(void);
25+
26+#endif
\ No newline at end of file