Merge "power: Adds a new power hint POWER_HINT_SUSTAINED_PERFORMANCE"
diff --git a/include/hardware/activity_recognition.h b/include/hardware/activity_recognition.h
index 8f99459..2200723 100644
--- a/include/hardware/activity_recognition.h
+++ b/include/hardware/activity_recognition.h
@@ -179,9 +179,27 @@
      * independently of the other. The HAL implementation needs to keep track of which pairs are
      * currently active and needs to detect only those pairs.
      *
+     * At the first detection after this function gets called, the hardware should know whether the
+     * user is in the activity.
+     * - If event_type is ACTIVITY_EVENT_ENTER and the user is in the activity, then an
+     *   (ACTIVITY_EVENT_ENTER, activity) event should be added to the FIFO.
+     * - If event_type is ACTIVITY_EVENT_EXIT and the user is not in the activity, then an
+     *   (ACTIVITY_EVENT_EXIT, activity) event should be added to the FIFO.
+     * For example, suppose get_supported_activities_list contains on_bicyle and running, and the
+     * user is biking. Consider the following four calls that could happen in any order.
+     * - When enable_activity_event(on_bicycle, ACTIVITY_EVENT_ENTER) is called,
+     *   (ACTIVITY_EVENT_ENTER, on_bicycle) should be added to the FIFO.
+     * - When enable_activity_event(on_bicycle, ACTIVITY_EVENT_EXIT) is called, nothing should be
+     *   added to the FIFO.
+     * - When enable_activity_event(running, ACTIVITY_EVENT_ENTER) is called, nothing should be
+     *   added to the FIFO.
+     * - When enable_activity_event(running, ACTIVITY_EVENT_EXIT) is called,
+     *   (ACTIVITY_EVENT_EXIT, running) should be added to the FIFO.
+     *
      * activity_handle - Index of the specific activity that needs to be detected in the list
      *                   returned by get_supported_activities_list.
-     * event_type - Specific transition of the activity that needs to be detected.
+     * event_type - Specific transition of the activity that needs to be detected. It should be
+     *              either ACTIVITY_EVENT_ENTER or ACTIVITY_EVENT_EXIT.
      * max_batch_report_latency_ns - a transition can be delayed by at most
      *                               “max_batch_report_latency” nanoseconds.
      * Return 0 on success, negative errno code otherwise.
@@ -190,7 +208,8 @@
             uint32_t activity_handle, uint32_t event_type, int64_t max_batch_report_latency_ns);
 
     /*
-     * Disables detection of a specific (activity, event_type) pair.
+     * Disables detection of a specific (activity, event_type) pair. All the (activity, event_type)
+     * events in the FIFO are discarded.
      */
     int (*disable_activity_event)(const struct activity_recognition_device* dev,
             uint32_t activity_handle, uint32_t event_type);
@@ -199,6 +218,7 @@
      * Flush all the batch FIFOs. Report all the activities that were stored in the FIFO so far as
      * if max_batch_report_latency had expired. This shouldn't change the latency in any way. Add
      * a flush_complete_event to indicate the end of the FIFO after all events are delivered.
+     * activity_callback should be called before this function returns successfully.
      * See ACTIVITY_EVENT_FLUSH_COMPLETE for more details.
      * Return 0 on success, negative errno code otherwise.
      */
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 2389c09..29b695c 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -144,6 +144,9 @@
 /* Set the HW synchronization source for an output stream. */
 #define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync"
 
+/* Enable mono audio playback if 1, else should be 0. */
+#define AUDIO_PARAMETER_MONO_OUTPUT "mono_output"
+
 /**
  * audio codec parameters
  */
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 3427213..93aa8e5 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -107,6 +107,12 @@
     uint64_t energy_used;   /* a product of mA, V and ms */
 } __attribute__((packed))bt_activity_energy_info;
 
+typedef struct {
+    int32_t app_uid;
+    uint64_t tx_bytes;
+    uint64_t rx_bytes;
+} __attribute__((packed))bt_uid_traffic_t;
+
 /** Bluetooth Adapter Discovery state */
 typedef enum {
     BT_DISCOVERY_STOPPED,
@@ -256,6 +262,19 @@
     void *val;
 } bt_property_t;
 
+/** Bluetooth Out Of Band data for bonding */
+typedef struct
+{
+   uint8_t c192[16]; /* Simple Pairing Hash C-192 */
+   uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
+   uint8_t c256[16]; /* Simple Pairing Hash C-256 */
+   uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
+   uint8_t sm_tk[16]; /* Security Manager TK Value */
+   uint8_t le_sc_c[16]; /* LE Secure Connections Random Value */
+   uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
+} bt_out_of_band_data_t;
+
+
 
 /** Bluetooth Device Type */
 typedef enum {
@@ -365,8 +384,12 @@
  * If the ctrl_state value is 0, it means the API call failed
  * Time values-In milliseconds as returned by the controller
  * Energy used-Value as returned by the controller
- * Status-Provides the status of the read_energy_info API call */
-typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
+ * Status-Provides the status of the read_energy_info API call
+ * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
+ * app_uid set to -1.
+ */
+typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
+                                     bt_uid_traffic_t *uid_data);
 
 /** TODO: Add callbacks for Link Up/Down and other generic
   *  notifications/callbacks */
@@ -485,6 +508,10 @@
     /** Create Bluetooth Bonding */
     int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
 
+    /** Create Bluetooth Bond using out of band data */
+    int (*create_bond_out_of_band)(const bt_bdaddr_t *bd_addr, int transport,
+                                   const bt_out_of_band_data_t *oob_data);
+
     /** Remove Bond */
     int (*remove_bond)(const bt_bdaddr_t *bd_addr);
 
@@ -540,8 +567,10 @@
     /**
      * Native support for dumpsys function
      * Function is synchronous and |fd| is owned by caller.
+     * |arguments| are arguments which may affect the output, encoded as
+     * UTF-8 strings.
      */
-    void (*dump)(int fd);
+    void (*dump)(int fd, const char **arguments);
 
     /**
      * Clear /data/misc/bt_config.conf and erase all stored connections
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/bt_av.h b/include/hardware/bt_av.h
index 5252a17..5f7601e 100644
--- a/include/hardware/bt_av.h
+++ b/include/hardware/bt_av.h
@@ -38,13 +38,13 @@
 /** Callback for connection state change.
  *  state will have one of the values from btav_connection_state_t
  */
-typedef void (* btav_connection_state_callback)(btav_connection_state_t state, 
+typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
                                                     bt_bdaddr_t *bd_addr);
 
 /** Callback for audiopath state change.
  *  state will have one of the values from btav_audio_state_t
  */
-typedef void (* btav_audio_state_callback)(btav_audio_state_t state, 
+typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
                                                bt_bdaddr_t *bd_addr);
 
 /** Callback for audio configuration change.
@@ -57,6 +57,13 @@
                                                 uint32_t sample_rate,
                                                 uint8_t channel_count);
 
+/*
+ * Callback for audio focus request to be used only in
+ * case of A2DP Sink. This is required because we are using
+ * AudioTrack approach for audio data rendering.
+ */
+typedef void (* btav_audio_focus_request_callback)(bt_bdaddr_t *bd_addr);
+
 /** BT-AV callback structure. */
 typedef struct {
     /** set to sizeof(btav_callbacks_t) */
@@ -64,17 +71,18 @@
     btav_connection_state_callback  connection_state_cb;
     btav_audio_state_callback audio_state_cb;
     btav_audio_config_callback audio_config_cb;
+    btav_audio_focus_request_callback audio_focus_request_cb;
 } btav_callbacks_t;
 
-/** 
+/**
  * NOTE:
  *
  * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
- *    shall be handled internally via uinput 
+ *    shall be handled internally via uinput
  *
  * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
  *    android_audio_hw library and the Bluetooth stack.
- * 
+ *
  */
 /** Represents the standard BT-AV interface.
  *  Used for both the A2DP source and sink interfaces.
@@ -96,6 +104,9 @@
 
     /** Closes the interface. */
     void  (*cleanup)( void );
+
+    /** Sends Audio Focus State. */
+    void  (*audio_focus_state)( int focus_state );
 } btav_interface_t;
 
 __END_DECLS
diff --git a/include/hardware/bt_rc.h b/include/hardware/bt_rc.h
index c565c48..1e2c293 100644
--- a/include/hardware/bt_rc.h
+++ b/include/hardware/bt_rc.h
@@ -103,6 +103,36 @@
     uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
 } btrc_player_settings_t;
 
+typedef struct {
+    uint8_t   val;
+    uint16_t  charset_id;
+    uint16_t  str_len;
+    uint8_t   *p_str;
+} btrc_player_app_ext_attr_val_t;
+
+typedef struct {
+    uint8_t   attr_id;
+    uint16_t  charset_id;
+    uint16_t  str_len;
+    uint8_t   *p_str;
+    uint8_t   num_val;
+    btrc_player_app_ext_attr_val_t ext_attr_val[BTRC_MAX_APP_ATTR_SIZE];
+} btrc_player_app_ext_attr_t;
+
+typedef struct {
+    uint8_t attr_id;
+    uint8_t num_val;
+    uint8_t attr_val[BTRC_MAX_APP_ATTR_SIZE];
+} btrc_player_app_attr_t;
+
+typedef struct {
+    uint32_t start_item;
+    uint32_t end_item;
+    uint32_t size;
+    uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE];
+    uint8_t  attr_count;
+} btrc_getfolderitem_t;
+
 typedef union
 {
     btrc_play_status_t play_status;
@@ -264,14 +294,53 @@
 
 typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
 
+typedef void (* btrc_groupnavigation_rsp_callback) (int id, int key_state);
+
 typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
 
+typedef void (* btrc_ctrl_getrcfeatures_callback) (bt_bdaddr_t *bd_addr, int features);
+
+typedef void (* btrc_ctrl_setabsvol_cmd_callback) (bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label);
+
+typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (bt_bdaddr_t *bd_addr, uint8_t label);
+
+typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (bt_bdaddr_t *bd_addr,
+                                                                          uint8_t accepted);
+
+typedef void (* btrc_ctrl_playerapplicationsetting_callback)(bt_bdaddr_t *bd_addr,
+                                                                 uint8_t num_attr,
+                                                                 btrc_player_app_attr_t *app_attrs,
+                                                                 uint8_t num_ext_attr,
+                                                                 btrc_player_app_ext_attr_t *ext_attrs);
+
+typedef void (* btrc_ctrl_playerapplicationsetting_changed_callback)(bt_bdaddr_t *bd_addr,
+                                                                          btrc_player_settings_t *p_vals);
+
+typedef void (* btrc_ctrl_track_changed_callback)(bt_bdaddr_t *bd_addr, uint8_t num_attr,
+                                                     btrc_element_attr_val_t *p_attrs);
+
+typedef void (* btrc_ctrl_play_position_changed_callback)(bt_bdaddr_t *bd_addr,
+                                                              uint32_t song_len, uint32_t song_pos);
+
+typedef void (* btrc_ctrl_play_status_changed_callback)(bt_bdaddr_t *bd_addr,
+                                                            btrc_play_status_t play_status);
+
 /** BT-RC Controller callback structure. */
 typedef struct {
     /** set to sizeof(BtRcCallbacks) */
     size_t      size;
-    btrc_passthrough_rsp_callback               passthrough_rsp_cb;
-    btrc_connection_state_callback              connection_state_cb;
+    btrc_passthrough_rsp_callback                               passthrough_rsp_cb;
+    btrc_groupnavigation_rsp_callback                           groupnavigation_rsp_cb;
+    btrc_connection_state_callback                              connection_state_cb;
+    btrc_ctrl_getrcfeatures_callback                            getrcfeatures_cb;
+    btrc_ctrl_setplayerapplicationsetting_rsp_callback          setplayerappsetting_rsp_cb;
+    btrc_ctrl_playerapplicationsetting_callback                 playerapplicationsetting_cb;
+    btrc_ctrl_playerapplicationsetting_changed_callback         playerapplicationsetting_changed_cb;
+    btrc_ctrl_setabsvol_cmd_callback                            setabsvol_cmd_cb;
+    btrc_ctrl_registernotification_abs_vol_callback             registernotification_absvol_cb;
+    btrc_ctrl_track_changed_callback                            track_changed_cb;
+    btrc_ctrl_play_position_changed_callback                    play_position_changed_cb;
+    btrc_ctrl_play_status_changed_callback                      play_status_changed_cb;
 } btrc_ctrl_callbacks_t;
 
 /** Represents the standard BT-RC AVRCP Controller interface. */
@@ -285,7 +354,23 @@
     bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks );
 
     /** send pass through command to target */
