Merge "HWC2: Add getHdrCapabilities" into nyc-dev
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 593d30c..1349114 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -463,7 +463,7 @@
     int (*init)(bt_callbacks_t* callbacks );
 
     /** Enable Bluetooth. */
-    int (*enable)(bool);
+    int (*enable)(void);
 
     /** Disable Bluetooth. */
     int (*disable)(void);
diff --git a/include/hardware/context_hub.h b/include/hardware/context_hub.h
index aa7e253..79054d2 100644
--- a/include/hardware/context_hub.h
+++ b/include/hardware/context_hub.h
@@ -46,8 +46,13 @@
 
 /*****************************************************************************/
 
-#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)
+#define CONTEXT_HUB_HEADER_MAJOR_VERSION          1
+#define CONTEXT_HUB_HEADER_MINOR_VERSION          0
+#define CONTEXT_HUB_DEVICE_API_VERSION \
+     HARDWARE_DEVICE_API_VERSION(CONTEXT_HUB_HEADER_MAJOR_VERSION, \
+                                 CONTEXT_HUB_HEADER_MINOR_VERSION)
+
+#define CONTEXT_HUB_DEVICE_API_VERSION_1_0  HARDWARE_DEVICE_API_VERSION(1, 0)
 
 /**
  * The id of this module
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index a2d9b2e..14b8aa5 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -116,6 +116,35 @@
     SENSOR_HAL_DATA_INJECTION_MODE      = 0x1
 };
 
+#define SENSOR_FLAG_MASK(nbit, shift)   (((1<<(nbit))-1)<<(shift))
+#define SENSOR_FLAG_MASK_1(shift)       SENSOR_FLAG_MASK(1, shift)
+
+/*
+ * Mask and shift for reporting mode sensor flags defined above.
+ */
+#define REPORTING_MODE_SHIFT            (1)
+#define REPORTING_MODE_NBIT             (3)
+#define REPORTING_MODE_MASK             SENSOR_FLAG_MASK(REPORTING_MODE_NBIT, REPORTING_MODE_SHIFT)
+                                        // 0xE
+
+/*
+ * Mask and shift for data_injection mode sensor flags defined above.
+ */
+#define DATA_INJECTION_SHIFT            (4)
+#define DATA_INJECTION_MASK             SENSOR_FLAG_MASK_1(DATA_INJECTION_SHIFT) //0x10
+
+/*
+ * Mask and shift for dynamic sensor flag.
+ */
+#define DYNAMIC_SENSOR_SHIFT            (5)
+#define DYNAMIC_SENSOR_MASK             SENSOR_FLAG_MASK_1(DYNAMIC_SENSOR_SHIFT) //0x20
+
+/*
+ * Mask and shift for sensor additional information support.
+ */
+#define ADDITIONAL_INFO_SHIFT           (6)
+#define ADDITIONAL_INFO_MASK            SENSOR_FLAG_MASK_1(ADDITIONAL_INFO_SHIFT) //0x40
+
 /*
  * Availability: SENSORS_DEVICE_API_VERSION_1_3
  * Sensor flags used in sensor_t.flags.
@@ -147,20 +176,21 @@
      * Counter sensors can be set with this flag and SensorService will inject accelerometer data
      * and read the corresponding step counts.
      */
-    SENSOR_FLAG_SUPPORTS_DATA_INJECTION = 0x10  // 1 0000
+    SENSOR_FLAG_SUPPORTS_DATA_INJECTION = DATA_INJECTION_MASK, // 1 0000
+
+    /*
+     * Set this flag if the sensor is a dynamically connected sensor. See
+     * dynamic_sensor_meta_event_t and SENSOR_TYPE_DYNAMIC_SENSOR_META for details.
+     */
+    SENSOR_FLAG_DYNAMIC_SENSOR = DYNAMIC_SENSOR_MASK,
+
+    /*
+     * Set this flag if sensor additional information is supported. See SENSOR_TYPE_ADDITIONAL_INFO
+     * and additional_info_event_t for details.
+     */
+    SENSOR_FLAG_ADDITIONAL_INFO = ADDITIONAL_INFO_MASK
 };
 
