Merge "Define AR HAL API more clearly"
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/tv_input.h b/include/hardware/tv_input.h
index ed3fafb..3bb9862 100644
--- a/include/hardware/tv_input.h
+++ b/include/hardware/tv_input.h
@@ -33,14 +33,18 @@
  *
  * Version History:
  *
- * TV_INPUT_MODULE_API_VERSION_0_1:
- * Initial TV input hardware module API.
+ * TV_INPUT_DEVICE_API_VERSION_0_1:
+ * Initial TV input hardware device API.
+ *
+ * TV_INPUT_DEVICE_API_VERSION_0_2:
+ * Minor revision --- add video detection flag in stream configs.
  *
  */
 
 #define TV_INPUT_MODULE_API_VERSION_0_1  HARDWARE_MODULE_API_VERSION(0, 1)
 
 #define TV_INPUT_DEVICE_API_VERSION_0_1  HARDWARE_DEVICE_API_VERSION(0, 1)
+#define TV_INPUT_DEVICE_API_VERSION_0_2  HARDWARE_DEVICE_API_VERSION(0, 2)
 
 /*
  * The id of this module
@@ -164,7 +168,8 @@
      * port. the framework regards input devices with no available streams as
      * disconnected, so the implementation can generate this event with no
      * available streams to indicate that this device is disconnected, and vice
-     * versa.
+     * versa. In addition, streams have signal detection flag to denote if
+     * signal is detected for sure.
      */
     TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED = 3,
     /*
@@ -264,6 +269,33 @@
     uint32_t max_video_height;
 } tv_stream_config_t;
 
+enum {
+    /*
+     * Set if signal is detected on this stream. Note that even if this mask is
+     * unset it does not necessarily mean no signal --- it denotes that HAL is
+     * unsure of the signal status.
+     */
+    TV_STREAM_FLAG_MASK_SIGNAL_DETECTION = 0x1,
+};
+
+/*
+ * >= TV_INPUT_DEVICE_API_VERSION_0_2
+ *
+ * tv_stream_config_t extended in a way that allows extension without breaking
+ * binary compatibility
+ */
+typedef struct tv_stream_config_ext {
+    tv_stream_config_t config;
+
+    /*
+     * Flags to show the status of this stream. See TV_STREAM_FLAG_* for
+     * details.
+     */
+    uint32_t flags;
+
+    int32_t reserved[16 - 1];
+} tv_stream_config_ext_t;
+
 typedef struct buffer_producer_stream {
     /*
      * IN/OUT: Width / height of the stream. Client may request for specific
@@ -397,7 +429,22 @@
     int (*cancel_capture)(struct tv_input_device* dev, int device_id,
             int stream_id, uint32_t seq);
 
-    void* reserved[16];
+    /*
+     * get_stream_configurations_ext:
+     *
+     * Get stream configurations for a specific device. An input device may have
+     * multiple configurations.
+     *
+     * The configs object is guaranteed to be valid only until the next call to
+     * get_stream_configurations_ext() or STREAM_CONFIGURATIONS_CHANGED event.
+     *
+     * Return 0 on success.
+     */
+    int (*get_stream_configurations_ext)(const struct tv_input_device* dev,
+            int device_id, int* num_configurations,
+            const tv_stream_config_ext_t** configs);
+
+    void* reserved[16 - 1];
 } tv_input_device_t;
 
 __END_DECLS
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/tv_input/tv_input.cpp b/modules/tv_input/tv_input.cpp
index 114e80e..45e8388 100644
--- a/modules/tv_input/tv_input.cpp
+++ b/modules/tv_input/tv_input.cpp
@@ -37,18 +37,18 @@
         const char* name, struct hw_device_t** device);
 
 static struct hw_module_methods_t tv_input_module_methods = {
-    open: tv_input_device_open
+    .open = tv_input_device_open
 };
 
 tv_input_module_t HAL_MODULE_INFO_SYM = {
-    common: {
-        tag: HARDWARE_MODULE_TAG,
-        version_major: 0,
-        version_minor: 1,
-        id: TV_INPUT_HARDWARE_MODULE_ID,
-        name: "Sample TV input module",
-        author: "The Android Open Source Project",
-        methods: &tv_input_module_methods,
+    .common = {
+        .tag = HARDWARE_MODULE_TAG,
+        .version_major = 0,
+        .version_minor = 1,
+        .id = TV_INPUT_HARDWARE_MODULE_ID,
+        .name = "Sample TV input module",
+        .author = "The Android Open Source Project",
+        .methods = &tv_input_module_methods,
     }
 };
 
@@ -72,7 +72,8 @@
 }
 
 static int tv_input_get_stream_configurations(
-        const struct tv_input_device*, int, int*, const tv_stream_config_t**)
+        const struct tv_input_device*, int, int*,
+        const tv_stream_config_t**)
 {
     return -EINVAL;
 }