-    bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state );
+    bt_status_t (*send_pass_through_cmd) (bt_bdaddr_t *bd_addr, uint8_t key_code,
+            uint8_t key_state );
+
+    /** send group navigation command to target */
+    bt_status_t (*send_group_navigation_cmd) (bt_bdaddr_t *bd_addr, uint8_t key_code,
+            uint8_t key_state );
+
+    /** send command to set player applicaiton setting attributes to target */
+    bt_status_t (*set_player_app_setting_cmd) (bt_bdaddr_t *bd_addr, uint8_t num_attrib,
+            uint8_t* attrib_ids, uint8_t* attrib_vals);
+
+    /** send rsp to set_abs_vol received from target */
+    bt_status_t (*set_volume_rsp) (bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label);
+
+    /** send notificaiton rsp for abs vol to target */
+    bt_status_t (*register_abs_vol_rsp) (bt_bdaddr_t *bd_addr, btrc_notification_type_t rsp_type,
+            uint8_t abs_vol, uint8_t label);
 
     /** Closes the interface. */
     void  (*cleanup)( void );
diff --git a/include/hardware/bt_sock.h b/include/hardware/bt_sock.h
index 5d206d7..8d1a9e0 100644
--- a/include/hardware/bt_sock.h
+++ b/include/hardware/bt_sock.h
@@ -56,16 +56,20 @@
      * If neither a UUID nor a channel is provided, a channel will be allocated
      * and a service record can be created providing the channel number to
      * create_sdp_record(...) in bt_sdp.
+     * The callingUid is the UID of the application which is requesting the socket. This is
+     * used for traffic accounting purposes.
      */
     bt_status_t (*listen)(btsock_type_t type, const char* service_name,
-            const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
+            const uint8_t* service_uuid, int channel, int* sock_fd, int flags, int callingUid);
 
     /**
      * Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which
-     * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
+     * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected.
+     * The callingUid is the UID of the application which is requesting the socket. This is
+     * used for traffic accounting purposes.
      */
     bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid,
-            int channel, int* sock_fd, int flags);
+            int channel, int* sock_fd, int flags, int callingUid);
 } btsock_interface_t;
 
 __END_DECLS
diff --git a/include/hardware/camera_common.h b/include/hardware/camera_common.h
index 42e4e20..c74d7bb 100644
--- a/include/hardware/camera_common.h
+++ b/include/hardware/camera_common.h
@@ -147,10 +147,11 @@
 #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/context_hub.h b/include/hardware/context_hub.h
new file mode 100644
index 0000000..01d2377
--- /dev/null
+++ b/include/hardware/context_hub.h
@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2016 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 CONTEXT_HUB_H
+#define CONTEXT_HUB_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <hardware/hardware.h>
+
+/**
+ * This header file defines the interface of a Context Hub Implementation to
+ * the Android service exposing Context hub capabilities to applications.
+ * The Context hub is expected to a low power compute domain with the following
+ * defining charecteristics -
+ *
+ *    1) Access to sensors like accelerometer, gyroscope, magenetometer.
+ *    2) Access to radios like GPS, Wifi, Bluetooth etc.
+ *    3) Access to low power audio sensing.
+ *
+ * Implementations of this HAL can add additional sensors not defined by the
+ * Android API. Such information sources shall be private to the implementation.
+ *
+ * The Context Hub HAL exposes the construct of code download. A piece of binary
+ * code can be pushed to the context hub through the supported APIs.
+ *
+ * This version of the HAL designs in the possibility of multiple context hubs.
+ */
+
+__BEGIN_DECLS
+
+/*****************************************************************************/
+
+#define CONTEXT_HUB_HEADER_VERSION          1
+#define CONTEXT_HUB_DEVICE_API_VERSION_1_0  HARDWARE_DEVICE_API_VERSION_2(1, 0, CONTEXT_HUB_HEADER_VERSION)
+
+/**
+ * The id of this module
+ */
+#define CONTEXT_HUB_MODULE_ID         "context_hub"
+
+/**
+ * Name of the device to open
+ */
+#define CONTEXT_HUB_HARDWARE_POLL     "ctxt_poll"
+
+/**
+ * Memory types for code upload. Device-specific. At least HUB_MEM_TYPE_MAIN must be supported
+ */
+#define HUB_MEM_TYPE_MAIN             0
+#define HUB_MEM_TYPE_SECONDARY        1
+#define HUB_MEM_TYPE_TCM              2
+
+
+#define HUB_MEM_TYPE_FIRST_VENDOR     0x80000000ul
+
+
+/**
+ * Other memory types (likely not writeable, informational only)
+ */
+#define HUB_MEM_TYPE_BOOTLOADER       0xfffffffful
+#define HUB_MEM_TYPE_OS               0xfffffffeul
+#define HUB_MEM_TYPE_EEDATA           0xfffffffdul
+#define HUB_MEM_TYPE_RAM              0xfffffffcul
+
+/**
+ * Types of memory blocks on the context hub
+ * */
+#define MEM_FLAG_READ  0x1  // Memory can be written to
+#define MEM_FLAG_WRITE 0x2  // Memory can be written to
+#define MEM_FLAG_EXEC  0x4  // Memory can be executed from
+
+/**
+ * The following structure defines each memory block in detail
+ */
+struct mem_range_t {
+    uint32_t total_bytes;
+    uint32_t free_bytes;
+    uint32_t type;        // HUB_MEM_TYPE_*
+    uint32_t mem_flags;   // MEM_FLAG_*
+};
+
+
+/**
+ * App names may be strings, bytes, uints, etc. This caovers all types of app names
+ */
+struct hub_app_name_t {
+    uint32_t app_name_len;
+    const void *app_name;
+};
+
+struct hub_app_info {
+    const struct hub_app_name_t *name;
+    uint32_t version;
+    uint32_t num_mem_ranges;
+    const struct mem_range_t *mem_usage;
+};
+
+/**
+ * Following enum defines the types of sensors that a hub may declare support
+ * for. Declaration for support would mean that the hub can access and process
+ * data from that particular sensor type.
+ */
+
+typedef enum {
+    CONTEXT_SENSOR_RESERVED,             // 0
+    CONTEXT_SENSOR_ACCELEROMETER,        // 1
+    CONTEXT_SENSOR_GYROSCOPE,            // 2
+    CONTEXT_SENSOR_MAGNETOMETER,         // 3
+    CONTEXT_SENSOR_BAROMETER,            // 4
+    CONTEXT_SENSOR_PROXIMITY_SENSOR,     // 5
+    CONTEXT_SENSOR_AMBIENT_LIGHT_SENSOR, // 6
+
+    CONTEXT_SENSOR_GPS = 0x100,          // 0x100
+    // Reserving this space for variants on GPS
+    CONTEXT_SENSOR_WIFI = 0x200,         // 0x200
+    // Reserving this space for variants on WIFI
+    CONTEXT_SENSOR_AUDIO = 0x300,        // 0x300
+    // Reserving this space for variants on Audio
+    CONTEXT_SENSOR_CAMERA = 0x400,       // 0x400
+    // Reserving this space for variants on Camera
+    CONTEXT_SENSOR_BLE = 0x500,          // 0x500
+
+    CONTEXT_SENSOR_MAX = 0xffffffff,     //make sure enum size is set
+} context_sensor_e;
+
+/**
+ * Sensor types beyond CONTEXT_HUB_TYPE_PRIVATE_SENSOR_BASE are custom types
+ */
+#define CONTEXT_HUB_TYPE_PRIVATE_SENSOR_BASE 0x10000
+
+/**
+ * The following structure describes a sensor
+ */
+struct physical_sensor_description_t {
+    uint32_t sensor_type;           // From the definitions above eg: 100
+    const char *type_string;        // Type as a string. eg: "GPS"
+    const char *name;               // Identifier eg: "Bosch BMI160"
+    const char *vendor;             // Vendor : eg "STM"
+    uint32_t version;               // Version : eg 0x1001
+    uint32_t fifo_reserverd_count;  // Batching possible in hardware. Please
+                                    // note that here hardware does not include
+                                    // the context hub itslef. Thus, this
+                                    // definition may be different from say the
+                                    // number advertised in the sensors HAL
+                                    // which allows for batching in a hub.
+    uint32_t fifo_max_count;        // maximum number of batchable events.
+    uint64_t min_delay_ms;          // in milliseconds, corresponding to highest
+                                    // sampling freq.
+    uint64_t max_delay_ms;          // in milliseconds, corresponds to minimum
+                                    // sampling frequency
+    float peak_power_mw;            // At max frequency & no batching, power
+                                    // in milliwatts
+};
+
+struct connected_sensor_t {
+    uint32_t sensor_id;             // identifier for this sensor
+
+    /* This union may be extended to other sensor types */
+    union {
+        struct physical_sensor_description_t physical_sensor;
+    };
+};
+
+
+
+/**
+ * Messages of this length or less must be supported by all implementations,
+ * longer lengths are supported up to max_supported_msg_len. This is exposed
+ * to third party apps, and since we do not know their msg data formats we
+ * cannot fragment for them. Our own messages are allowed to be bigger and
+ * this HAL will fragment as needed. "Our own" messages are messaegs defined
+ * in this file.
+ */
+#define HUB_REQUIRED_SUPPORTED_MSG_LEN  128
+
+struct hub_message_t {
+    const struct hub_app_name_t *app; /* To/From this nanoapp */
+    uint32_t message_type;
+    uint32_t message_len;
+    const void *message;
+};
+
+
+/**
+ * Definition of a context hub. A device may contain more than one low
+ * power domain. In that case, please add an entry for each hub. However,
+ * it is perfectly OK for a device to declare one context hub and manage
+ * them internally as several
+ */
+
+struct context_hub_t {
+    const char *name;                // descriptive name eg: "Awesome Hub #1"
+    const char *vendor;              // hub hardware vendor eg: "Qualcomm"
+    const char *toolchain;           // toolchain to make binaries eg:"gcc ARM"
+    uint32_t platform_version;       // Version of the hardware : eg 0x20
+    uint32_t toolchain_version;      // Version of the toolchain : eg: 0x484
+    uint32_t hub_id;                 // a device unique id for this hub
+
+    float peak_mips;                 // Peak MIPS platform can deliver
+    float stopped_power_draw_mw;     // if stopped, retention power, milliwatts
+    float sleep_power_draw_mw;       // if sleeping, retention power, milliwatts
+    float peak_power_draw_mw;        // for a busy CPUm power in milliwatts
+
+    const struct connected_sensor_t *connected_sensors; // array of connected sensors
+    uint32_t num_connected_sensors;  // number of connected sensors
+
+    uint32_t max_supported_msg_len;
+    const struct hub_app_name_t *os_app_name; /* send msgs here for OS functions */
+};
+
+/**
+ * All communication between the context hubs and the Context Hub Service is in
+ * the form of messages. Some message types are distinguished and their
+ * Semantics shall be well defined.
+ * Custom message types should be defined starting above
+ * CONTEXT_HUB_PRIVATE_MSG_BASE
+ */
+
+typedef enum {
+    CONTEXT_HUB_APPS_ENABLE = 1, // 1: Enables the loaded nano-apps
+    CONTEXT_HUB_APPS_DISABLE,    // 2: Disables any loaded nano-apps
+    CONTEXT_HUB_LOAD_APP,        // 3: Load a supplied app
+    CONTEXT_HUB_UNLOAD_APP,      // 4: Unload a specified app
+    CONTEXT_HUB_QUERY_APPS,      // 5: Query for apps info on hub (gets struct hub_app_info[])
+    CONTEXT_HUB_QUERY_MEMORY,    // 5: Query for memory info (gets struct mem_range_t[])
+    CONTEXT_HUB_LOAD_OS,         // 6: Load up OS update
+} hub_messages_e;
+
+#define CONTEXT_HUB_TYPE_PRIVATE_MSG_BASE 0x10000
+
+
+/**
+ * A callback registers with the context hub service to pass messages
+ * coming from the hub to the service/clients.
+ */
+typedef int context_hub_callback(uint32_t hub_id, const struct hub_message_t *rxed_msg, void *cookie);
+
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct context_hub_module_t {
+    struct hw_module_t common;
+
+    /**
+     * Enumerate all available hubs.The list is returned in "list".
+     * @return result : 0 if successful, error code otherwise
+     *
+     * This method shall be called at device bootup.
+     */
+    int (*get_hubs)(struct context_hub_module_t* module, const struct context_hub_t ** list);
+
+    /**
+     * Registers a callback for the HAL implementation to communicate
+     * with the context hub service.
+     * @return result : 0 if successful, error code otherwise
+     */
+    int (*subscribe_messages)(uint32_t hub_id, context_hub_callback cbk, void *cookie);
+
+    /**
+     * Send a message to a hub
+     * @return result : 0 if successful, error code otherwise
+     */
+    int (*send_message)(uint32_t hub_id, const struct hub_message_t *msg);
+
+};
+
+__END_DECLS
+
+#endif  // CONTEXT_HUB_SENSORS_INTERFACE_H
diff --git a/include/hardware/fingerprint.h b/include/hardware/fingerprint.h
index 618ca7e..b567732 100644
--- a/include/hardware/fingerprint.h
+++ b/include/hardware/fingerprint.h
@@ -50,6 +50,7 @@
     FINGERPRINT_ERROR_NO_SPACE = 4, /* No space available to store a template */
     FINGERPRINT_ERROR_CANCELED = 5, /* The current operation can't proceed. See above. */
     FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint with given id can't be removed */