-/*
- * Mask and shift for reporting mode sensor flags defined above.
- */
-#define REPORTING_MODE_MASK              (0xE)
-#define REPORTING_MODE_SHIFT             (1)
-
-/*
- * Mask and shift for data_injection mode sensor flags defined above.
- */
-#define DATA_INJECTION_MASK              (0x10)
-#define DATA_INJECTION_SHIFT             (4)
 
 /*
  * Sensor type
diff --git a/include/hardware/sound_trigger.h b/include/hardware/sound_trigger.h
index 2a8db87..e1abbc9 100644
--- a/include/hardware/sound_trigger.h
+++ b/include/hardware/sound_trigger.h
@@ -39,7 +39,8 @@
 
 
 #define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
-#define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0
+#define SOUND_TRIGGER_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
+#define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_1
 
 /**
  * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL
@@ -106,7 +107,13 @@
      * The implementation does not have to call the callback when stopped via this method.
      */
     int (*stop_recognition)(const struct sound_trigger_hw_device *dev,
-                           sound_model_handle_t sound_model_handle);
+                            sound_model_handle_t sound_model_handle);
+
+    /* Stop recognition on all models.
+     * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_1 or above.
+     * If no implementation is provided, stop_recognition will be called for each running model.
+     */
+    int (*stop_all_recognitions)(const struct sound_trigger_hw_device* dev);
 };
 
 typedef struct sound_trigger_hw_device sound_trigger_hw_device_t;
diff --git a/include/hardware/thermal.h b/include/hardware/thermal.h
index 7fdf682..e7189e2 100644
--- a/include/hardware/thermal.h
+++ b/include/hardware/thermal.h
@@ -80,6 +80,13 @@
    * If not available, set by HAL to UNKNOWN_TEMPERATURE.
    */
   float shutdown_threshold;
+
+  /**
+   * Threshold temperature at which VR mode clockrate minumums cannot be
+   * maintained for this device temperature type.
+   * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+   */
+  float vr_throttling_threshold;
 } temperature_t;
 
 typedef struct {
@@ -193,6 +200,7 @@
      */
     ssize_t (*getCoolingDevices)(struct thermal_module *module, cooling_device_t *list,
                                  size_t size);
+
 } thermal_module_t;
 
 __END_DECLS
diff --git a/include/hardware/vehicle.h b/include/hardware/vehicle.h
index 9086d1c..e767593 100644
--- a/include/hardware/vehicle.h
+++ b/include/hardware/vehicle.h
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <sys/cdefs.h>
 #include <sys/types.h>
+#include <math.h>
 #include <errno.h>
 
 #include <hardware/hardware.h>
@@ -75,6 +76,8 @@
  *                 for that property to work.
  * @zone_type type of zoned used. defined for zoned property
  * @range_start, @range_end : define range of specific property values.
+ * @allow_out_of_range_value : This property allows out of range value to deliver additional
+ *                             information. Check VEHICLE_*_OUT_OF_RANGE_* for applicable values.
  */
 //===== Vehicle Information ====
 
@@ -257,10 +260,10 @@
  * @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
  * @zone_type VEHICLE_ZONE
  * @data_enum TODO
+ * @allow_out_of_range_value : OFF
  */
 #define VEHICLE_PROPERTY_HVAC_FAN_SPEED                             (0x00000500)
 
@@ -269,10 +272,10 @@
  * @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
  * @zone_type VEHICLE_ZONE
  * @data_enum TODO
+ * @allow_out_of_range_value : OFF
  */
 #define VEHICLE_PROPERTY_HVAC_FAN_DIRECTION                         (0x00000501)
 
@@ -292,7 +295,6 @@
  * @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
  * @zone_type VEHICLE_ZONE
  * @data_member hvac.temperature_current
  */
@@ -302,10 +304,10 @@
  * 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
  * @zone_type VEHICLE_ZONE
  * @data_member hvac.temperature_set
+ * @allow_out_of_range_value : MIN / MAX / OFF
  */
 #define VEHICLE_PROPERTY_HVAC_TEMPERATURE_SET                       (0x00000503)
 
