Merge change 2135 into donut

* changes:
  nexus: Switch controllers to use abstracted properties and refactor command protocol
diff --git a/adb/Android.mk b/adb/Android.mk
index 6cbaf82..9725478 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -53,6 +53,7 @@
 	$(USB_SRCS) \
 	shlist.c \
 	utils.c \
+	usb_vendors.c \
 
 
 ifneq ($(USE_SYSDEPS_WIN32),)
diff --git a/adb/adb.c b/adb/adb.c
index 7a2b299..0b5ebac 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -29,6 +29,8 @@
 
 #if !ADB_HOST
 #include <private/android_filesystem_config.h>
+#else
+#include "usb_vendors.h"
 #endif
 
 
@@ -833,6 +835,7 @@
 
 #if ADB_HOST
     HOST = 1;
+    usb_vendors_init();
     usb_init();
     local_init();
 
@@ -916,6 +919,9 @@
     fdevent_loop();
 
     usb_cleanup();
+#if ADB_HOST
+    usb_vendors_cleanup();
+#endif
 
     return 0;
 }
diff --git a/adb/adb.h b/adb/adb.h
index aebb81a..7762e00 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -375,7 +375,9 @@
 void usb_kick(usb_handle *h);
 
 /* used for USB device detection */
+#if ADB_HOST
 int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol);
+#endif
 
 unsigned host_to_le32(unsigned n);
 int adb_commandline(int argc, char **argv);
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
diff --git a/adb/usb_osx.c b/adb/usb_osx.c
index 2d4c1a9..171a9fc 100644
--- a/adb/usb_osx.c
+++ b/adb/usb_osx.c
@@ -28,20 +28,15 @@
 
 #define TRACE_TAG   TRACE_USB
 #include "adb.h"
+#include "usb_vendors.h"
 
 #define  DBG   D
 
 #define ADB_SUBCLASS           0x42
 #define ADB_PROTOCOL           0x1
 
-int vendorIds[] = {
-    VENDOR_ID_GOOGLE,
-    VENDOR_ID_HTC,
-};
-#define NUM_VENDORS             (sizeof(vendorIds)/sizeof(vendorIds[0]))
-
 static IONotificationPortRef    notificationPort = 0;
-static io_iterator_t            notificationIterators[NUM_VENDORS];
+static io_iterator_t*           notificationIterators;
 
 struct usb_handle
 {
@@ -81,7 +76,7 @@
     memset(notificationIterators, 0, sizeof(notificationIterators));
 
     //* loop through all supported vendors
-    for (i = 0; i < NUM_VENDORS; i++) {
+    for (i = 0; i < vendorIdCount; i++) {
         //* Create our matching dictionary to find the Android device's
         //* adb interface
         //* IOServiceAddMatchingNotification consumes the reference, so we do
@@ -374,7 +369,7 @@
     CFRunLoopRun();
     currentRunLoop = 0;
 
-    for (i = 0; i < NUM_VENDORS; i++) {
+    for (i = 0; i < vendorIdCount; i++) {
         IOObjectRelease(notificationIterators[i]);
     }
     IONotificationPortDestroy(notificationPort);
@@ -391,6 +386,9 @@
     {
         adb_thread_t    tid;
 
+        notificationIterators = (io_iterator_t*)malloc(
+            vendorIdCount * sizeof(io_iterator_t));
+
         adb_mutex_init(&start_lock, NULL);
         adb_cond_init(&start_cond, NULL);
 
@@ -415,6 +413,11 @@
     close_usb_devices();
     if (currentRunLoop)
         CFRunLoopStop(currentRunLoop);
+
+    if (notificationIterators != NULL) {
+        free(notificationIterators);
+        notificationIterators = NULL;
+    }
 }
 
 int usb_write(usb_handle *handle, const void *buf, int len)
diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c
new file mode 100644
index 0000000..f949249
--- /dev/null
+++ b/adb/usb_vendors.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "usb_vendors.h"
+
+#include "sysdeps.h"
+#include <stdio.h>
+#include "adb.h"
+
+int* vendorIds = NULL;
+unsigned vendorIdCount = 0;
+
+void usb_vendors_init(void) {
+    /* for now, only put the built-in VENDOR_ID_* */
+    vendorIdCount = 2;
+    vendorIds = (int*)malloc(vendorIdCount * sizeof(int));
+    vendorIds[0] = VENDOR_ID_GOOGLE;
+    vendorIds[1] = VENDOR_ID_HTC;
+}
+
+void usb_vendors_cleanup(void) {
+    if (vendorIds != NULL) {
+        free(vendorIds);
+        vendorIds = NULL;
+        vendorIdCount = 0;
+    }
+}
diff --git a/adb/usb_vendors.h b/adb/usb_vendors.h
new file mode 100644
index 0000000..43e5f99
--- /dev/null
+++ b/adb/usb_vendors.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __USB_VENDORS_H
+#define __USB_VENDORS_H
+
+extern int* vendorIds;
+extern unsigned  vendorIdCount;
+
+void usb_vendors_init(void);
+void usb_vendors_cleanup(void);
+
+#endif
\ No newline at end of file
diff --git a/include/cutils/native_handle.h b/include/cutils/native_handle.h
index 8a44b72..89d6b65 100644
--- a/include/cutils/native_handle.h
+++ b/include/cutils/native_handle.h
@@ -17,9 +17,9 @@
 #ifndef NATIVE_HANDLE_H_
 #define NATIVE_HANDLE_H_
 
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct
 {
@@ -66,6 +66,8 @@
 int native_handle_delete(native_handle_t* h);
 
 
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* NATIVE_HANDLE_H_ */
diff --git a/rootdir/init.rc b/rootdir/init.rc
index c20eeaa..9853cc6 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -246,6 +246,12 @@
     group audio
     oneshot
 
+service bootanim /system/bin/bootanimation
+    user graphics
+    group graphics
+    disabled
+    oneshot
+
 service dbus /system/bin/dbus-daemon --system --nofork
     socket dbus stream 660 bluetooth bluetooth
     user bluetooth