+    FINGERPRINT_ERROR_LOCKOUT = 7, /* the functionality is temporarily locked out */
     FINGERPRINT_ERROR_VENDOR_BASE = 1000 /* vendor-specific error messages start here */
 } fingerprint_error_t;
 
@@ -250,8 +251,16 @@
      */
     int (*authenticate)(struct fingerprint_device *dev, uint64_t operation_id, uint32_t gid);
 
+    /*
+     * Resets a lockout by providing a valid hardware authentication token.
+     *
+     * Function return: 0 on success
+     *                  or a negative number in case of error, generally from the errno.h set.
+     */
+    int (*reset_lockout)(struct fingerprint_device *dev, const hw_auth_token_t *hat);
+
     /* Reserved for backward binary compatibility */
-    void *reserved[4];
+    void *reserved[3];
 } fingerprint_device_t;
 
 typedef struct fingerprint_module {
diff --git a/include/hardware/hardware_properties.h b/include/hardware/hardware_properties.h
new file mode 100644
index 0000000..7c9bd4e
--- /dev/null
+++ b/include/hardware/hardware_properties.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2015 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 ANDROID_INCLUDE_HARDWARE_HARDWAREPROPERTIES_H
+#define ANDROID_INCLUDE_HARDWARE_HARDWAREPROPERTIES_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <hardware/hardware.h>
+
+__BEGIN_DECLS
+
+#define HARDWARE_PROPERTIES_HARDWARE_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
+
+/**
+ * The id of this module
+ */
+#define HARDWARE_PROPERTIES_HARDWARE_MODULE_ID "hardware_properties"
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+typedef struct hardware_properties_module {
+    struct hw_module_t common;
+
+    /*
+     * (*getCpuTemperatures) is called to get CPU temperatures in Celsius of
+     * each core.
+     *
+     * Returns number of cores or negative value on error.
+     *
+     */
+    ssize_t (*getCpuTemperatures)(struct hardware_properties_module *module, float **temps);
+
+    /*
+     * (*getGpuTemperatures) is called to get GPU temperatures in Celsius of
+     * each GPU.
+     *
+     * Returns number of GPUs or negative value on error.
+     *
+     */
+    ssize_t (*getGpuTemperatures)(struct hardware_properties_module *module, float **temps);
+
+    /*
+     * (*getBatteryTemperatures) is called to get battery temperatures in
+     * Celsius.
+     *
+     * Returns number of battery temperatures or negative value on error.
+     *
+     */
+    ssize_t (*getBatteryTemperatures)(struct hardware_properties_module *module, float **temps);
+
+    /*
+     * (*getCpuUsages) is called to get CPU usage information of each core:
+     * active and total times in ms since first boot.
+     *
+     * Returns number of cores or negative value on error.
+     *
+     */
+    ssize_t (*getCpuUsages)(struct hardware_properties_module *module,
+                            int64_t **active_times, int64_t **total_times);
+
+    /*
+     * (*getFanSpeeds) is called to get the fan speeds in RPM of each fan.
+     *
+     * Returns number of fans or negative value on error.
+     *
+     */
+    ssize_t (*getFanSpeeds)(struct hardware_properties_module *module,
+                        float **fan_speeds);
+} hardware_properties_module_t;
+
+__END_DECLS
+
+#endif  // ANDROID_INCLUDE_HARDWARE_HARDWAREPROPERTIES_H
diff --git a/include/hardware/keymaster2.h b/include/hardware/keymaster2.h
new file mode 100644
index 0000000..dcde30e
--- /dev/null
+++ b/include/hardware/keymaster2.h
@@ -0,0 +1,452 @@
+/*
+ * Copyright (C) 2015 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 ANDROID_HARDWARE_KEYMASTER2_H
+#define ANDROID_HARDWARE_KEYMASTER2_H
+
+#include <hardware/keymaster_common.h>
+#include <hardware/keymaster_defs.h>
+
+__BEGIN_DECLS
+
+/**
+ * Keymaster2 device definition
+ */
+struct keymaster2_device {
+    /**
+     * Common methods of the keymaster device.  This *must* be the first member of
+     * keymaster_device as users of this structure will cast a hw_device_t to
+     * keymaster_device pointer in contexts where it's known the hw_device_t references a
+     * keymaster_device.
+     */
+    struct hw_device_t common;
+
+    void* context;
+
+    /**
+     * See flags defined for keymaster0_devices::flags in keymaster_common.h.  Used only for
+     * backward compatibility; keymaster2 hardware devices must set this to zero.
+     */
+    uint32_t flags;
+
+    /**
+     * Adds entropy to the RNG used by keymaster.  Entropy added through this method is guaranteed
+     * not to be the only source of entropy used, and the mixing function is required to be secure,
+     * in the sense that if the RNG is seeded (from any source) with any data the attacker cannot
+     * predict (or control), then the RNG output is indistinguishable from random.  Thus, if the
+     * entropy from any source is good, the output will be good.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] data Random data to be mixed in.
+     *
+     * \param[in] data_length Length of \p data.
+     */
+    keymaster_error_t (*add_rng_entropy)(const struct keymaster2_device* dev, const uint8_t* data,
+                                         size_t data_length);
+
+    /**
+     * Generates a key, or key pair, returning a key blob and/or a description of the key.
+     *
+     * Key generation parameters are defined as keymaster tag/value pairs, provided in \p params.
+     * See keymaster_tag_t for the full list.  Some values that are always required for generation
+     * of useful keys are:
+     *
+     * - KM_TAG_ALGORITHM;
+     * - KM_TAG_PURPOSE; and
+     * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED.
+     *
+     * KM_TAG_AUTH_TIMEOUT should generally be specified unless KM_TAG_NO_AUTH_REQUIRED is present,
+     * or the user will have to authenticate for every use.
+     *
+     * KM_TAG_BLOCK_MODE, KM_TAG_PADDING, KM_TAG_MAC_LENGTH and KM_TAG_DIGEST must be specified for
+     * algorithms that require them.
+     *
+     * The following tags may not be specified; their values will be provided by the implementation.
+     *
+     * - KM_TAG_ORIGIN,
+     * - KM_TAG_ROLLBACK_RESISTANT,
+     * - KM_TAG_CREATION_DATETIME
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] params Array of key generation param
+     *
+     * \param[out] key_blob returns the generated key. \p key_blob must not be NULL.  The caller
+     * assumes ownership key_blob->key_material and must free() it.
+     *
+     * \param[out] characteristics returns the characteristics of the key that was, generated, if
+     * non-NULL.  If non-NULL, the caller assumes ownership and must deallocate with
+     * keymaster_free_characteristics().  Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and
+     * KM_TAG_APPLICATION_DATA are never returned.
+     */
+    keymaster_error_t (*generate_key)(const struct keymaster2_device* dev,
+                                      const keymaster_key_param_set_t* params,
+                                      keymaster_key_blob_t* key_blob,
+                                      keymaster_key_characteristics_t* characteristics);
+
+    /**
+     * Returns the characteristics of the specified key, or KM_ERROR_INVALID_KEY_BLOB if the
+     * key_blob is invalid (implementations must fully validate the integrity of the key).
+     * client_id and app_data must be the ID and data provided when the key was generated or
+     * imported, or empty if KM_TAG_APPLICATION_ID and/or KM_TAG_APPLICATION_DATA were not provided
+     * during generation.  Those values are not included in the returned characteristics.  The
+     * caller assumes ownership of the allocated characteristics object, which must be deallocated
+     * with keymaster_free_characteristics().
+     *
+     * Note that KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never returned.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] key_blob The key to retreive characteristics from.
+     *
+     * \param[in] client_id The client ID data, or NULL if none associated.
+     *
+     * \param[in] app_id The app data, or NULL if none associated.
+     *
+     * \param[out] characteristics The key characteristics. Must not be NULL.  The caller assumes
+     * ownership of the contents and must deallocate with keymaster_free_characteristics().
+     */
+    keymaster_error_t (*get_key_characteristics)(const struct keymaster2_device* dev,
+                                                 const keymaster_key_blob_t* key_blob,
+                                                 const keymaster_blob_t* client_id,
+                                                 const keymaster_blob_t* app_data,
+                                                 keymaster_key_characteristics_t* characteristics);
+
+    /**
+     * Imports a key, or key pair, returning a key blob and/or a description of the key.
+     *
+     * Most key import parameters are defined as keymaster tag/value pairs, provided in "params".
+     * See keymaster_tag_t for the full list.  Values that are always required for import of useful
+     * keys are:
+     *
+     * - KM_TAG_ALGORITHM;
+     * - KM_TAG_PURPOSE; and
+     * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED.
+     *
+     * KM_TAG_AUTH_TIMEOUT should generally be specified. If unspecified, the user will have to
+     * authenticate for every use.
+     *
+     * The following tags will take default values if unspecified:
+     *
+     * - KM_TAG_KEY_SIZE will default to the size of the key provided.
+     * - KM_TAG_RSA_PUBLIC_EXPONENT will default to the value in the key provided (for RSA keys)
+     *
+     * The following tags may not be specified; their values will be provided by the implementation.
+     *
+     * - KM_TAG_ORIGIN,
+     * - KM_TAG_ROLLBACK_RESISTANT,
+     * - KM_TAG_CREATION_DATETIME
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] params Parameters defining the imported key.
+     *
+     * \param[in] params_count The number of entries in \p params.
+     *
+     * \param[in] key_format specifies the format of the key data in key_data.
+     *
+     * \param[out] key_blob Used to return the opaque key blob.  Must be non-NULL.  The caller
+     * assumes ownership of the contained key_material.
+     *
+     * \param[out] characteristics Used to return the characteristics of the imported key.  May be
+     * NULL, in which case no characteristics will be returned.  If non-NULL, the caller assumes
+     * ownership of the contents and must deallocate with keymaster_free_characteristics().  Note
+     * that KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never returned.
+     */
+    keymaster_error_t (*import_key)(const struct keymaster2_device* dev,
+                                    const keymaster_key_param_set_t* params,
+                                    keymaster_key_format_t key_format,
+                                    const keymaster_blob_t* key_data,
+                                    keymaster_key_blob_t* key_blob,
+                                    keymaster_key_characteristics_t* characteristics);
+
+    /**
+     * Exports a public or symmetric key, returning a byte array in the specified format.
+     *
+     * Note that symmetric key export is allowed only if the key was created with KM_TAG_EXPORTABLE,
+     * and only if all of the requirements for key usage (e.g. authentication) are met.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] export_format The format to be used for exporting the key.
+     *
+     * \param[in] key_to_export The key to export.
+     *
+     * \param[in] client_id Client ID blob, which must match the blob provided in
+     * KM_TAG_APPLICATION_ID during key generation (if any).
+     *
+     * \param[in] app_data Appliation data blob, which must match the blob provided in
+     * KM_TAG_APPLICATION_DATA during key generation (if any).
+     *
+     * \param[out] export_data The exported key material.  The caller assumes ownership.
+     */
+    keymaster_error_t (*export_key)(const struct keymaster2_device* dev,
+                                    keymaster_key_format_t export_format,
+                                    const keymaster_key_blob_t* key_to_export,
+                                    const keymaster_blob_t* client_id,
+                                    const keymaster_blob_t* app_data,
+                                    keymaster_blob_t* export_data);
+
+    /**
+     * Derives a shared secret key from \p key, which must be an EC key, and the public key found in
+     * /p other_key_certificate, an X.509 certificate containing a compatible EC public key.  The
+     * derived key's characteristics are described in \p new_key_params, which must include
+     * algorithm (KM_TAG_ALGORITHM), key size (KM_TAG_KEY_SIZE) and KDF (KM_TAG_KDF) as well as
+     * other desired key characteristics.  The resulting key material is not returned directly, but
+     * instead a new keymaster key is created and the associated blob returned in \p key_blob.  If
+     * \p characteristics is non-NULL, the new key's characteristics are placed there.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] key The keymaster key to use for key agreement. This must be an EC key with the
+     * KM_PURPOSE_DERIVE_KEY purpose.
+     *
+     * \param[in] other_key_certificate An X.509 certificate or certificate fragment containing a
+     * SubjectPublicKey field containing an EC public key on the same curve as \p key.
+     *
+     * \param[in] new_key_params A set of parameters to define/describe the newly-derived symmetric
+     * key. The parameters will define how the key may be used. The set must include KM_TAG_KDF to
+     * specify how the raw agreed key bytes will be transformed to produce the key material.
+     *
+     * \param[out] key_blob The key blob containing the newly-derived key.  The caller takes
+     * ownership of the returned blob.
+     *
+     * \param[out] characteristics. If non-null, will be used to return the characteristics of the
+     * new key blob, which will have KM_TAG_ORIGIN set to KM_ORIGIN_DERIVED.  The caller takes
+     * ownership of the returned characteristics and must deallocate with
+     * keymaster_free_characteristics().
+     */
+    keymaster_error_t (*agree_key)(const struct keymaster2_device* dev,
+                                   const keymaster_key_blob_t* key,
+                                   const keymaster_blob_t* other_key_certificate,
+                                   const keymaster_key_param_set_t* new_key_params,
+                                   keymaster_key_blob_t* new_key_blob,
+                                   keymaster_key_characteristics_t* characteristics);
+
+    /**
+     * Generates a signed X.509 certificate chain attesting to the presence of \p key_to_attest in
+     * keymaster (TODO(swillden): Describe certificate contents in more detail).  The certificate
+     * will contain an extension with OID 1.3.6.1.4.1.11129.2.1.17 and value defined in
+     * <TODO:swillden -- insert link here> which contains the key description.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] key_to_attest The keymaster key for which the attestation certificate will be
+     * generated.
+     *
+     * \param[in] attest_params Parameters defining how to do the attestation.  At present the only
+     * parameter is KM_TAG_ALGORITHM, which must be either KM_ALGORITHM_EC or KM_ALGORITHM_RSA.
+     * This selects which of the provisioned attestation keys will be used to sign the certificate.
+     *
+     * \param[out] cert_chain An array of DER-encoded X.509 certificates. The first will be the
+     * certificate for \p key_to_attest.  The remaining entries will chain back to the root.  The
+     * caller takes ownership and must deallocate with keymaster_free_cert_chain.
+     */
+    keymaster_error_t (*attest_key)(const struct keymaster2_device* dev,
+                                    const keymaster_key_blob_t* key_to_attest,
+                                    const keymaster_key_param_set_t* attest_params,
+                                    keymaster_cert_chain_t* cert_chain);
+
+    /**
+     * Upgrades an old key.  Keys can become "old" in two ways: Keymaster can be upgraded to a new
+     * version, or the system can be updated to invalidate the OS version and/or patch level.  In
+     * either case, attempts to use an old key will result in keymaster returning
+     * KM_ERROR_KEY_REQUIRES_UPGRADE.  This method should then be called to upgrade the key.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] key_to_upgrade The keymaster key to upgrade.
+     *
+     * \param[in] upgrade_params Parameters needed to complete the upgrade. In particular,
+     * KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA will be required if they were defined for
+     * the key.
+     *
+     * \param[out] upgraded_key The upgraded key blob.
+     */
+    keymaster_error_t (*upgrade_key)(const struct keymaster2_device* dev,
+                                     const keymaster_key_blob_t* key_to_upgrade,
+                                     const keymaster_key_param_set_t* upgrade_params,
+                                     keymaster_key_blob_t* upgraded_key);
+
+    /**
+     * Deletes the key, or key pair, associated with the key blob.  After calling this function it
+     * will be impossible to use the key for any other operations.  May be applied to keys from
+     * foreign roots of trust (keys not usable under the current root of trust).
+     *
+     * This function is optional and should be set to NULL if it is not implemented.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] key The key to be deleted.
+     */
+    keymaster_error_t (*delete_key)(const struct keymaster2_device* dev,
+                                    const keymaster_key_blob_t* key);
+
+    /**
+     * Deletes all keys in the hardware keystore. Used when keystore is reset completely.  After
+     * calling this function it will be impossible to use any previously generated or imported key
+     * blobs for any operations.
+     *
+     * This function is optional and should be set to NULL if it is not implemented.
+     *
+     * \param[in] dev The keymaster device structure.
+     */
+    keymaster_error_t (*delete_all_keys)(const struct keymaster2_device* dev);
+
+    /**
+     * Begins a cryptographic operation using the specified key.  If all is well, begin() will
+     * return KM_ERROR_OK and create an operation handle which must be passed to subsequent calls to
+     * update(), finish() or abort().
+     *
+     * It is critical that each call to begin() be paired with a subsequent call to finish() or
+     * abort(), to allow the keymaster implementation to clean up any internal operation state.
+     * Failure to do this may leak internal state space or other internal resources and may
+     * eventually cause begin() to return KM_ERROR_TOO_MANY_OPERATIONS when it runs out of space for
+     * operations.  Any result other than KM_ERROR_OK from begin(), update() or finish() implicitly
+     * aborts the operation, in which case abort() need not be called (and will return
+     * KM_ERROR_INVALID_OPERATION_HANDLE if called).
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] purpose The purpose of the operation, one of KM_PURPOSE_ENCRYPT,
+     * KM_PURPOSE_DECRYPT, KM_PURPOSE_SIGN or KM_PURPOSE_VERIFY. Note that for AEAD modes,
+     * encryption and decryption imply signing and verification, respectively, but should be
+     * specified as KM_PURPOSE_ENCRYPT and KM_PURPOSE_DECRYPT.
+     *
+     * \param[in] key The key to be used for the operation. \p key must have a purpose compatible
+     * with \p purpose and all of its usage requirements must be satisfied, or begin() will return
+     * an appropriate error code.
+     *
+     * \param[in] in_params Additional parameters for the operation.  This is typically used to
+     * provide authentication data, with KM_TAG_AUTH_TOKEN.  If KM_TAG_APPLICATION_ID or
+     * KM_TAG_APPLICATION_DATA were provided during generation, they must be provided here, or the
+     * operation will fail with KM_ERROR_INVALID_KEY_BLOB.  For operations that require a nonce or
+     * IV, on keys that were generated with KM_TAG_CALLER_NONCE, in_params may contain a tag
+     * KM_TAG_NONCE.
+     *
+     * \param[out] out_params Output parameters.  Used to return additional data from the operation
+     * initialization, notably to return the IV or nonce from operations that generate an IV or
+     * nonce.  The caller takes ownership of the output parameters array and must free it with
+     * keymaster_free_param_set().  out_params may be set to NULL if no output parameters are
+     * expected.  If out_params is NULL, and output paramaters are generated, begin() will return
+     * KM_ERROR_OUTPUT_PARAMETER_NULL.
+     *
+     * \param[out] operation_handle The newly-created operation handle which must be passed to
+     * update(), finish() or abort().  If operation_handle is NULL, begin() will return
+     * KM_ERROR_OUTPUT_PARAMETER_NULL.
+     */
+    keymaster_error_t (*begin)(const struct keymaster2_device* dev, keymaster_purpose_t purpose,
+                               const keymaster_key_blob_t* key,
+                               const keymaster_key_param_set_t* in_params,
+                               keymaster_key_param_set_t* out_params,
+                               keymaster_operation_handle_t* operation_handle);
+
+    /**
+     * Provides data to, and possibly receives output from, an ongoing cryptographic operation begun
+     * with begin().
+     *
+     * If operation_handle is invalid, update() will return KM_ERROR_INVALID_OPERATION_HANDLE.
+     *
+     * update() may not consume all of the data provided in the data buffer.  update() will return
+     * the amount consumed in *data_consumed.  The caller should provide the unconsumed data in a
+     * subsequent call.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] operation_handle The operation handle returned by begin().
+     *
+     * \param[in] in_params Additional parameters for the operation.  For AEAD modes, this is used
+     * to specify KM_TAG_ADDITIONAL_DATA.  Note that additional data may be provided in multiple
+     * calls to update(), but only until input data has been provided.
+     *
+     * \param[in] input Data to be processed, per the parameters established in the call to begin().
+     * Note that update() may or may not consume all of the data provided.  See \p input_consumed.
+     *
+     * \param[out] input_consumed Amount of data that was consumed by update().  If this is less
+     * than the amount provided, the caller should provide the remainder in a subsequent call to
+     * update().
+     *
+     * \param[out] out_params Output parameters.  Used to return additional data from the operation
+     * The caller takes ownership of the output parameters array and must free it with
+     * keymaster_free_param_set().  out_params may be set to NULL if no output parameters are
+     * expected.  If out_params is NULL, and output paramaters are generated, begin() will return
+     * KM_ERROR_OUTPUT_PARAMETER_NULL.
+     *
+     * \param[out] output The output data, if any.  The caller assumes ownership of the allocated
+     * buffer.  output must not be NULL.
+     *
+     * Note that update() may not provide any output, in which case output->data_length will be
+     * zero, and output->data may be either NULL or zero-length (so the caller should always free()
+     * it).
+     */
+    keymaster_error_t (*update)(const struct keymaster2_device* dev,
+                                keymaster_operation_handle_t operation_handle,
+                                const keymaster_key_param_set_t* in_params,
+                                const keymaster_blob_t* input, size_t* input_consumed,
+                                keymaster_key_param_set_t* out_params, keymaster_blob_t* output);
+
+    /**
+     * Finalizes a cryptographic operation begun with begin() and invalidates \p operation_handle.
+     *
+     * \param[in] dev The keymaster device structure.
+     *
+     * \param[in] operation_handle The operation handle returned by begin().  This handle will be
+     * invalidated.
+     *
+     * \param[in] in_params Additional parameters for the operation.  For AEAD modes, this is used
+     * to specify KM_TAG_ADDITIONAL_DATA, but only if no input data was provided to update().
+     *
+     * \param[in] input Data to be processed, per the parameters established in the call to
+     * begin(). finish() must consume all provided data or return KM_ERROR_INVALID_INPUT_LENGTH.
+     *
+     * \param[in] signature The signature to be verified if the purpose specified in the begin()
+     * call was KM_PURPOSE_VERIFY.
+     *
+     * \param[out] output The output data, if any.  The caller assumes ownership of the allocated
+     * buffer.
+     *
+     * If the operation being finished is a signature verification or an AEAD-mode decryption and
+     * verification fails then finish() will return KM_ERROR_VERIFICATION_FAILED.
+     */
+    keymaster_error_t (*finish)(const struct keymaster2_device* dev,
+                                keymaster_operation_handle_t operation_handle,
+                                const keymaster_key_param_set_t* in_params,
+                                const keymaster_blob_t* input, const keymaster_blob_t* signature,
+                                keymaster_key_param_set_t* out_params, keymaster_blob_t* output);
+
+    /**
+     * Aborts a cryptographic operation begun with begin(), freeing all internal resources and
+     * invalidating \p operation_handle.
+     */
+    keymaster_error_t (*abort)(const struct keymaster2_device* dev,
+                               keymaster_operation_handle_t operation_handle);
+};
+typedef struct keymaster2_device keymaster2_device_t;
+
+/* Convenience API for opening and closing keymaster devices */
+
+static inline int keymaster2_open(const struct hw_module_t* module, keymaster2_device_t** device) {
+    return module->methods->open(module, KEYSTORE_KEYMASTER, (struct hw_device_t**)device);
+}
+
+static inline int keymaster2_close(keymaster2_device_t* device) {
+    return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif  // ANDROID_HARDWARE_KEYMASTER2_H
diff --git a/include/hardware/keymaster_common.h b/include/hardware/keymaster_common.h
index 772d7e4..c79c122 100644
--- a/include/hardware/keymaster_common.h
+++ b/include/hardware/keymaster_common.h
@@ -54,6 +54,12 @@
 #define KEYMASTER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
 #define KEYMASTER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
 
+/**
+ * Keymaster 2.0 module version provides third API, slightly modified and extended from 1.0.
+ */
+#define KEYMASTER_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
+#define KEYMASTER_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
+
 struct keystore_module {
     /**
      * Common methods of the keystore module.  This *must* be the first member of keystore_module as
diff --git a/include/hardware/keymaster_defs.h b/include/hardware/keymaster_defs.h
index 27cef37..c0ca514 100644
--- a/include/hardware/keymaster_defs.h
+++ b/include/hardware/keymaster_defs.h
@@ -52,22 +52,25 @@
      */
 
     /* Crypto parameters */
-    KM_TAG_PURPOSE = KM_ENUM_REP | 1,      /* keymaster_purpose_t. */
-    KM_TAG_ALGORITHM = KM_ENUM | 2,        /* keymaster_algorithm_t. */
-    KM_TAG_KEY_SIZE = KM_UINT | 3,         /* Key size in bits. */
-    KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4,   /* keymaster_block_mode_t. */
-    KM_TAG_DIGEST = KM_ENUM_REP | 5,       /* keymaster_digest_t. */
-    KM_TAG_PADDING = KM_ENUM_REP | 6,      /* keymaster_padding_t. */
-    KM_TAG_CALLER_NONCE = KM_BOOL | 7,     /* Allow caller to specify nonce or IV. */
-    KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8,   /* Minimum length of MAC or AEAD authentication tag in
-                                            * bits. */
-    KM_TAG_KDF = KM_ENUM | 9,              /* keymaster_kdf_t */
-    KM_TAG_EC_CURVE = KM_ENUM | 10,        /* keymaster_ec_curve_t */
+    KM_TAG_PURPOSE = KM_ENUM_REP | 1,    /* keymaster_purpose_t. */
+    KM_TAG_ALGORITHM = KM_ENUM | 2,      /* keymaster_algorithm_t. */
+    KM_TAG_KEY_SIZE = KM_UINT | 3,       /* Key size in bits. */
+    KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4, /* keymaster_block_mode_t. */
+    KM_TAG_DIGEST = KM_ENUM_REP | 5,     /* keymaster_digest_t. */
+    KM_TAG_PADDING = KM_ENUM_REP | 6,    /* keymaster_padding_t. */
+    KM_TAG_CALLER_NONCE = KM_BOOL | 7,   /* Allow caller to specify nonce or IV. */
+    KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8, /* Minimum length of MAC or AEAD authentication tag in
+                                          * bits. */
+    KM_TAG_KDF = KM_ENUM_REP | 9,        /* keymaster_kdf_t (keymaster2) */
+    KM_TAG_EC_CURVE = KM_ENUM | 10,      /* keymaster_ec_curve_t (keymaster2) */
 
     /* Algorithm-specific. */
     KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200,
     KM_TAG_ECIES_SINGLE_HASH_MODE = KM_BOOL | 201, /* Whether the ephemeral public key is fed into
-                                                    *  the KDF, see 10.2 in http://goo.gl/WbmSSO */
+                                                    * the KDF */
+    KM_TAG_INCLUDE_UNIQUE_ID = KM_BOOL | 202,      /* If true, attestation certificates for this key
+                                                    * will contain an application-scoped and
+                                                    * time-bounded device-unique ID. (keymaster2) */
 
     /* Other hardware-enforced. */
     KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 301, /* keymaster_key_blob_usage_requirements_t */
@@ -108,8 +111,13 @@
                                                    device is powered off. */
 
     /* Application access control */
-    KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Reserved for future use -- ignore */
-    KM_TAG_APPLICATION_ID = KM_BYTES | 601,  /* Reserved for fugure use -- ignore */
+    KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Specified to indicate key is usable by all
+                                              * applications. */
+    KM_TAG_APPLICATION_ID = KM_BYTES | 601,  /* Byte string identifying the authorized
+                                              * application. */
+    KM_TAG_EXPORTABLE = KM_BOOL | 602,       /* If true, private/secret key can be exported, but
+                                              * only if all access control requirements for use are
+                                              * met. (keymaster2) */
 
     /*
      * Semantically unenforceable tags, either because they have no specific meaning or because
@@ -120,6 +128,9 @@
     KM_TAG_ORIGIN = KM_ENUM | 702,             /* keymaster_key_origin_t. */
     KM_TAG_ROLLBACK_RESISTANT = KM_BOOL | 703, /* Whether key is rollback-resistant. */
     KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704,     /* Root of trust ID. */
+    KM_TAG_OS_VERSION = KM_UINT | 705,         /* Version of system (keymaster2) */
+    KM_TAG_OS_PATCHLEVEL = KM_UINT | 706,      /* Patch level of system (keymaster2) */
+    KM_TAG_UNIQUE_ID = KM_BYTES | 707,         /* Used to provide unique ID in attestation */
 
     /* Tags used only to provide data to or receive data from operations */
     KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000, /* Used to provide associated data for AEAD modes. */
@@ -127,7 +138,12 @@
     KM_TAG_AUTH_TOKEN = KM_BYTES | 1002,      /* Authentication token that proves secure user
                                                  authentication has been performed.  Structure
                                                  defined in hw_auth_token_t in hw_auth_token.h. */
-    KM_TAG_MAC_LENGTH = KM_UINT | 1003,       /* MAC or AEAD authentication tag length in bits. */
+    KM_TAG_MAC_LENGTH = KM_UINT | 1003,       /* MAC or AEAD authentication tag length in
+                                               * bits. */
+
+    KM_TAG_RESET_SINCE_ID_ROTATION = KM_BOOL | 1004, /* Whether the device has beeen factory reset
+                                                        since the last unique ID rotation.  Used for
+                                                        key attestation. */
 } keymaster_tag_t;
 
 /**
@@ -195,16 +211,18 @@
  * Key derivation functions, mostly used in ECIES.
  */
 typedef enum {
+    /* Do not apply a key derivation function; use the raw agreed key */
+    KM_KDF_NONE = 0,
     /* HKDF defined in RFC 5869 with SHA256 */
-    KM_KDF_RFC5869_SHA256 = 0,
+    KM_KDF_RFC5869_SHA256 = 1,
     /* KDF1 defined in ISO 18033-2 with SHA1 */
-    KM_KDF_ISO18033_1_KDF2_SHA1 = 1,
+    KM_KDF_ISO18033_2_KDF1_SHA1 = 2,
     /* KDF1 defined in ISO 18033-2 with SHA256 */
-    KM_KDF_ISO18033_1_KDF1_SHA256 = 2,
+    KM_KDF_ISO18033_2_KDF1_SHA256 = 3,
     /* KDF2 defined in ISO 18033-2 with SHA1 */
-    KM_KDF_ISO18033_2_KDF2_SHA1 = 3,
+    KM_KDF_ISO18033_2_KDF2_SHA1 = 4,
     /* KDF2 defined in ISO 18033-2 with SHA256 */
-    KM_KDF_ISO18033_2_KDF2_SHA256 = 4,
+    KM_KDF_ISO18033_2_KDF2_SHA256 = 5,
 } keymaster_kdf_t;
 
 /**
@@ -224,8 +242,9 @@
  * hardware-enforced list is guaranteed never to have existed outide the secure hardware.
  */
 typedef enum {
-    KM_ORIGIN_GENERATED = 0, /* Generated in keymaster */
-    KM_ORIGIN_IMPORTED = 2,  /* Imported, origin unknown */
+    KM_ORIGIN_GENERATED = 0, /* Generated in keymaster.  Should not exist outside the TEE. */
+    KM_ORIGIN_DERIVED = 1,   /* Derived inside keymaster.  Likely exists off-device. */
+    KM_ORIGIN_IMPORTED = 2,  /* Imported into keymaster.  Existed as cleartext in Android. */
     KM_ORIGIN_UNKNOWN = 3,   /* Keymaster did not record origin.  This value can only be seen on
                               * keys in a keymaster0 implementation.  The keymaster0 adapter uses
                               * this value to document the fact that it is unkown whether the key
@@ -237,7 +256,7 @@
  * for the key to function.  For example, key "blobs" which are actually handles referencing
  * encrypted key material stored in the file system cannot be used until the file system is
  * available, and should have BLOB_REQUIRES_FILE_SYSTEM.  Other requirements entries will be added
- * as needed for implementations.  This type is new in 0_4.
+ * as needed for implementations.
  */
 typedef enum {
     KM_BLOB_STANDALONE = 0,
@@ -245,13 +264,14 @@
 } keymaster_key_blob_usage_requirements_t;
 
 /**
- * Possible purposes of a key (or pair). This type is new in 0_4.
+ * Possible purposes of a key (or pair).
  */
 typedef enum {
-    KM_PURPOSE_ENCRYPT = 0,
-    KM_PURPOSE_DECRYPT = 1,
-    KM_PURPOSE_SIGN = 2,
-    KM_PURPOSE_VERIFY = 3,
+    KM_PURPOSE_ENCRYPT = 0,    /* Usable with RSA, EC and AES keys. */
+    KM_PURPOSE_DECRYPT = 1,    /* Usable with RSA, EC and AES keys. */
+    KM_PURPOSE_SIGN = 2,       /* Usable with RSA, EC and HMAC keys. */
+    KM_PURPOSE_VERIFY = 3,     /* Usable with RSA, EC and HMAC keys. */
+    KM_PURPOSE_DERIVE_KEY = 4, /* Usable with EC keys. */
 } keymaster_purpose_t;
 
 typedef struct {
@@ -293,14 +313,18 @@
     size_t key_material_size;
 } keymaster_key_blob_t;
 
+typedef struct {
+    keymaster_blob_t* entries;
+    size_t entry_count;
+} keymaster_cert_chain_t;
+
 /**
- * Formats for key import and export.  At present, only asymmetric key import/export is supported.
- * In the future this list will expand greatly to accommodate asymmetric key import/export.
+ * Formats for key import and export.
  */
 typedef enum {
     KM_KEY_FORMAT_X509 = 0,  /* for public key export */
     KM_KEY_FORMAT_PKCS8 = 1, /* for asymmetric key pair import */
-    KM_KEY_FORMAT_RAW = 3,   /* for symmetric key import */
+    KM_KEY_FORMAT_RAW = 3,   /* for symmetric key import and export*/
 } keymaster_key_format_t;
 
 /**
@@ -372,6 +396,7 @@
     KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59,
     KM_ERROR_UNSUPPORTED_KDF = -60,
     KM_ERROR_UNSUPPORTED_EC_CURVE = -61,
+    KM_ERROR_KEY_REQUIRES_UPGRADE = -62,
 
     KM_ERROR_UNIMPLEMENTED = -100,
     KM_ERROR_VERSION_MISMATCH = -101,
@@ -542,6 +567,19 @@
     }
 }
 
+inline void keymaster_free_cert_chain(keymaster_cert_chain_t* chain) {
+    if (chain) {
+        for (size_t i = 0; i < chain->entry_count; ++i) {
+            free((uint8_t*)chain->entries[i].data);
+            chain->entries[i].data = NULL;
+            chain->entries[i].data_length = 0;
+        }
+        free(chain->entries);
+        chain->entries = NULL;
+        chain->entry_count = 0;
+    }
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif  // __cplusplus
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/sensors.h b/include/hardware/sensors.h
index 51bffe1..b6f4a04 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -657,6 +657,60 @@
 #define SENSOR_TYPE_WRIST_TILT_GESTURE                         (26)
 #define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE                  "android.sensor.wrist_tilt_gesture"
 
+/*
+ * SENSOR_TYPE_DEVICE_ORIENTATION
+ * reporting-mode: on-change
+ *
+ * The current orientation of the device. The value should be reported in the
+ * first element of the 'data' member variable in sensors_event_t. The only
+ * values that can be reported are (please refer to Android Sensor Coordinate
+ * System to understand the X and Y axis direction with respect to default
+ * orientation):
+ *  - 0: device is in default orientation (Y axis is vertical and points up)
+ *  - 1: device is rotated 90 degrees counter-clockwise from default
+ *       orientation (X axis is vertical and points up)
+ *  - 2: device is rotated 180 degrees from default orientation (Y axis is
+ *       vertical and points down)
+ *  - 3: device is rotated 90 degrees clockwise from default orientation (X axis
+ *       is vertical and points down)
+ *
+ * Moving the device to an orientation where the Z axis is vertical (either up
+ * or down) should not cause a new event to be reported.
+ *
+ * To improve the user experience of this sensor, it is recommended to implement
+ * some physical (i.e., rotation angle) and temporal (i.e., delay) hysteresis.
+ * In other words, minor or transient rotations should not cause a new event to
+ * be reported.
+ *
+ * This sensor should only be implemented with the help of an accelerometer.
+ * This is a low power sensor that should reduce the number of interrupts of the
+ * AP. Do not emulate this sensor in the HAL.
+ *
+ * Both wake-up and non wake-up versions are useful.
+ */
+#define SENSOR_TYPE_DEVICE_ORIENTATION                 (27)
+#define SENSOR_STRING_TYPE_DEVICE_ORIENTATION          "android.sensor.device_orientation"
+
+/*
+ * SENSOR_TYPE_POSE_6DOF
+ * trigger-mode: continuous
+ *
+ * A sensor of this type returns the pose of the device.
+ * Pose of the device is defined as the orientation of the device from a
+ * Earth Centered Earth Fixed frame and the translation from an arbitrary
+ * point at subscription.
+ *
+ * This sensor can be high power. It can use any and all of the following
+ *           . Accelerometer
+ *           . Gyroscope
+ *           . Camera
+ *           . Depth Camera
+ *
+ * Implement only the wake-up version of this sensor.
+ */
+#define SENSOR_TYPE_POSE_6DOF                         (28)
+#define SENSOR_STRING_TYPE_POSE_6DOF                  "android.sensor.pose_6dof"
+
 /**
  * Values returned by the accelerometer in various locations in the universe.
  * all values are in SI units (m/s^2)
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..14fb7aa 100644
--- a/include/hardware/vehicle.h
+++ b/include/hardware/vehicle.h
@@ -67,6 +67,9 @@
  * @data_member: Name of member from vehicle_value union to access this data.
  * @data_enum: enum type that should be used for the data.
  * @unit: Unit of data. Should be from vehicle_unit_type.
+ * @config_flags: Usage of config_flags in vehicle_prop_config
+ * @config_array: Usage of config_array in vehicle_prop_config. When this is specified,
+ *                @config_flags will not be used.
  * @config_string: Explains the usage of config_string in vehicle_prop_config. Property with
  *                 this annotation is expected to have additional information in config_string
  *                 for that property to work.
@@ -253,6 +256,7 @@
  * @value_type VEHICLE_VALUE_TYPE_ZONED_INT32
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Supported zones
  * @data_member hvac.fan_speed
  * @data_enum TODO
  */
@@ -263,16 +267,27 @@
  * @value_type VEHICLE_VALUE_TYPE_ZONED_INT32
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Supported zones
  * @data_member hvac.fan_direction
  * @data_enum TODO
  */
 #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,
+    VEHICLE_HVAC_FAN_DIRECTION_FACE_AND_FLOOR_FLAG  = 0x3
+};
+
 /**
  * HVAC current temperature.
  * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Supported zones
  * @data_member hvac.temperature_current
  */
 #define VEHICLE_PROPERTY_HVAC_TEMPERATURE_CURRENT                   (0x00000502)
@@ -281,6 +296,7 @@
  * HVAC, target temperature set.
  * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
+ * @config_flags Supported zones
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
  * @data_member hvac.temperature_set
  */
@@ -291,6 +307,7 @@
  * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Supported zones
  * @data_member hvac.defrost_on
  */
 #define VEHICLE_PROPERTY_HVAC_DEFROSTER                             (0x00000504)
@@ -300,11 +317,48 @@
  * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Supported zones
  * @data_member hvac.ac_on
  */
 #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
@@ -335,6 +389,7 @@
  * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Number of presets supported
  * @data_member int32_array
  */
 #define VEHICLE_PROPERTY_RADIO_PRESET                               (0x0000801)
@@ -353,7 +408,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 +421,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
@@ -485,10 +540,10 @@
 };
 
 /**
- * Property to control audio volume of each stream.
+ * Property to control audio volume of each audio context.
  *
  * Data type looks like:
- *   int32_array[0] : stream number (not bit flag) like VEHICLE_AUDIO_STREAM0.
+ *   int32_array[0] : stream context as defined in vehicle_audio_context_flag.
  *   int32_array[1] : volume level, valid range is 0 to int32_max_value defined in config.
  *                    0 will be mute state. int32_min_value in config should be always 0.
  *   int32_array[2] : One of vehicle_audio_volume_state.
@@ -499,6 +554,7 @@
  * @value_type VEHICLE_VALUE_TYPE_INT32_VEC3
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags all audio contexts supported.
  * @data_member int32_array
  */
 #define VEHICLE_PROPERTY_AUDIO_VOLUME                                 (0x00000901)
@@ -526,8 +582,8 @@
 
 /**
  * Property for handling volume limit set by user. This limits maximum volume that can be set
- * per each volume.
- *   int32_array[0] : stream number (not bit flag) like VEHICLE_AUDIO_STREAM0.
+ * per each context.
+ *   int32_array[0] : stream context as defined in vehicle_audio_context_flag.
  *   int32_array[1] : maximum volume set to the stream. If there is no restriction, this value
  *                    will be  bigger than VEHICLE_PROPERTY_AUDIO_VOLUME's max value.
  *
@@ -538,6 +594,7 @@
  * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags all audio contexts supported.
  * @data_member int32_array
  */
 #define VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT                           (0x00000902)
@@ -558,8 +615,8 @@
  *   int32_array[0] : audio stream where the audio for the application context will be routed
  *                    by default. Note that this is the default setting from system, but each app
  *                    may still use different audio stream for whatever reason.
- *   int32_array[1] : All application contexts that will be sent through the physical stream. Flag
- *                    is defined in vehicle_app_context_flag.
+ *   int32_array[1] : All audio contexts that will be sent through the physical stream. Flag
+ *                    is defined in vehicle_audio_context_flag.
 
  * Setting of this property will be done for all available physical streams based on audio H/W
  * variant information acquired from VEHICLE_PROPERTY_AUDIO_HW_VARIANT property.
@@ -588,6 +645,8 @@
 * @value_type VEHICLE_VALUE_TYPE_INT32
 * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC
 * @access VEHICLE_PROP_ACCESS_READ
+* @config_flags Additional info on audio H/W. Should use vehicle_audio_hw_variant_config_flag for
+*               this.
 * @data_member int32_value
 */
 #define VEHICLE_PROPERTY_AUDIO_HW_VARIANT                             (0x00000904)
@@ -608,6 +667,48 @@
 };
 
 /**
+ * Property to share currently active audio context in android side.
+ * This can be used as a hint to adjust audio policy or other policy decision. Note that there
+ * can be multiple context active at the same time.
+ *
+ * @value_type VEHICLE_VALUE_TYPE_INT32
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_WRITE
+ * @data_member int32
+ */
+#define VEHICLE_PROPERTY_AUDIO_CONTEXT                        (0x00000905)
+/**
+ * Flags to tell the current audio context.
+ */
+enum vehicle_audio_context_flag {
+    /** Music playback is currently active. */
+    VEHICLE_AUDIO_CONTEXT_MUSIC_FLAG                      = 0x1,
+    /** Navigation is currently running. */
+    VEHICLE_AUDIO_CONTEXT_NAVIGATION_FLAG                 = 0x2,
+    /** Voice command session is currently running. */
+    VEHICLE_AUDIO_CONTEXT_VOICE_COMMAND_FLAG              = 0x4,
+    /** Voice call is currently active. */
+    VEHICLE_AUDIO_CONTEXT_CALL_FLAG                       = 0x8,
+    /** Alarm is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. */
+    VEHICLE_AUDIO_CONTEXT_ALARM_FLAG                      = 0x10,
+    /**
+     * Notification sound is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY.
+     */
+    VEHICLE_AUDIO_CONTEXT_NOTIFICATION_FLAG               = 0x20,
+    /**
+     * Context unknown. Only used for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY to represent default
+     * stream for unknown contents.
+     */
+    VEHICLE_AUDIO_CONTEXT_UNKNOWN_FLAG                    = 0x40,
+    /** Safety alert / warning is played. */
+    VEHICLE_AUDIO_CONTEXT_SAFETY_ALERT_FLAG               = 0x80,
+    /** CD / DVD kind of audio is played */
+    VEHICLE_AUDIO_CONTEXT_CD_ROM                         = 0x100,
+    /** Aux audio input is played */
+    VEHICLE_AUDIO_CONTEXT_AUX_AUDIO                      = 0x200,
+};
+
+/**
  * Property to control power state of application processor.
  *
  * It is assumed that AP's power state is controller by separate power controller.
@@ -625,6 +726,7 @@
  * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
  * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_flags Additional info on power state. Should use vehicle_ap_power_state_config_flag.
  * @data_member int32_array
  */
 #define VEHICLE_PROPERTY_AP_POWER_STATE                               (0x00000A00)