@@ -314,7 +316,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
+ * @zone_type VEHICLE_WINDOW
  * @data_member hvac.defrost_on
  */
 #define VEHICLE_PROPERTY_HVAC_DEFROSTER                             (0x00000504)
@@ -367,6 +369,22 @@
 #define VEHICLE_PROPERTY_HVAC_DUAL_ON                               (0x00000509)
 
 /**
+ * Represents power state for HVAC. Some HVAC properties will require matching power to be turned on
+ * to get out of OFF state. For non-zoned HVAC properties, VEHICLE_ALL_ZONE corresponds to
+ * global power state.
+ *
+ * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_READ_WRITE
+ * @config_string list of HVAC properties whose power is controlled by this property. Format is
+ *                hexa-decimal number (0x...) separated by comma like "0x500,0x503". All zones
+ *                defined in these affected properties should be available in the property.
+ * @zone_type VEHICLE_ZONE
+ * @data_member hvac.power_on
+ */
+#define VEHICLE_PROPERTY_HVAC_POWER_ON                              (0x00000510)
+
+/**
  * Outside temperature
  * @value_type VEHICLE_VALUE_TYPE_FLOAT
  * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
@@ -374,6 +392,7 @@
  * @data_member outside_temperature
  * @unit VEHICLE_UNIT_TYPE_CELCIUS
  */
+
 #define VEHICLE_PROPERTY_ENV_OUTSIDE_TEMPERATURE                   (0x00000703)
 
 
@@ -431,10 +450,16 @@
  *   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
- *                   VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG can be used.
- *                   This is for case like radio where android side app still needs to hold focus
- *                   but playback is done outside Android.
- *   int32_array[3]: Currently active audio contexts in android side. Use combination of flags from
+ *                   VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG or
+ *                   VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG can be used.
+ *                   VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG is for case like radio where android
+ *                   side app still needs to hold focus but playback is done outside Android.
+ *                   VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG is for muting media channel
+ *                   including radio. VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG can be set even
+ *                   if android side releases focus (request type REQUEST_RELEASE). In that case,
+ *                   audio module should maintain mute state until user's explicit action to
+ *                   play some media.
+ *   int32_array[3]: Currently active audio contexts. Use combination of flags from
  *                   vehicle_audio_context_flag.
  *                   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. And android
@@ -559,6 +584,11 @@
      * side and car side can play radio any time while this flag is active.
      */
     VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG = 0x4,
+    /**
+     * Car side should mute any media including radio. This can be used with any focus request
+     * including GAIN* and RELEASE.
+     */
+    VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG = 0x8,
 };
 
 /**
@@ -723,14 +753,13 @@
  */
 enum vehicle_audio_hw_variant_config_flag {
     /**
-     * This is a flag to disable the default behavior of not sending focus request for radio module.
-     * By default, when radio app request audio focus, that focus request is filtered out and
-     * is not sent to car audio module as radio is supposed to be played by car radio module and
-     * android side should have have audio focus for media stream.
-     * But in some H/W, radio may be directly played from android side, and in that case,
-     * android side should take focus for media stream. This flag should be enabled in such case.
+     * Flag to tell that radio is internal to android and radio should
+     * be treated like other android stream like media.
+     * When this flag is not set or AUDIO_HW_VARIANT does not exist,
+     * radio is treated as external module. This brins some delta in audio focus
+     * handling as well.
      */
-    VEHICLE_AUDIO_HW_VARIANT_FLAG_PASS_RADIO_AUDIO_FOCUS_FLAG = 0x1,
+    VEHICLE_AUDIO_HW_VARIANT_FLAG_INTERNAL_RADIO_FLAG = 0x1,
 };
 
 
@@ -1116,6 +1145,24 @@
     VEHICLE_PERMISSION_OEM_OR_SYSTEM_APP = 0x3
 };
 
