Merge "tv_input: add signal detection flag to stream config"
diff --git a/include/hardware/boot_control.h b/include/hardware/boot_control.h
index 62d6918..36a867d 100644
--- a/include/hardware/boot_control.h
+++ b/include/hardware/boot_control.h
@@ -101,10 +101,11 @@
     int (*setSlotAsUnbootable)(struct boot_control_module *module, unsigned slot);
 
     /*
-     * (*isSlotBootable)() returns if the slot passed in parameter has
-     * booted successfully in the past.
-     * Returns 1 if the slot has booted successfully, 0 if it has not,
-     * and -errno on error.
+     * (*isSlotBootable)() returns if the slot passed in parameter is
+     * bootable. Note that slots can be made unbootable by both the
+     * bootloader and by the OS using setSlotAsUnbootable.
+     * Returns 1 if the slot is bootable, 0 if it's not, and -errno on
+     * error.
      */
     int (*isSlotBootable)(struct boot_control_module *module, unsigned slot);
 
@@ -116,7 +117,15 @@
      */
     const char* (*getSuffix)(struct boot_control_module *module, unsigned slot);
 
-    void* reserved[32];
+    /*
+     * (*isSlotMarkedSucessful)() returns if the slot passed in parameter has
+     * been marked as successful using markBootSuccessful.
+     * Returns 1 if the slot has been marked as successful, 0 if it's
+     * not the case, and -errno on error.
+     */
+    int (*isSlotMarkedSuccessful)(struct boot_control_module *module, unsigned slot);
+
+    void* reserved[31];
 } boot_control_module_t;
 
 
diff --git a/include/hardware/camera2.h b/include/hardware/camera2.h
index d920d4b..2b7add0 100644
--- a/include/hardware/camera2.h
+++ b/include/hardware/camera2.h
@@ -23,7 +23,10 @@
 /**
  * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ]
  *
- * DEPRECATED. New devices should use Camera HAL v3.2 or newer.
+ * NO LONGER SUPPORTED.  The camera service will no longer load HAL modules that
+ * contain HAL v2.0 or v2.1 devices.
+ *
+ * New devices should use Camera HAL v3.2 or newer.
  *
  * Supports the android.hardware.Camera API, and the android.hardware.camera2
  * API in legacy mode only.
diff --git a/include/hardware/camera_common.h b/include/hardware/camera_common.h
index 7658dd4..c74d7bb 100644
--- a/include/hardware/camera_common.h
+++ b/include/hardware/camera_common.h
@@ -140,17 +140,18 @@
  * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated
  * as CAMERA_DEVICE_API_VERSION_1_0
  */
-#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
-#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
-#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1)
+#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED
+#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED
+#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED
 #define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
 #define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1)
 #define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
 #define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3)
+#define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4)
 
-// Device version 3.3 is current, older HAL camera device versions are not
+// Device version 3.4 is current, older HAL camera device versions are not
 // recommended for new devices.
-#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3
+#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_4
 
 /**
  * Defined in /system/media/camera/include/system/camera_metadata.h
diff --git a/include/hardware/fingerprint.h b/include/hardware/fingerprint.h
index ac88c10..618ca7e 100644
--- a/include/hardware/fingerprint.h
+++ b/include/hardware/fingerprint.h
@@ -21,6 +21,7 @@
 
 #define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
 #define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
+#define FINGERPRINT_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
 #define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint"
 
 typedef enum fingerprint_msg_type {
@@ -28,7 +29,8 @@
     FINGERPRINT_ACQUIRED = 1,
     FINGERPRINT_TEMPLATE_ENROLLING = 3,
     FINGERPRINT_TEMPLATE_REMOVED = 4,
-    FINGERPRINT_AUTHENTICATED = 5
+    FINGERPRINT_AUTHENTICATED = 5,
+    FINGERPRINT_TEMPLATE_ENUMERATING = 6,
 } fingerprint_msg_type_t;
 
 /*
@@ -82,6 +84,11 @@
     uint64_t msg; /* Vendor specific message. Used for user guidance */
 } fingerprint_enroll_t;
 