@@ -780,42 +882,6 @@
 };
 
 /**
- * Property to share currently active application context in android side.
- * This can be used as a hint to adjust audio policy or other policy decision. Note that there
- * can be multiple context active at the same time.
- *
- * @value_type VEHICLE_VALUE_TYPE_INT32
- * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
- * @access VEHICLE_PROP_ACCESS_WRITE
- * @data_member int32
- */
-#define VEHICLE_PROPERTY_APP_CONTEXT                        (0x00000B00)
-/**
- * Flags to tell the current application context. The same flag is used in
- */
-enum vehicle_app_context_flag {
-    /** Music playback is currently active. */
-    VEHICLE_APP_CONTEXT_MUSIC_FLAG = 0x1,
-    /** Navigation is currently running. */
-    VEHICLE_APP_CONTEXT_NAVIGATION_FLAG = 0x2,
-    /** Voice command session is currently running. */
-    VEHICLE_APP_CONTEXT_VOICE_COMMAND_FLAG = 0x4,
-    /** Voice call is currently active. */
-    VEHICLE_APP_CONTEXT_CALL_FLAG = 0x8,
-    /** Alarm is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. */
-    VEHICLE_APP_CONTEXT_ALARM_FLAG = 0x10,
-    /**
-     * Notification sound is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY.
-     */
-    VEHICLE_APP_CONTEXT_NOTIFICATION_FLAG = 0x20,
-    /**
-     * Context unknown. Only used for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY to represent default
-     * stream for unknown contents.
-     */
-    VEHICLE_APP_CONTEXT_UNKNOWN_FLAG = 0x40,
-};
-
-/**
  *  H/W specific, non-standard property can be added as necessary. Such property should use
  *  property number in range of [VEHICLE_PROPERTY_CUSTOM_START, VEHICLE_PROPERTY_CUSTOM_END].
  *  Definition of property in this range is completely up to each HAL implementation.
@@ -824,20 +890,20 @@
  *  include config_string of "com.XYZ.some_further_details".
  *  @range_start
  */