@@ -98,6 +99,13 @@
     return -EINVAL;
 }
 
+static int tv_input_get_stream_configurations_ext(
+        const struct tv_input_device*, int, int*,
+        const tv_stream_config_ext_t**)
+{
+    return -EINVAL;
+}
+
 /*****************************************************************************/
 
 static int tv_input_device_close(struct hw_device_t *dev)
@@ -134,6 +142,8 @@
         dev->device.close_stream = tv_input_close_stream;
         dev->device.request_capture = tv_input_request_capture;
         dev->device.cancel_capture = tv_input_cancel_capture;
+        dev->device.get_stream_configurations_ext =
+                tv_input_get_stream_configurations_ext;
 
         *device = &dev->device.common;
         status = 0;
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"
 
diff --git a/tests/camera2/camera2_utils.cpp b/tests/camera2/camera2_utils.cpp
index d962939..c63c32a 100644
--- a/tests/camera2/camera2_utils.cpp
+++ b/tests/camera2/camera2_utils.cpp
@@ -208,13 +208,13 @@
     return queue->dequeue(buffer, true);
 }
 
-int MetadataQueue::consumer_free(const camera2_request_queue_src_ops_t *q,
+int MetadataQueue::consumer_free(const camera2_request_queue_src_ops_t * /* q */,
         camera_metadata_t *old_buffer) {
     free_camera_metadata(old_buffer);
     return OK;
 }
 
-int MetadataQueue::producer_dequeue(const camera2_frame_queue_dst_ops_t *q,
+int MetadataQueue::producer_dequeue(const camera2_frame_queue_dst_ops_t * /* q */,
         size_t entries, size_t bytes,
         camera_metadata_t **buffer) {
     camera_metadata_t *new_buffer =
@@ -224,7 +224,7 @@
         return OK;
 }
 
-int MetadataQueue::producer_cancel(const camera2_frame_queue_dst_ops_t *q,
+int MetadataQueue::producer_cancel(const camera2_frame_queue_dst_ops_t * /* q */,
         camera_metadata_t *old_buffer) {
     free_camera_metadata(old_buffer);
     return OK;
@@ -386,12 +386,21 @@
         return res;
     }
 
-    res = native_window_set_buffers_geometry(mConsumerInterface.get(),
-            mWidth, mHeight, mFormat);
+    res = native_window_set_buffers_dimensions(mConsumerInterface.get(),
+            mWidth, mHeight);
     if (res != OK) {
-        ALOGE("%s: Unable to configure buffer geometry"
-                " %d x %d, format 0x%x for stream %d",
-                __FUNCTION__, mWidth, mHeight, mFormat, mId);
+        ALOGE("%s: Unable to configure buffer dimensions"
+                " %d x %d for stream %d",
+                __FUNCTION__, mWidth, mHeight, mId);
+        mState = CONNECTED;
+        return res;
+    }
+    res = native_window_set_buffers_format(mConsumerInterface.get(),
+            mFormat);
+    if (res != OK) {
+        ALOGE("%s: Unable to configure buffer format"
+                " 0x%x for stream %d",
+                __FUNCTION__, mFormat, mId);
         mState = CONNECTED;
         return res;
     }
@@ -454,8 +463,8 @@
         res = mConsumerInterface->cancelBuffer(mConsumerInterface.get(),
                 anwBuffers[i], -1);
     }
-    delete anwBuffers;
-    delete buffers;
+    delete[] anwBuffers;
+    delete[] buffers;
 
     return res;
 }
diff --git a/tests/hardware/struct-size.cpp b/tests/hardware/struct-size.cpp
index 4207ea8..acb9d2d 100644
--- a/tests/hardware/struct-size.cpp
+++ b/tests/hardware/struct-size.cpp
@@ -27,11 +27,11 @@
 
 template<size_t> static constexpr size_t CheckSizeHelper(size_t, size_t);
 
-template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t size64) {
+template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t /* size64 */) {
     return size32;
 }
 