+typedef struct fingerprint_enumerated {
+    fingerprint_finger_id_t finger;
+    uint32_t remaining_templates;
+} fingerprint_enumerated_t;
+
 typedef struct fingerprint_removed {
     fingerprint_finger_id_t finger;
 } fingerprint_removed_t;
@@ -100,6 +107,7 @@
     union {
         fingerprint_error_t error;
         fingerprint_enroll_t enroll;
+        fingerprint_enumerated_t enumerated;
         fingerprint_removed_t removed;
         fingerprint_acquired_t acquired;
         fingerprint_authenticated_t authenticated;
@@ -198,31 +206,24 @@
     /*
      * Enumerate all the fingerprint templates found in the directory set by
      * set_active_group()
-     * This is a synchronous call. The function takes:
-     * - A pointer to an array of fingerprint_finger_id_t.
-     * - The size of the array provided, in fingerprint_finger_id_t elements.
-     * Max_size is a bi-directional parameter and returns the actual number
-     * of elements copied to the caller supplied array.
-     * In the absence of errors the function returns the total number of templates
-     * in the user directory.
-     * If the caller has no good guess on the size of the array he should call this
-     * function witn *max_size == 0 and use the return value for the array allocation.
-     * The caller of this function has a complete list of the templates when *max_size
-     * is the same as the function return.
+     * For each template found notify() will be called with:
+     * fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENUMERATED
+     * fingerprint_msg.data.enumerated.finger indicating a template id
+     * fingerprint_msg.data.enumerated.remaining_templates indicating how many more
+     * enumeration messages to expect.
      *
-     * Function return: Total number of fingerprint templates in the current storage directory.
+     * Function return: 0 if enumerate request is accepted
      *                  or a negative number in case of error, generally from the errno.h set.
      */
-    int (*enumerate)(struct fingerprint_device *dev, fingerprint_finger_id_t *results,
-        uint32_t *max_size);
+    int (*enumerate)(struct fingerprint_device *dev);
 
     /*
      * Fingerprint remove request:
      * Deletes a fingerprint template.
-     * Works only within a path set by set_active_group().
+     * Works only within the path set by set_active_group().
      * notify() will be called with details on the template deleted.
      * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and
-     * fingerprint_msg.data.removed.id indicating the template id removed.
+     * fingerprint_msg.data.removed.finger indicating the template id removed.
      *
      * Function return: 0 if fingerprint template(s) can be successfully deleted
      *                  or a negative number in case of error, generally from the errno.h set.
diff --git a/include/hardware/lights.h b/include/hardware/lights.h
index 2cf5519..b426caf 100644
--- a/include/hardware/lights.h
+++ b/include/hardware/lights.h
@@ -30,6 +30,28 @@
  */
 #define LIGHTS_HARDWARE_MODULE_ID "lights"
 
+/**
+ * Header file version.
+ */
+#define LIGHTS_HEADER_VERSION   1
+
+/**
+ * Device API version 0.0-1.0
+ *
+ * Base version for the device API in the lights HAL: all versions less than
+ * 2.0 are treated as being this version.
+ */
+#define LIGHTS_DEVICE_API_VERSION_1_0   HARDWARE_DEVICE_API_VERSION_2(1, 0, LIGHTS_HEADER_VERSION)
+
+/**
+ * Device API version 2.0
+ *
+ * Devices reporting this version or higher may additionally support the
+ * following modes:
+ * - BRIGHTNESS_MODE_LOW_PERSISTENCE
+ */
+#define LIGHTS_DEVICE_API_VERSION_2_0   HARDWARE_DEVICE_API_VERSION_2(2, 0, LIGHTS_HEADER_VERSION)
+
 /*
  * These light IDs correspond to logical lights, not physical.
  * So for example, if your INDICATOR light is in line with your
@@ -82,6 +104,34 @@
 #define BRIGHTNESS_MODE_SENSOR      1
 
 /**
+ * Use a low-persistence mode for display backlights.
+ *
+ * When set, the device driver must switch to a mode optimized for low display
+ * persistence that is intended to be used when the device is being treated as a
+ * head mounted display (HMD).  The actual display brightness in this mode is
+ * implementation dependent, and any value set for color in light_state may be
+ * overriden by the HAL implementation.
+ *
+ * For an optimal HMD viewing experience, the display should meet the following
+ * criteria in this mode:
+ * - Less than 2ms display persistence.
+ * - Any "smart panel" or other frame buffering options that increase display
+ *   latency are disabled.
+ * - Display brightness is set so that the display is still visible to the user
+ *   under normal indoor lighting.
+ *
+ * This mode will only be used with light devices of type LIGHT_ID_BACKLIGHT,
+ * and will only be called by the Android framework for light_device_t
+ * implementations that report a version >= 2.0 in their hw_device_t common
+ * fields.  If the device version is >= 2.0 and this mode is unsupported, calling
+ * set_light with this mode must return the negative error code -ENOSYS (-38)
+ * without altering any settings.
+ *
+ * Available only for version >= LIGHTS_DEVICE_API_VERSION_2_0
+ */
+#define BRIGHTNESS_MODE_LOW_PERSISTENCE 2
+
+/**
  * The parameters that can be set for a given light.
  *
  * Not all lights must support all parameters.  If you
diff --git a/include/hardware/vehicle.h b/include/hardware/vehicle.h
index 267a910..22c69bb 100644
--- a/include/hardware/vehicle.h
+++ b/include/hardware/vehicle.h
@@ -268,6 +268,14 @@
  */
 #define VEHICLE_PROPERTY_HVAC_FAN_DIRECTION                         (0x00000501)
 
+/*
+ * Bit flags for fan direction
+ */
+enum vehicle_hvac_fan_direction_flags {
+    VEHICLE_HVAC_FAN_DIRECTION_FACE_FLAG    = 0x1,
+    VEHICLE_HVAC_FAN_DIRECTION_FLOOR_FLAG   = 0x2
+};
+
 /**
  * HVAC current temperature.
  * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT
@@ -305,6 +313,42 @@
 #define VEHICLE_PROPERTY_HVAC_AC_ON                                 (0x00000505)
 
 /**
+ * On/off max AC
+ * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @data_member hvac.max_ac_on
+ */
+#define VEHICLE_PROPERTY_HVAC_MAX_AC_ON                             (0x00000506)
+
+/**
+ * On/off max defrost
+ * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @data_member hvac.max_defrost_on
+ */
+#define VEHICLE_PROPERTY_HVAC_MAX_DEFROST_ON                        (0x00000507)
+
+/**
+ * On/off re-circulation
+ * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @data_member hvac.max_recirc_on
+ */
+#define VEHICLE_PROPERTY_HVAC_RECIRC_ON                             (0x00000508)
+
+/**
+ * On/off dual
+ * @value_type VEHICLE_VALUE_TYPE_BOOLEAN
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @data_member hvac.dual_on
+ */
+#define VEHICLE_PROPERTY_HVAC_DUAL_ON                               (0x00000509)
+
+/**
  * Outside temperature
  * @value_type VEHICLE_VALUE_TYPE_FLOAT
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
@@ -353,7 +397,7 @@
  * per stream characteristics and global characteristics.
  *
  * Focus request (get of this property) will take the following form in int32_vec4:
- *   int32_array[0]: vehicle_audio_focus_request_type
+ *   int32_array[0]: vehicle_audio_focus_request type
  *   int32_array[1]: bit flags of streams requested by this focus request. There can be up to
  *                   32 streams.
  *   int32_array[2]: External focus state flags. For request, only flag like
@@ -366,7 +410,7 @@
  * android before this focus request should not be affected by focus request.
  *
  * Focus response (set and subscription callback for this property) will take the following form:
- *   int32_array[0]: vehicle_audio_focus_state_type
+ *   int32_array[0]: vehicle_audio_focus_state type
  *   int32_array[1]: bit flags of streams allowed.
  *   int32_array[2]: External focus state: bit flags of currently active audio focus in car
  *                   side (outside Android). Active audio focus does not necessarily mean currently
@@ -1242,6 +1286,14 @@
 
 typedef vehicle_zoned_boolean_t vehicle_hvac_ac_on_t;
 
+typedef vehicle_boolean_t vehicle_hvac_max_ac_on_t;
+
+typedef vehicle_boolean_t vehicle_hvac_max_defrost_on_t;
+
+typedef vehicle_boolean_t vehicle_hvac_recirc_on_t;
+
+typedef vehicle_boolean_t vehicle_hvac_dual_on_t;
+
 typedef struct vehicle_hvac {
     /**
      * Define one structure for each possible HVAC property.
@@ -1258,6 +1310,10 @@
         vehicle_hvac_fan_speed_t fan_speed;
         vehicle_hvac_fan_direction_t fan_direction;
         vehicle_hvac_ac_on_t ac_on;
+        vehicle_hvac_max_ac_on_t max_ac_on;
+        vehicle_hvac_max_defrost_on_t max_defrost_on;
+        vehicle_hvac_recirc_on_t recirc_on;
+        vehicle_hvac_dual_on_t dual_on;
 
         vehicle_hvac_zone_temperature_t temperature_current;
         vehicle_hvac_zone_temperature_t temperature_set;
@@ -1452,7 +1508,8 @@
      * Get a vehicle property value immediately. data should be allocated
      * properly.
      * The caller of the API OWNS the data field.
-     * Caller will only set data->prop and HAL implementation needs to fill all entries properly.
+     * Caller will set data->prop, data->value_type, and optionally zone value for zoned property.
+     * But HAL implementation needs to fill all entries properly when returning.
      * For pointer type, HAL implementation should allocate necessary memory and caller is
      * responsible for freeing memory for the pointer.
      * For VEHICLE_PROP_CHANGE_MODE_STATIC type of property, get should return the same value
diff --git a/modules/vehicle/vehicle.c b/modules/vehicle/vehicle.c
index 69bfad3..7e92ddd 100644
--- a/modules/vehicle/vehicle.c
+++ b/modules/vehicle/vehicle.c
@@ -18,7 +18,10 @@
 #define LOG_NDEBUG 1
 #define RADIO_PRESET_NUM 6
 
+#define UNUSED __attribute__((__unused__))
+
 #include <errno.h>
+#include <inttypes.h>
 #include <malloc.h>
 #include <pthread.h>
 #include <stdint.h>
@@ -120,7 +123,7 @@
 };
 
 vehicle_prop_config_t* find_config(int prop) {
-    int i;
+    unsigned int i;
     for (i = 0; i < sizeof(CONFIGS) / sizeof(vehicle_prop_config_t); i++) {
         if (CONFIGS[i].prop == prop) {
             return &CONFIGS[i];
@@ -140,7 +143,7 @@
     return 0;
 }
 
-static vehicle_prop_config_t const * vdev_list_properties(vehicle_hw_device_t* device,
+static vehicle_prop_config_t const * vdev_list_properties(vehicle_hw_device_t* device UNUSED,
         int* num_properties) {
     ALOGD("vdev_list_properties.");
 
@@ -180,7 +183,7 @@
     return 0;
 }
 
-static int vdev_get(vehicle_hw_device_t* device, vehicle_prop_value_t* data) {
+static int vdev_get(vehicle_hw_device_t* device UNUSED, vehicle_prop_value_t* data) {
     ALOGD("vdev_get.");
     //TODO all data supporting read should support get
     if (!data) {
@@ -237,12 +240,12 @@
             memset(&(data->value), 0, sizeof(data->value));
             break;
     }
-    ALOGI("vdev_get, type 0x%x, time %ld, value_type %d", data->prop, data->timestamp,
+    ALOGI("vdev_get, type 0x%x, time %" PRId64 ", value_type %d", data->prop, data->timestamp,
             data->value_type);
     return 0;
 }
 
-static int vdev_set(vehicle_hw_device_t* device, const vehicle_prop_value_t* data) {
+static int vdev_set(vehicle_hw_device_t* device UNUSED, const vehicle_prop_value_t* data) {
     ALOGD("vdev_set.");
     // Just print what data will be setting here.
     ALOGD("Setting property %d with value type %d\n", data->prop, data->value_type);
@@ -289,8 +292,8 @@
     return 0;
 }
 
-void print_subscribe_info(vehicle_device_impl_t* impl) {
-    int i;
+void print_subscribe_info(vehicle_device_impl_t* impl UNUSED) {
+    unsigned int i;
     for (i = 0; i < sizeof(CONFIGS) / sizeof(vehicle_prop_config_t); i++) {
         subscription_t* sub = (subscription_t*)CONFIGS[i].hal_data;
         if (sub != NULL) {
@@ -457,7 +460,7 @@
         return 0;
     }
     int ret_code = pthread_create(
-        &sub->thread, NULL, fake_event_thread, sub);
+                                  &sub->thread, NULL, (void *(*)(void*))fake_event_thread, sub);
     print_subscribe_info(impl);
     pthread_mutex_unlock(&lock_);
     return 0;
@@ -509,7 +512,7 @@
  * informations in hw_device_t structure. After calling open() the client should
  * use the hw_device_t to execute any Vehicle HAL device specific functions.
  */
-static int vdev_open(const hw_module_t* module, const char* __unused name,
+static int vdev_open(const hw_module_t* module, const char* name UNUSED,
                      hw_device_t** device) {
     ALOGD("vdev_open");
 
diff --git a/tests/camera2/CameraModuleFixture.h b/tests/camera2/CameraModuleFixture.h
index 3a2df69..661c693 100644
--- a/tests/camera2/CameraModuleFixture.h
+++ b/tests/camera2/CameraModuleFixture.h
@@ -23,7 +23,6 @@
 #include "hardware/camera2.h"
 
 #include <common/CameraModule.h>
-#include <device2/Camera2Device.h>
 #include <device3/Camera3Device.h>
 
 #include "camera2_utils.h"
@@ -92,14 +91,10 @@
         struct camera_info info;
         ASSERT_EQ(OK, mModule->getCameraInfo(cameraID, &info));
 
-        ASSERT_GE((int)info.device_version, CAMERA_DEVICE_API_VERSION_2_0) <<
+        ASSERT_GE((int)info.device_version, CAMERA_DEVICE_API_VERSION_3_0) <<
                 "Device version too old for camera " << cameraID << ". Version: " <<
                 info.device_version;
         switch(info.device_version) {
-            case CAMERA_DEVICE_API_VERSION_2_0:
-            case CAMERA_DEVICE_API_VERSION_2_1:
-                *device = new Camera2Device(cameraID);
-                break;
             case CAMERA_DEVICE_API_VERSION_3_0:
             case CAMERA_DEVICE_API_VERSION_3_1:
             case CAMERA_DEVICE_API_VERSION_3_2:
diff --git a/tests/camera2/CameraMultiStreamTests.cpp b/tests/camera2/CameraMultiStreamTests.cpp
index 3e29ad6..eb64db1 100644
--- a/tests/camera2/CameraMultiStreamTests.cpp
+++ b/tests/camera2/CameraMultiStreamTests.cpp
@@ -495,9 +495,6 @@
         jpegData = availableJpegSizes.data.i32;
         jpegCount = availableJpegSizes.count;
     } else {
-        const int32_t *implDefResolutions;
-        size_t   implDefResolutionsCount;
-
         getResolutionList(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, &implDefData, &implDefCount);
         ASSERT_NE(0u, implDefCount)
             << "Missing implementation defined sizes";
diff --git a/tests/camera2/CameraStreamFixture.h b/tests/camera2/CameraStreamFixture.h
index fc5fb36..bf7fb42 100644
--- a/tests/camera2/CameraStreamFixture.h
+++ b/tests/camera2/CameraStreamFixture.h
@@ -186,7 +186,6 @@
     void getResolutionList(int32_t format,
             const int32_t **list,
             size_t *count) {
-        status_t res;
         ALOGV("Getting resolutions for format %x", format);
         if (getDeviceVersion() < CAMERA_DEVICE_API_VERSION_3_2) {
             return;
diff --git a/tests/camera2/CameraStreamTests.cpp b/tests/camera2/CameraStreamTests.cpp
index a3b8c47..de9ae8a 100644
--- a/tests/camera2/CameraStreamTests.cpp
+++ b/tests/camera2/CameraStreamTests.cpp
@@ -29,8 +29,6 @@
 #include <gui/CpuConsumer.h>
 #include <gui/Surface.h>
 
-#include <device2/Camera2Device.h>
-
 #include "CameraStreamFixture.h"
 #include "TestExtensions.h"