-#define VEHICLE_PROPERTY_CUSTOM_START                       (0xf0000000)
+#define VEHICLE_PROPERTY_CUSTOM_START                       (0x70000000)
 /** @range_end */
-#define VEHICLE_PROPERTY_CUSTOM_END                         (0xf7ffffff)
+#define VEHICLE_PROPERTY_CUSTOM_END                         (0x73ffffff)
 
 /**
  * Property range allocated for system's internal usage like testing. HAL should never declare
  * property in this range.
  * @range_start
  */
-#define VEHICLE_PROPERTY_INTERNAL_START                     (0xf8000000)
+#define VEHICLE_PROPERTY_INTERNAL_START                     (0x74000000)
 /**
  * @range_end
  */
-#define VEHICLE_PROPERTY_INTERNAL_END                       (0xf8ffffff)
+#define VEHICLE_PROPERTY_INTERNAL_END                       (0x74ffffff)
 
 /**
  * Value types for various properties.
@@ -847,10 +913,8 @@
     VEHICLE_VALUE_TYPE_STRING                   = 0x01,
     VEHICLE_VALUE_TYPE_BYTES                    = 0x02,
     VEHICLE_VALUE_TYPE_BOOLEAN                  = 0x03,
-    VEHICLE_VALUE_TYPE_ZONED_INT32              = 0x04,
-    VEHICLE_VALUE_TYPE_ZONED_FLOAT              = 0x05,
-    VEHICLE_VALUE_TYPE_ZONED_BOOLEAN            = 0x06,
-    VEHICLE_VALUE_TYPE_INT64                    = 0x07,
+    VEHICLE_VALUE_TYPE_ZONED_BOOLEAN            = 0x04,
+    VEHICLE_VALUE_TYPE_INT64                    = 0x05,
     VEHICLE_VALUE_TYPE_FLOAT                    = 0x10,
     VEHICLE_VALUE_TYPE_FLOAT_VEC2               = 0x11,
     VEHICLE_VALUE_TYPE_FLOAT_VEC3               = 0x12,
@@ -859,6 +923,12 @@
     VEHICLE_VALUE_TYPE_INT32_VEC2               = 0x21,
     VEHICLE_VALUE_TYPE_INT32_VEC3               = 0x22,
     VEHICLE_VALUE_TYPE_INT32_VEC4               = 0x23,
+    VEHICLE_VALUE_TYPE_ZONED_FLOAT              = 0x30,
+    VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC2         = 0x31,
+    VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC3         = 0x32,
+    VEHICLE_VALUE_TYPE_ZONED_INT32              = 0x40,
+    VEHICLE_VALUE_TYPE_ZONED_INT32_VEC2         = 0x41,
+    VEHICLE_VALUE_TYPE_ZONED_INT32_VEC3         = 0x42,
 };
 
 /**
@@ -1106,6 +1176,15 @@
     int32_t value;
 } vehicle_zoned_int32_t;
 
+typedef struct vehicle_zoned_int32_array {
+    union {
+        int32_t zone;
+        int32_t seat;
+        int32_t window;
+    };
+    int32_t values[3];
+} vehicle_zoned_int32_array_t;
+
 typedef struct vehicle_zoned_float {
     union {
         int32_t zone;
@@ -1115,6 +1194,15 @@
     float value;
 } vehicle_zoned_float_t;
 
+typedef struct vehicle_zoned_float_array {
+    union {
+        int32_t zone;
+        int32_t seat;
+        int32_t window;
+    };
+    float values[3];
+} vehicle_zoned_float_array_t;
+
 typedef struct vehicle_zoned_boolean {
     union {
         int32_t zone;
@@ -1174,6 +1262,7 @@
          * from 1 (see VEHICLE_RADIO_PRESET_MIN_VALUE) to vehicle_radio_num_presets.
          */
         int32_t vehicle_radio_num_presets;