+
+/**
+ *  Special values for INT32/FLOAT (including ZONED types)
+ *  These values represent special state, which is outside MIN/MAX range but can happen.
+ *  For example, HVAC temperature may use out of range min / max to represent that
+ *  it is working in full power although target temperature has separate min / max.
+ *  OUT_OF_RANGE_OFF can represent a state where the property is powered off.
+ *  Usually such property will have separate property to control power.
+ */
+
+#define VEHICLE_INT_OUT_OF_RANGE_MAX (INT32_MAX)
+#define VEHICLE_INT_OUT_OF_RANGE_MIN (INT32_MIN)
+#define VEHICLE_INT_OUT_OF_RANGE_OFF (INT32_MIN + 1)
+
+#define VEHICLE_FLOAT_OUT_OF_RANGE_MAX (INFINITY)
+#define VEHICLE_FLOAT_OUT_OF_RANGE_MIN (-INFINITY)
+#define VEHICLE_INT_OUT_OF_RANGE_OFF (NAN)
+
 /**
  * Car states.
  *
@@ -1417,6 +1464,7 @@
         vehicle_boolean_t max_defrost_on;
         vehicle_boolean_t recirc_on;
         vehicle_boolean_t dual_on;
+        vehicle_boolean_t power_on;
 
         float temperature_current;
         float temperature_set;
@@ -1645,6 +1693,9 @@
      * NULL.
      * The caller of the API OWNS the data field.
      * timestamp of data will be ignored for set operation.
+     * Setting some properties require having initial state available. Depending on the vehicle hal,
+     * such initial data may not be available for short time after init. In such case, set call
+     * can return -EAGAIN like get call.
      */
     int (*set)(struct vehicle_hw_device* device, const vehicle_prop_value_t *data);
 
@@ -1654,8 +1705,9 @@
      * a) on-change: sample_rate should be set to 0.
      * b) supports frequency: sample_rate should be set from min_sample_rate to
      * max_sample_rate.
-     * Subscribing to properties in-correctly may result in error callbacks and
-     * will depend on HAL implementation.
+     * For on-change type of properties, vehicle network service will make another get call to check
+     * the initial state. Due to this, vehicle hal implementation does not need to send initial
+     * state for on-change type of properties.
      * @param device
      * @param prop
      * @param sample_rate
@@ -1667,6 +1719,24 @@
 
     /** Cancel subscription on a property. */
     int (*unsubscribe)(struct vehicle_hw_device* device, int32_t prop);
+
+    /**
+     * Print out debugging state for the vehicle hal. This will be called by
+     * the vehicle network service and will be included into the service' dump.
+     *
+     * The passed-in file descriptor can be used to write debugging text using
+     * dprintf() or write(). The text should be in ASCII encoding only.
+     *
+     * Performance requirements:
+     *
+     * This must be a non-blocking call. The HAL should return from this call
+     * in 1ms, must return from this call in 10ms. This call must avoid
+     * deadlocks, as it may be called at any point of operation.
+     * Any synchronization primitives used (such as mutex locks or semaphores)
+     * should be acquired with a timeout.
+     */
+    int (*dump)(struct vehicle_hw_device* device, int fd);
+
 } vehicle_hw_device_t;
 
 __END_DECLS
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index 912be1f..d47cfba 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -1573,7 +1573,7 @@
 
     status_t res = submix_get_route_idx_for_address_l(rsxadev, address, &route_idx);
     if (res != OK) {
-        ALOGE("Error %d looking for address=%s in adev_open_output_stream", res, address);
+        ALOGE("Error %d looking for address=%s in adev_open_input_stream", res, address);
         pthread_mutex_unlock(&rsxadev->lock);
         return res;
     }
diff --git a/modules/soundtrigger/sound_trigger_hw.c b/modules/soundtrigger/sound_trigger_hw.c
index dadad82..0492fd5 100644
--- a/modules/soundtrigger/sound_trigger_hw.c
+++ b/modules/soundtrigger/sound_trigger_hw.c
@@ -36,6 +36,9 @@
 #define LOG_NDEBUG 1
 #define PARSE_BUF_LEN 1024  // Length of the parsing buffer.S
 
+#define EVENT_RECOGNITION 1
+#define EVENT_SOUND_MODEL 2
+
 // The following commands work with the network port:
 #define COMMAND_LS "ls"
 #define COMMAND_RECOGNITION_TRIGGER "trig"  // Argument: model index.
@@ -156,6 +159,42 @@
     return true;
 }
 
