Merge "Fix bug 4319552 Use commonly defined channel mask values in native"
diff --git a/include/system/camera.h b/include/system/camera.h
index 58e0c6f..a3da52e 100644
--- a/include/system/camera.h
+++ b/include/system/camera.h
@@ -80,6 +80,7 @@
     CAMERA_MSG_RAW_IMAGE = 0x0080,
     CAMERA_MSG_COMPRESSED_IMAGE = 0x0100,
     CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200,
+    CAMERA_MSG_FACE = 0x0400,
     CAMERA_MSG_ALL_MSGS = 0xFFFF
 };
 
@@ -87,7 +88,9 @@
 enum {
     CAMERA_CMD_START_SMOOTH_ZOOM = 1,
     CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,
-    /** Set the clockwise rotation of preview display (setPreviewDisplay) in
+
+    /**
+     * Set the clockwise rotation of preview display (setPreviewDisplay) in
      * degrees. This affects the preview frames and the picture displayed after
      * snapshot. This method is useful for portrait mode applications. Note
      * that preview display of front-facing cameras is flipped horizontally
@@ -103,13 +106,38 @@
      */
     CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,
 
-    /** cmdType to disable/enable shutter sound. In sendCommand passing arg1 =
+    /**
+     * cmdType to disable/enable shutter sound. In sendCommand passing arg1 =
      * 0 will disable, while passing arg1 = 1 will enable the shutter sound.
      */
     CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4,
 
     /* cmdType to play recording sound */
     CAMERA_CMD_PLAY_RECORDING_SOUND = 5,
+
+    /**
+     * Start the face detection. This should be called after preview is started.
+     * The camera will notify the listener of CAMERA_MSG_FACE and the detected
+     * faces in the preview frame. The detected faces may be the same as the
+     * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop
+     * the face detection. This method is supported if CameraParameters
+     * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is
+     * bigger than 0. Hardware and software face detection should not be running
+     * at the same time. If the face detection has started, apps should not send
+     * this again.
+     *
+     * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE,
+     * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect.
+     *
+     * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or
+     * CAMERA_FACE_DETECTION_SW.
+     */
+    CAMERA_CMD_START_FACE_DETECTION = 6,
+
+    /**
+     * Stop the face detection.
+     */
+    CAMERA_CMD_STOP_FACE_DETECTION = 7,
 };
 
 /** camera fatal errors */
@@ -119,10 +147,20 @@
 };
 
 enum {
-    CAMERA_FACING_BACK = 0, /** The facing of the camera is opposite to that of
-                 * the screen. */
-    CAMERA_FACING_FRONT = 1 /** The facing of the camera is the same as that of
-                 * the screen. */
+    /** The facing of the camera is opposite to that of the screen. */
+    CAMERA_FACING_BACK = 0,
+    /** The facing of the camera is the same as that of the screen. */
+    CAMERA_FACING_FRONT = 1
+};
+
+enum {
+    /** Hardware face detection. It does not use much CPU. */
+    CAMERA_FACE_DETECTION_HW = 0,
+    /**
+     * Software face detection. It uses some CPU. Applications must use
+     * Camera.setPreviewTexture for preview in this mode.
+     */
+    CAMERA_FACE_DETECTION_SW = 1
 };
 
 __END_DECLS
diff --git a/init/init.c b/init/init.c
index 1e31cf9..a1d6be1 100755
--- a/init/init.c
+++ b/init/init.c
@@ -677,6 +677,8 @@
     } else {
         NOTICE("bootcharting ignored\n");
     }
+
+    return 0;
 }
 #endif
 
diff --git a/init/property_service.c b/init/property_service.c
index 046b120..77aa5e9 100644
--- a/init/property_service.c
+++ b/init/property_service.c
@@ -62,6 +62,7 @@
     { "net.gprs.",        AID_RADIO,    0 },
     { "net.ppp",          AID_RADIO,    0 },
     { "net.qmi",          AID_RADIO,    0 },
+    { "net.lte",          AID_RADIO,    0 },
     { "ril.",             AID_RADIO,    0 },
     { "gsm.",             AID_RADIO,    0 },
     { "persist.radio",    AID_RADIO,    0 },