+        int32_t config_array[4];
     };
 
     /**
@@ -1242,6 +1331,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 +1355,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;
@@ -1297,7 +1398,9 @@
     vehicle_bytes_t bytes_value;
     vehicle_boolean_t boolean_value;
     vehicle_zoned_int32_t zoned_int32_value;
+    vehicle_zoned_int32_array_t zoned_int32_array;
     vehicle_zoned_float_t zoned_float_value;
+    vehicle_zoned_float_array_t zoned_float_array;
     vehicle_zoned_boolean_t zoned_boolean_value;
 
     // Vehicle Information.
@@ -1452,7 +1555,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
@@ -1480,8 +1584,11 @@
      * @param device
      * @param prop
      * @param sample_rate
+     * @param zones All subscribed zones for zoned property. can be ignored for non-zoned property.
+     *              0 means all zones supported instead of no zone.
      */
-    int (*subscribe)(struct vehicle_hw_device* device, int32_t prop, float sample_rate);
+    int (*subscribe)(struct vehicle_hw_device* device, int32_t prop, float sample_rate,
+            int32_t zones);
 
     /** Cancel subscription on a property. */
     int (*unsubscribe)(struct vehicle_hw_device* device, int32_t prop);
diff --git a/modules/Android.mk b/modules/Android.mk
index 4f30d3c..a77188d 100644
--- a/modules/Android.mk
+++ b/modules/Android.mk
@@ -1,4 +1,4 @@
 hardware_modules := gralloc hwcomposer audio nfc nfc-nci local_time \
 	power usbaudio audio_remote_submix camera usbcamera consumerir sensors vibrator \