+void write_bad_command_error(int conn_socket, char* command) {
+    int num = snprintf(tmp_write_buffer, PARSE_BUF_LEN, "Bad command received: %s", command);
+    tmp_write_buffer[PARSE_BUF_LEN - 1] = '\0';  // Just to be sure.
+    tmp_write_buffer[PARSE_BUF_LEN - 2] = '\n';
+    write(conn_socket, tmp_write_buffer, num);
+}
+
+void write_string(int conn_socket, char* str) {
+    int num = snprintf(tmp_write_buffer, PARSE_BUF_LEN, "%s", str);
+    tmp_write_buffer[PARSE_BUF_LEN - 1] = '\0';
+    tmp_write_buffer[PARSE_BUF_LEN - 2] = '\n';
+    write(conn_socket, tmp_write_buffer, num);
+}
+
+void write_vastr(int conn_socket, char* format, ...) {
+    va_list argptr;
+    va_start(argptr, format);
+    int num = vsnprintf(tmp_write_buffer, PARSE_BUF_LEN, format, argptr);
+    va_end(argptr);
+    tmp_write_buffer[PARSE_BUF_LEN - 1] = '\0';
+    tmp_write_buffer[PARSE_BUF_LEN - 2] = '\n';
+    write(conn_socket, tmp_write_buffer, num);
+}
+
+static void print_uuid(sound_trigger_uuid_t uuid) {
+    ALOGI("%s %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", __func__, uuid.timeLow, uuid.timeMid,
+          uuid.timeHiAndVersion, uuid.clockSeq, uuid.node[0], uuid.node[1], uuid.node[2],
+          uuid.node[3], uuid.node[4], uuid.node[5]);
+}
+
+static void write_uuid(int conn_socket, sound_trigger_uuid_t uuid) {
+    write_vastr(conn_socket, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x\n", uuid.timeLow, uuid.timeMid,
+                uuid.timeHiAndVersion, uuid.clockSeq, uuid.node[0], uuid.node[1], uuid.node[2],
+                uuid.node[3], uuid.node[4], uuid.node[5]);
+}
+
 // Returns model at the given index, null otherwise (error, doesn't exist, etc).
 // Note that here index starts from zero.
 struct recognition_context* fetch_model_with_handle(
@@ -262,123 +301,76 @@
     return data;
 }
 