-template<> constexpr size_t CheckSizeHelper<8>(size_t size32, size_t size64) {
+template<> constexpr size_t CheckSizeHelper<8>(size_t /* size32 */, size_t size64) {
     return size64;
 }
 
diff --git a/tests/hwc/Android.mk b/tests/hwc/Android.mk
index 4cae9eb..367f5f4 100644
--- a/tests/hwc/Android.mk
+++ b/tests/hwc/Android.mk
@@ -3,6 +3,7 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE := libcnativewindow 
 LOCAL_SRC_FILES := cnativewindow.c util.c
+LOCAL_CFLAGS := -Wno-unused-parameter
 include $(BUILD_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
diff --git a/tests/hwc/cnativewindow.c b/tests/hwc/cnativewindow.c
index 76f4564..5c16afb 100644
--- a/tests/hwc/cnativewindow.c
+++ b/tests/hwc/cnativewindow.c
@@ -337,8 +337,8 @@
 		TRACE("set scaling mode %d\n", va_arg(ap,int));
 		return 0;
 	case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: {
-		int w = va_arg(ap,int);
-		int h = va_arg(ap,int);
+		unsigned int w = va_arg(ap,unsigned int);
+		unsigned int h = va_arg(ap,unsigned int);
 		if ((w == win->width) && (h == win->height)) {
 			TRACE("set buffers dimensions %d x %d\n", w, h);
 			return 0;
@@ -377,7 +377,7 @@
 	unsigned i;
 	int r;
 	uint32_t configs[32];
-	uint32_t numconfigs = 32;
+	size_t numconfigs = 32;
 	int32_t values[8];
 
 	if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) {
diff --git a/tests/input/evdev/Android.mk b/tests/input/evdev/Android.mk
index 557acba..3aeb2f8 100644
--- a/tests/input/evdev/Android.mk
+++ b/tests/input/evdev/Android.mk
@@ -24,6 +24,11 @@
 LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
 LOCAL_CPPFLAGS += -std=c++14
 
+# TestHelpers uses mktemp. As the path is given to TempFile, we can't do too much
+# here (e.g., use mkdtemp first). At least races will lead to an early failure, as
+# mkfifo fails on existing files.
+LOCAL_CFLAGS += -Wno-deprecated-declarations
+
 LOCAL_MODULE := libinput_evdevtests
 LOCAL_MODULE_TAGS := tests
 
diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp
index e5e1dfd..6266d40 100644
--- a/tests/keymaster/keymaster_test.cpp
+++ b/tests/keymaster/keymaster_test.cpp
@@ -395,8 +395,8 @@
 TEST_P(KeymasterGenerateRSATest, GenerateKeyPair_RSA_Success) {
     keymaster_keypair_t key_type = TYPE_RSA;
     keymaster_rsa_keygen_params_t params = {
-            modulus_size: GetParam(),
-            public_exponent: RSA_F4,
+            .modulus_size = GetParam(),
+            .public_exponent = RSA_F4,
     };
 
     uint8_t* key_blob;
@@ -443,7 +443,7 @@
 TEST_P(KeymasterGenerateECTest, GenerateKeyPair_EC_Success) {
     keymaster_keypair_t key_type = TYPE_EC;
     keymaster_ec_keygen_params_t params = {
-            field_size: GetParam(),
+            .field_size = GetParam(),
     };
 
     uint8_t* key_blob;
@@ -864,8 +864,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     uint8_t* sig;
@@ -904,7 +904,7 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_ec_sign_params_t params = {
-            digest_type: DIGEST_NONE,
+            .digest_type = DIGEST_NONE,
     };
 
     uint8_t* sig;
@@ -952,8 +952,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     uint8_t* sig;
@@ -971,8 +971,8 @@
 
 TEST_F(KeymasterTest, SignData_RSA_Raw_NullKey_Failure) {
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     uint8_t* sig;
@@ -1002,8 +1002,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     uint8_t* sig;
@@ -1030,8 +1030,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     uint8_t* sig;
@@ -1061,8 +1061,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     UniqueReadOnlyBlob testData(TEST_SIGN_DATA_1, sizeof(TEST_SIGN_DATA_1));
@@ -1092,7 +1092,7 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_ec_sign_params_t params = {
-            digest_type: DIGEST_NONE,
+            .digest_type = DIGEST_NONE,
     };
 
     uint8_t* sig;
@@ -1129,8 +1129,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     ASSERT_EQ(-1,
@@ -1154,7 +1154,7 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_ec_sign_params_t params = {
-            digest_type: DIGEST_NONE,
+            .digest_type = DIGEST_NONE,
     };
 
     ASSERT_EQ(-1,
@@ -1166,8 +1166,8 @@
 
 TEST_F(KeymasterTest, VerifyData_RSA_Raw_NullKey_Failure) {
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     UniqueReadOnlyBlob testData(TEST_SIGN_DATA_1, sizeof(TEST_SIGN_DATA_1));
@@ -1194,8 +1194,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     UniqueReadOnlyBlob testSig(TEST_SIGN_RSA_SIGNATURE_1, sizeof(TEST_SIGN_RSA_SIGNATURE_1));
@@ -1222,8 +1222,8 @@
     UniqueKey key(&sDevice, key_blob, key_blob_length);
 
     keymaster_rsa_sign_params_t params = {
-            digest_type: DIGEST_NONE,
-            padding_type: PADDING_NONE,
+            .digest_type = DIGEST_NONE,
+            .padding_type = PADDING_NONE,
     };
 
     UniqueReadOnlyBlob testData(TEST_SIGN_DATA_1, sizeof(TEST_SIGN_DATA_1));
diff --git a/tests/nusensors/nusensors.cpp b/tests/nusensors/nusensors.cpp
index 3c8eae9..55b7785 100644
--- a/tests/nusensors/nusensors.cpp
+++ b/tests/nusensors/nusensors.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
 #include <string.h>
 #include <stdint.h>
 #include <string.h>
@@ -57,7 +58,7 @@
     return "ukn";
 }
 
-int main(int argc, char** argv)
+int main(int /* argc */, char** /* argv */)
 {
     int err;
     struct sensors_poll_device_t* device;
@@ -131,7 +132,7 @@
             const sensors_event_t& data = buffer[i];
 
             if (data.version != sizeof(sensors_event_t)) {
-                printf("incorrect event version (version=%d, expected=%d",
+                printf("incorrect event version (version=%d, expected=%zu",
                         data.version, sizeof(sensors_event_t));
                 break;
             }
@@ -144,7 +145,7 @@
                 case SENSOR_TYPE_GRAVITY:
                 case SENSOR_TYPE_LINEAR_ACCELERATION:
                 case SENSOR_TYPE_ROTATION_VECTOR:
-                    printf("sensor=%s, time=%lld, value=<%5.1f,%5.1f,%5.1f>\n",
+                    printf("sensor=%s, time=%" PRId64 ", value=<%5.1f,%5.1f,%5.1f>\n",
                             getSensorName(data.type),
                             data.timestamp,
                             data.data[0],
@@ -158,14 +159,14 @@
                 case SENSOR_TYPE_PROXIMITY:
                 case SENSOR_TYPE_RELATIVE_HUMIDITY:
                 case SENSOR_TYPE_AMBIENT_TEMPERATURE:
-                    printf("sensor=%s, time=%lld, value=%f\n",
+                    printf("sensor=%s, time=%" PRId64 ", value=%f\n",
                             getSensorName(data.type),
                             data.timestamp,
                             data.data[0]);
                     break;
 
                 default:
-                    printf("sensor=%d, time=%lld, value=<%f,%f,%f, ...>\n",
+                    printf("sensor=%d, time=% " PRId64 ", value=<%f,%f,%f, ...>\n",
                             data.type,
                             data.timestamp,
                             data.data[0],