-	tv_input fingerprint input vehicle
+	tv_input fingerprint input vehicle hardware_properties
 include $(call all-named-subdir-makefiles,$(hardware_modules))
diff --git a/modules/hardware_properties/Android.mk b/modules/hardware_properties/Android.mk
new file mode 100644
index 0000000..41c02ea
--- /dev/null
+++ b/modules/hardware_properties/Android.mk
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := hardware_properties.default
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := hardware_properties.c
+LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/modules/hardware_properties/hardware_properties.c b/modules/hardware_properties/hardware_properties.c
new file mode 100644
index 0000000..89ef423
--- /dev/null
+++ b/modules/hardware_properties/hardware_properties.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2015 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 <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define LOG_TAG "HardwarePropertiesHAL"
+#include <utils/Log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/hardware_properties.h>
+
+static ssize_t get_device_temperatures(
+    struct hardware_properties_module *module, float **temps) {
+    *temps = NULL;
+    errno = ENOSYS;
+    ALOGE("getDeviceTemperatures: %s", strerror(errno));
+    return -1;
+}
+
+static ssize_t get_cpu_usages(struct hardware_properties_module *module,
+                              int64_t **active_times, int64_t **total_times) {
+    *active_times = NULL;
+    *total_times = NULL;
+    errno = ENOSYS;
+    ALOGE("getCpuUsages: %s", strerror(errno));
+    return -1;
+}
+
+static ssize_t get_fan_speeds(struct hardware_properties_module *module,
+                              float **fan_speeds) {
+    *fan_speeds = NULL;
+    errno = ENOSYS;
+    ALOGE("getFanSpeeds: %s", strerror(errno));
+    return -1;
+}
+
+static struct hw_module_methods_t hardware_properties_module_methods = {
+    .open = NULL,
+};
+
+struct hardware_properties_module HAL_MODULE_INFO_SYM = {
+    .common = {
+        .tag = HARDWARE_MODULE_TAG,
+        .module_api_version = HARDWARE_PROPERTIES_HARDWARE_MODULE_API_VERSION_0_1,
+        .hal_api_version = HARDWARE_HAL_API_VERSION,
+        .id = HARDWARE_PROPERTIES_HARDWARE_MODULE_ID,
+        .name = "Default Hardware Properties HAL",
+        .author = "The Android Open Source Project",
+        .methods = &hardware_properties_module_methods,
+    },
+
+    .getCpuTemperatures = get_device_temperatures,
+    .getGpuTemperatures = get_device_temperatures,
+    .getBatteryTemperatures = get_device_temperatures,
+    .getCpuUsages = get_cpu_usages,
+    .getFanSpeeds = get_fan_speeds,
+};
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/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index d0d43ab..d899d6b 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -55,11 +55,6 @@
 
 #define DEFAULT_INPUT_BUFFER_SIZE_MS 20
 