-void write_bad_command_error(int conn_socket, char* command) {
-    int num = snprintf(tmp_write_buffer, PARSE_BUF_LEN, "Bad command received: %s", command);
-    tmp_write_buffer[PARSE_BUF_LEN - 1] = '\0';  // Just to be sure.
-    tmp_write_buffer[PARSE_BUF_LEN - 2] = '\n';
-    write(conn_socket, tmp_write_buffer, num);
-}
-
-void write_string(int conn_socket, char* str) {
-    int num = snprintf(tmp_write_buffer, PARSE_BUF_LEN, "%s", str);
-    tmp_write_buffer[PARSE_BUF_LEN - 1] = '\0';
-    tmp_write_buffer[PARSE_BUF_LEN - 2] = '\n';
-    write(conn_socket, tmp_write_buffer, num);
-}
-
-void write_vastr(int conn_socket, char* format, ...) {
-    va_list argptr;
-    va_start(argptr, format);
-    int num = vsnprintf(tmp_write_buffer, PARSE_BUF_LEN, format, argptr);
-    va_end(argptr);
-    tmp_write_buffer[PARSE_BUF_LEN - 1] = '\0';
-    tmp_write_buffer[PARSE_BUF_LEN - 2] = '\n';
-    write(conn_socket, tmp_write_buffer, num);
-}
-
-static void print_uuid(sound_trigger_uuid_t uuid) {
-    ALOGI("%s %x-%x-%x-%x-%x%x%x%x%x%x", __func__, uuid.timeLow, uuid.timeMid,
-          uuid.timeHiAndVersion, uuid.clockSeq, uuid.node[0], uuid.node[1], uuid.node[2],
-          uuid.node[3], uuid.node[4], uuid.node[5]);
-}
-
-static void write_uuid(int conn_socket, sound_trigger_uuid_t uuid) {
-    write_vastr(conn_socket, "%d-%x-%x-%x-%x%x%x%x%x%x\n", uuid.timeLow, uuid.timeMid,
-                uuid.timeHiAndVersion, uuid.clockSeq, uuid.node[0], uuid.node[1], uuid.node[2],
-                uuid.node[3], uuid.node[4], uuid.node[5]);
-}
-
-void send_recognition_event_with_handle(int conn_socket, sound_model_handle_t* model_handle_str,
-                                        struct stub_sound_trigger_device* stdev,
-                                        int recognition_status) {
+void send_event_with_handle(sound_model_handle_t* model_handle_str,
+                            struct stub_sound_trigger_device* stdev, int event_type,
+                            int status) {
     ALOGI("%s", __func__);
-    if (model_handle_str == NULL) {
-        ALOGI("%s Bad sound model handle.", __func__);
-        write_string(conn_socket, "Bad sound model handle.\n");
-        return;
-    }
-
-    ALOGI("Going to send trigger for model");
     struct recognition_context *model_context = fetch_model_with_handle(stdev, model_handle_str);
     if (model_context) {
-        if (model_context->recognition_callback == NULL) {
-            ALOGI("%s No matching callback for handle %d", __func__,
-                  model_context->model_handle);
-            return;
-        }
+        if (event_type == EVENT_RECOGNITION) {
+            if (model_context->recognition_callback == NULL) {
+                ALOGI("%s No matching callback", __func__);
+                return;
+            }
 
-        if (model_context->model_type == SOUND_MODEL_TYPE_KEYPHRASE) {
-            struct sound_trigger_phrase_recognition_event *event;
-            event = (struct sound_trigger_phrase_recognition_event *)
-                    sound_trigger_keyphrase_event_alloc(model_context->model_handle,
-                                                        model_context->config,
-                                                        recognition_status);
+            if (model_context->model_type == SOUND_MODEL_TYPE_KEYPHRASE) {
+                struct sound_trigger_phrase_recognition_event *event;
+                event = (struct sound_trigger_phrase_recognition_event *)
+                        sound_trigger_keyphrase_event_alloc(model_context->model_handle,
+                                                            model_context->config, status);
+                if (event) {
+                    model_context->recognition_callback(event, model_context->recognition_cookie);
+                    free(event);
+                }
+            } else if (model_context->model_type == SOUND_MODEL_TYPE_GENERIC) {
+                struct sound_trigger_generic_recognition_event *event;
+                event = (struct sound_trigger_generic_recognition_event *)
+                        sound_trigger_generic_event_alloc(model_context->model_handle,
+                                                          model_context->config, status);
+                if (event) {
+                    model_context->recognition_callback(event, model_context->recognition_cookie);
+                    free(event);
+                }
+            } else {
+                ALOGI("Unknown Sound Model Type, No Event to Send");
+            }
+        } else if (event_type == EVENT_SOUND_MODEL) {
+            char *data;
+            data = (char *)calloc(1, sizeof(struct sound_trigger_model_event));
+            if (!data) {
+                ALOGW("%s Could not allocate event", __func__);
+                return;
+            }
+
+            struct sound_trigger_model_event *event;
+            event = (struct sound_trigger_model_event *)data;
+            event->status = SOUND_MODEL_STATUS_UPDATED;
+            event->model = model_context->model_handle;
             if (event) {
-                model_context->recognition_callback(event, model_context->recognition_cookie);
+                model_context->model_callback(&event, model_context->model_cookie);
                 free(event);
             }
-        } else if (model_context->model_type == SOUND_MODEL_TYPE_GENERIC) {
-            struct sound_trigger_generic_recognition_event *event;
-            event = (struct sound_trigger_generic_recognition_event *)
-                    sound_trigger_generic_event_alloc(model_context->model_handle,
-                                                      model_context->config,
-                                                      recognition_status);
-            if (event) {
-                model_context->recognition_callback(event, model_context->recognition_cookie);
-                free(event);
-            }
-        } else {
-            ALOGI("Unknown Sound Model Type, No Event to Send");
         }
     } else {
         ALOGI("No model for this handle");
     }
 }
 
-static void send_recognition_event(int conn_socket, struct stub_sound_trigger_device* stdev,
-                                   int recognition_status) {
+static void send_event(int conn_socket, struct stub_sound_trigger_device* stdev, int event_type,
+                       int status) {
     char* model_uuid_str = strtok(NULL, " \r\n");
     sound_trigger_uuid_t model_uuid;
     if (str_to_uuid(model_uuid_str, &model_uuid)) {
         sound_model_handle_t* model_handle_str = get_model_handle_with_uuid(stdev, model_uuid);
-        send_recognition_event_with_handle(conn_socket, model_handle_str, stdev,
-                                           recognition_status);
-    }
-}
-
-static void send_model_event(sound_model_handle_t model_handle,
-            sound_model_callback_t model_callback, void *model_cookie) {
-
-    if (model_callback == NULL) {
-        ALOGI("%s No matching callback for handle %d", __func__, model_handle);
-        return;
-    }
-
-    char *data;
-    data = (char *)calloc(1, sizeof(struct sound_trigger_model_event));
-    if (!data) {
-        ALOGW("%s Could not allocate event %d", __func__, model_handle);
-        return;
-    }
-
-    struct sound_trigger_model_event *event;
-    event = (struct sound_trigger_model_event *)data;
-    event->status = SOUND_MODEL_STATUS_UPDATED;
-    event->model = model_handle;
-
-    if (event) {
-        model_callback(&event, model_cookie);
-        free(event);
+        if (model_handle_str == NULL) {
+            ALOGI("%s Bad sound model handle.", __func__);
+            write_string(conn_socket, "Bad sound model handle.\n");
+            return;
+        }
+        send_event_with_handle(model_handle_str, stdev, event_type, status);
+    } else {
+        ALOGI("%s Not a valid UUID", __func__);
+        write_string(conn_socket, "Not a valid UUID.\n");
     }
 }
 
@@ -510,28 +502,6 @@
     }
 }
 
-void process_send_model_event(int conn_socket, char* buffer,
-                              struct stub_sound_trigger_device* stdev) {
-    ALOGI("%s", __func__);
-    char* model_handle_str = strtok(NULL, " ");
-    if (model_handle_str == NULL) {
-        write_string(conn_socket, "Bad sound model id.\n");
-        return;
-    }
-
-    ALOGI("Going to model event for model index #%d", index );
-    struct recognition_context *model_context = fetch_model_with_handle(stdev, model_handle_str);
-    if (model_context) {
-
-        send_model_event(model_context->model_handle,
-                         model_context->model_callback,
-                         model_context->model_cookie);
-    } else {
-        ALOGI("Sound Model Does Not Exist with this handle");
-        write_string(conn_socket, "Sound Model Does Not Exist with this handle.\n");
-    }
-}
-
 // Gets the next word from buffer, replaces '\n' or ' ' with '\0'.
 char* get_command(char* buffer) {
     char* command = strtok(buffer, " ");
@@ -563,13 +533,13 @@
             } else if (strncmp(command, COMMAND_LS, 2) == 0) {
                 list_models(conn_socket, buffer, stdev);
             } else if (strcmp(command, COMMAND_RECOGNITION_TRIGGER) == 0) {
-                send_recognition_event(conn_socket, stdev, RECOGNITION_STATUS_SUCCESS);
+                send_event(conn_socket, stdev, EVENT_RECOGNITION, RECOGNITION_STATUS_SUCCESS);
             } else if (strcmp(command, COMMAND_RECOGNITION_ABORT) == 0) {
-                send_recognition_event(conn_socket, stdev, RECOGNITION_STATUS_ABORT);
+                send_event(conn_socket, stdev, EVENT_RECOGNITION, RECOGNITION_STATUS_ABORT);
             } else if (strcmp(command, COMMAND_RECOGNITION_FAILURE) == 0) {
-                send_recognition_event(conn_socket, stdev, RECOGNITION_STATUS_FAILURE);
+                send_event(conn_socket, stdev, EVENT_RECOGNITION, RECOGNITION_STATUS_FAILURE);
             } else if (strcmp(command, COMMAND_UPDATE) == 0) {
-                process_send_model_event(conn_socket, buffer, stdev);
+                send_event(conn_socket, stdev, EVENT_SOUND_MODEL, SOUND_MODEL_STATUS_UPDATED);
             } else if (strncmp(command, COMMAND_CLOSE, 5) == 0) {
                 ALOGI("Closing this connection.");
                 write_string(conn_socket, "Closing this connection.");
@@ -713,7 +683,6 @@
         pthread_mutex_unlock(&stdev->lock);
         return -ENOSYS;
     }
-
     if(previous_model_context) {
         previous_model_context->next = model_context->next;
     } else {
@@ -722,7 +691,6 @@
     free(model_context->config);
     free(model_context);
     pthread_mutex_unlock(&stdev->lock);
-
     return status;
 }
 
@@ -787,6 +755,27 @@
     return 0;
 }
 