diff --git a/toolbox/getevent.c b/toolbox/getevent.c
index c0ac94a..e3ab41a 100644
--- a/toolbox/getevent.c
+++ b/toolbox/getevent.c
@@ -25,8 +25,9 @@
     PRINT_VERSION           = 1U << 4,
     PRINT_POSSIBLE_EVENTS   = 1U << 5,
     PRINT_INPUT_PROPS       = 1U << 6,
+    PRINT_HID_DESCRIPTOR    = 1U << 7,
 
-    PRINT_ALL_INFO          = (1U << 7) - 1,
+    PRINT_ALL_INFO          = (1U << 8) - 1,
 
     PRINT_LABELS            = 1U << 16,
 };
@@ -254,6 +255,40 @@
     }
 }
 
+static void print_hid_descriptor(int bus, int vendor, int product)
+{
+    const char *dirname = "/sys/kernel/debug/hid";
+    char prefix[16];
+    DIR *dir;
+    struct dirent *de;
+    char filename[PATH_MAX];
+    FILE *file;
+    char line[2048];
+
+    snprintf(prefix, sizeof(prefix), "%04X:%04X:%04X.", bus, vendor, product);
+
+    dir = opendir(dirname);
+    if(dir == NULL)
+        return;
+    while((de = readdir(dir))) {
+        if (strstr(de->d_name, prefix) == de->d_name) {
+            snprintf(filename, sizeof(filename), "%s/%s/rdesc", dirname, de->d_name);
+
+            file = fopen(filename, "r");
+            if (file) {
+                printf("  HID descriptor: %s\n\n", de->d_name);
+                while (fgets(line, sizeof(line), file)) {
+                    fputs("    ", stdout);
+                    fputs(line, stdout);
+                }
+                fclose(file);
+                puts("");
+            }
+        }
+    }
+    closedir(dir);
+}
+
 static int open_device(const char *device, int print_flags)
 {
     int version;
@@ -335,6 +370,9 @@
     if(print_flags & PRINT_INPUT_PROPS) {
         print_input_props(fd);
     }
+    if(print_flags & PRINT_HID_DESCRIPTOR) {
+        print_hid_descriptor(id.bustype, id.vendor, id.product);
+    }
 
     ufds[nfds].fd = fd;
     ufds[nfds].events = POLLIN;
@@ -432,12 +470,13 @@
 
 static void usage(int argc, char *argv[])
 {
-    fprintf(stderr, "Usage: %s [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-p] [-i] [-l] [-q] [-c count] [-r] [device]\n", argv[0]);
+    fprintf(stderr, "Usage: %s [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]\n", argv[0]);
     fprintf(stderr, "    -t: show time stamps\n");
     fprintf(stderr, "    -n: don't print newlines\n");
     fprintf(stderr, "    -s: print switch states for given bits\n");
     fprintf(stderr, "    -S: print all switch states\n");
     fprintf(stderr, "    -v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64)\n");
+    fprintf(stderr, "    -d: show HID descriptor, if available\n");
     fprintf(stderr, "    -p: show possible events (errs, dev, name, pos. events)\n");
     fprintf(stderr, "    -i: show all device info and possible events\n");
     fprintf(stderr, "    -l: label event types and names in plain text\n");
@@ -469,7 +508,7 @@
 
     opterr = 0;
     do {
-        c = getopt(argc, argv, "tns:Sv::pilqc:rh");
+        c = getopt(argc, argv, "tns:Sv::dpilqc:rh");
         if (c == EOF)
             break;
         switch (c) {
@@ -496,8 +535,12 @@
                 print_flags |= PRINT_DEVICE | PRINT_DEVICE_NAME | PRINT_DEVICE_INFO | PRINT_VERSION;
             print_flags_set = 1;
             break;
+        case 'd':
+            print_flags |= PRINT_HID_DESCRIPTOR;
+            break;
         case 'p':
-            print_flags |= PRINT_DEVICE_ERRORS | PRINT_DEVICE | PRINT_DEVICE_NAME | PRINT_POSSIBLE_EVENTS;
+            print_flags |= PRINT_DEVICE_ERRORS | PRINT_DEVICE
+                    | PRINT_DEVICE_NAME | PRINT_POSSIBLE_EVENTS | PRINT_INPUT_PROPS;
             print_flags_set = 1;
             if(dont_block == -1)
                 dont_block = 1;