-// stereo channel count
-#define FCC_2 2
-// fixed channel count of 8 limitation (for data processing in AudioFlinger)
-#define FCC_8 8
-
 struct audio_device {
     struct audio_hw_device hw_device;
 
diff --git a/modules/vehicle/vehicle.c b/modules/vehicle/vehicle.c
index 69bfad3..38c38ee 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) {
@@ -369,6 +372,10 @@
                 }
                 break;
             default: // unsupported
+                if (sub->impl == NULL) {
+                    ALOGE("subscription impl NULL");
+                    return;
+                }
                 if (sub->impl->error_fn_ != NULL) {
                     sub->impl->error_fn_(VEHICLE_ERROR_UNKNOWN, VEHICLE_PROPERTY_INVALID,
                             VEHICLE_OPERATION_GENERIC);
@@ -399,7 +406,8 @@
     }
 }
 
-static int vdev_subscribe(vehicle_hw_device_t* device, int32_t prop, float sample_rate) {
+static int vdev_subscribe(vehicle_hw_device_t* device, int32_t prop, float sample_rate,
+        int32_t zones) {
     ALOGD("vdev_subscribe 0x%x, %f", prop, sample_rate);
     vehicle_device_impl_t* impl = (vehicle_device_impl_t*)device;
     // Check that the device is initialized.
@@ -457,7 +465,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 +517,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/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],
diff --git a/tests/vehicle/vehicle-hal-tool.c b/tests/vehicle/vehicle-hal-tool.c
index 78fd714..d10a7b9 100755
--- a/tests/vehicle/vehicle-hal-tool.c
+++ b/tests/vehicle/vehicle-hal-tool.c
@@ -292,7 +292,7 @@
     uint32_t wait_in_seconds) {
     // Init the device with a callback.
     device->init(device, vehicle_event_callback, vehicle_error_callback);
-    int ret_code = device->subscribe(device, prop, 0);
+    int ret_code = device->subscribe(device, prop, 0, 0);
     if (ret_code != 0) {
         printf("Could not subscribe: %d\n", ret_code);
         exit(1);
@@ -355,6 +355,7 @@
     char int_array_string[1000]; int_array_string[0] = '\0';
 
     int opt;
+    //TODO allow passing zone
     while ((opt = getopt(argc, argv, "lm:p:t:v:w:s:")) != -1) {
         switch (opt) {
             case 'l':
diff --git a/tests/vehicle/vehicle_tests.cpp b/tests/vehicle/vehicle_tests.cpp
index 5862972..4c15570 100644
--- a/tests/vehicle/vehicle_tests.cpp
+++ b/tests/vehicle/vehicle_tests.cpp
@@ -99,7 +99,7 @@
 TEST_F(VehicleDevice, subscribeTest) {
     // If the device is not init subscribe should fail off the bat.
     int ret_code = vehicle_device()->subscribe(vehicle_device(), VEHICLE_PROPERTY_DRIVING_STATUS,
-            0);
+            0, 0);
     ASSERT_EQ(ret_code, -EINVAL) << "Return code is: " << ret_code;
 
     // Let's init the device.
@@ -107,7 +107,7 @@
     ASSERT_EQ(ret_code, 0) << "Return code is: " << ret_code;
 
     // Subscribe should now go through.
-    ret_code = vehicle_device()->subscribe(vehicle_device(), VEHICLE_PROPERTY_DRIVING_STATUS, 0);
+    ret_code = vehicle_device()->subscribe(vehicle_device(), VEHICLE_PROPERTY_DRIVING_STATUS, 0, 0);
     ASSERT_EQ(ret_code, 0) << "Return code is: " << ret_code;
 
     // We should start getting some messages thrown from the callback. Let's