+static int stdev_stop_all_recognitions(const struct sound_trigger_hw_device *dev) {
+    struct stub_sound_trigger_device *stdev = (struct stub_sound_trigger_device *)dev;
+    ALOGI("%s", __func__);
+    pthread_mutex_lock(&stdev->lock);
+
+    struct recognition_context *model_context = stdev->root_model_context;
+    while (model_context) {
+        free(model_context->config);
+        model_context->config = NULL;
+        model_context->recognition_callback = NULL;
+        model_context->recognition_cookie = NULL;
+        ALOGI("%s stopped handle %d", __func__, model_context->model_handle);
+
+        model_context = model_context->next;
+    }
+
+    pthread_mutex_unlock(&stdev->lock);
+
+    return 0;
+}
+
 __attribute__ ((visibility ("default")))
 int sound_trigger_open_for_streaming() {
     int ret = 0;
@@ -830,7 +819,7 @@
     stdev->root_model_context = NULL;
 
     stdev->device.common.tag = HARDWARE_DEVICE_TAG;
-    stdev->device.common.version = SOUND_TRIGGER_DEVICE_API_VERSION_1_0;
+    stdev->device.common.version = SOUND_TRIGGER_DEVICE_API_VERSION_1_1;
     stdev->device.common.module = (struct hw_module_t *) module;
     stdev->device.common.close = stdev_close;
     stdev->device.get_properties = stdev_get_properties;
@@ -838,6 +827,7 @@
     stdev->device.unload_sound_model = stdev_unload_sound_model;
     stdev->device.start_recognition = stdev_start_recognition;
     stdev->device.stop_recognition = stdev_stop_recognition;
+    stdev->device.stop_all_recognitions = stdev_stop_all_recognitions;
 
     pthread_mutex_init(&stdev->lock, (const pthread_mutexattr_t *) NULL);
 
diff --git a/modules/thermal/thermal.c b/modules/thermal/thermal.c
index c45d87a..6ba5845 100644
--- a/modules/thermal/thermal.c
+++ b/modules/thermal/thermal.c
@@ -72,6 +72,7 @@
                     .current_value = temp,
                     .throttling_threshold = UNKNOWN_TEMPERATURE,
                     .shutdown_threshold = UNKNOWN_TEMPERATURE,
+                    .vr_throttling_threshold = UNKNOWN_TEMPERATURE,
                 };
             }
             fclose(file);
diff --git a/modules/vehicle/vehicle.c b/modules/vehicle/vehicle.c
index d8aa2cb..a26f27c 100644
--- a/modules/vehicle/vehicle.c
+++ b/modules/vehicle/vehicle.c
@@ -526,6 +526,11 @@
     }
 }
 
+static int vdev_dump(struct vehicle_hw_device* device UNUSED, int fd UNUSED) {
+    //TODO
+    return 0;
+}
+
 /*
  * The open function is provided as an interface in harwdare.h which fills in
  * all the information about specific implementations and version specific
@@ -557,6 +562,7 @@
     vdev->vehicle_device.set = vdev_set;
     vdev->vehicle_device.subscribe = vdev_subscribe;
     vdev->vehicle_device.unsubscribe = vdev_unsubscribe;
+    vdev->vehicle_device.dump = vdev_dump;
 
     *device = (hw_device_t *) vdev;
     return 0;