Merge "Add KM_TAG_ATTESTATION_CHALLENGE." into nyc-dev
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 29b695c..49cc0fe 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -431,6 +431,23 @@
      * Unit: the number of input audio frames
      */
     uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream);
+
+    /**
+     * Return a recent count of the number of audio frames received and
+     * the clock time associated with that frame count.
+     *
+     * frames is the total frame count received. This should be as early in
+     *     the capture pipeline as possible. In general,
+     *     frames should be non-negative and should not go "backwards".
+     *
+     * time is the clock MONOTONIC time when frames was measured. In general,
+     *     time should be a positive quantity and should not go "backwards".
+     *
+     * The status returned is 0 on success, -ENOSYS if the device is not
+     * ready/available, or -EINVAL if the arguments are null or otherwise invalid.
+     */
+    int (*get_capture_position)(const struct audio_stream_in *stream,
+                                int64_t *frames, int64_t *time);
 };
 typedef struct audio_stream_in audio_stream_in_t;
 
diff --git a/include/hardware/vehicle.h b/include/hardware/vehicle.h
index df4753a..71c57bc 100644
--- a/include/hardware/vehicle.h
+++ b/include/hardware/vehicle.h
@@ -372,7 +372,18 @@
  * @data_member outside_temperature
  * @unit VEHICLE_UNIT_TYPE_CELCIUS
  */
-#define VEHICLE_PROPERTY_ENV_OUTSIDE_TEMP                           (0x00000703)
+#define VEHICLE_PROPERTY_ENV_OUTSIDE_TEMPERATURE                   (0x00000703)
+
+
+/**
+ * Cabin temperature
+ * @value_type VEHICLE_VALUE_TYPE_FLOAT
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS
+ * @access VEHICLE_PROP_ACCESS_READ
+ * @data_member cabin_temperature
+ * @unit VEHICLE_UNIT_TYPE_CELCIUS
+ */
+#define VEHICLE_PROPERTY_ENV_CABIN_TEMPERATURE                  (0x00000704)
 
 
 /*
@@ -459,7 +470,13 @@
     VEHICLE_AUDIO_FOCUS_REQUEST_GAIN = 0x1,
     VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT = 0x2,
     VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_MAY_DUCK = 0x3,
-    VEHICLE_AUDIO_FOCUS_REQUEST_RELEASE = 0x4,
+    /**
+     * This is for the case where android side plays sound like UI feedback
+     * and car side does not need to duck existing playback as long as
+     * requested stream is available.
+     */
+    VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_NO_DUCK  = 0x4,
+    VEHICLE_AUDIO_FOCUS_REQUEST_RELEASE = 0x5,
 };
 
 enum vehicle_audio_focus_state {
@@ -712,6 +729,8 @@
     VEHICLE_AUDIO_CONTEXT_CD_ROM                         = 0x100,
     /** Aux audio input is played */
     VEHICLE_AUDIO_CONTEXT_AUX_AUDIO                      = 0x200,
+    /** system sound like UI feedback */
+    VEHICLE_AUDIO_CONTEXT_SYSTEM_SOUND                   = 0x400,
 };
 
 /**
@@ -887,6 +906,36 @@
     VEHICLE_AP_POWER_BOOTUP_REASON_TIMER         = 2,
 };
 
+
+/**
+ * Property to feed H/W input events to android
+ *
+ * int32_array[0] : action defined by vehicle_hw_key_input_action
+ * int32_array[1] : key code, should use standard android key code
+ * int32_array[2] : target display defined in vehicle_display. Events not tied
+ *                  to specific display should be sent to DISPLAY_MAIN.
+ * int32_array[3] : reserved for now. should be zero
+ * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4
+ * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE
+ * @access VEHICLE_PROP_ACCESS_READ
+ * @config_flags
+ * @data_member int32_array
+ */
+#define VEHICLE_PROPERTY_HW_KEY_INPUT                               (0x00000A10)
+
+enum vehicle_hw_key_input_action {
+    /** Key down */
+    VEHICLE_HW_KEY_INPUT_ACTION_DOWN = 0,
+    /** Key up */
+    VEHICLE_HW_KEY_INPUT_ACTION_UP = 1,
+};
+
+enum vehicle_display {
+    /** center console */
+    VEHICLE_DISPLAY_MAIN               = 0,
+    VEHICLE_DISPLAY_INSTRUMENT_CLUSTER = 1,
+};
+
 /**
  *  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].
@@ -1139,6 +1188,22 @@
     VEHICLE_WINDOW_ROW_3_RIGHT      = 0x2000,
 };
 
+enum vehicle_door {
+    VEHICLE_DOOR_ROW_1_LEFT    = 0x00000001,
+    VEHICLE_DOOR_ROW_1_RIGHT   = 0x00000004,
+    VEHICLE_DOOR_ROW_2_LEFT    = 0x00000010,
+    VEHICLE_DOOR_ROW_2_RIGHT   = 0x00000040,
+    VEHICLE_DOOR_ROW_3_LEFT    = 0x00000100,
+    VEHICLE_DOOR_ROW_3_RIGHT   = 0x00000400,
+    VEHICLE_DOOR_HOOD          = 0x10000000,
+    VEHICLE_DOOR_REAR          = 0x20000000,
+};
+
+enum vehicle_mirror {
+    VEHICLE_MIRROR_DRIVER_LEFT   = 0x00000001,
+    VEHICLE_MIRROR_DRIVER_RIGHT  = 0x00000002,
+    VEHICLE_MIRROR_DRIVER_CENTER = 0x00000004,
+};
 enum vehicle_turn_signal {
     VEHICLE_SIGNAL_NONE         = 0x00,
     VEHICLE_SIGNAL_RIGHT        = 0x01,
@@ -1457,6 +1522,8 @@
     vehicle_hvac_t hvac;
 
     float outside_temperature;
+    float cabin_temperature;
+
 } vehicle_value_t;
 
 /*
diff --git a/include/hardware/vehicle_rvc.h b/include/hardware/vehicle_rvc.h
new file mode 100644
index 0000000..05d57e4
--- /dev/null
+++ b/include/hardware/vehicle_rvc.h
@@ -0,0 +1,156 @@
+/*
+ * 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 ANDROID_VEHICLE_RVC_INTERFACE_H
+#define ANDROID_VEHICLE_RVC_INTERFACE_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <errno.h>
+
+#include <hardware/hardware.h>
+#include <cutils/native_handle.h>
+
+__BEGIN_DECLS
+
+/*****************************************************************************/
+
+#define VEHICLE_RVC_HEADER_VERSION          1
+#define VEHICLE_RVC_MODULE_API_VERSION_1_0  HARDWARE_MODULE_API_VERSION(1, 0)
+#define VEHICLE_RVC_DEVICE_API_VERSION_1_0  HARDWARE_DEVICE_API_VERSION_2(1, 0, VEHICLE_RVC_HEADER_VERSION)
+
+/**
+ * Vehicle Rearview Camera to provide interfaces for controlling
+ * the RVC.
+ */
+
+/**
+ * The id of this module
+ */
+#define VEHICLE_RVC_HARDWARE_MODULE_ID  "vehicle_rvc"
+
+/**
+ *  Name of the vehicle device to open
+ */
+#define VEHICLE_RVC_HARDWARE_DEVICE     "vehicle_rvc_hw_device"
+
+/**
+ * Describes the current state of RVC module
+ */
+typedef struct {
+    uint32_t overlay_on;
+    uint32_t rvc_on;
+} vehicle_rvc_state_t;
+
+/**
+ * Describes a rectangle for cropping and positioning objects
+ * uint32_t left    Position of left border of rectangle
+ * uint32_t top     Position of top border of rectangle
+ * uint32_t width   Width of rectangle
+ * uint32_t height  Height of rectangle
+ */
+typedef struct {
+    uint32_t left;
+    uint32_t top;
+    uint32_t width;
+    uint32_t height;
+} vehicle_rvc_rect_t;
+
+/**
+ * Bitmask of features supported by RVC module
+ */
+enum vehicle_rvc_config_flag {
+    ANDROID_OVERLAY_SUPPORT_FLAG        = 0x1,
+    CAMERA_CROP_SUPPORT_FLAG            = 0x2,
+    CAMERA_POSITIONING_SUPPORT_FLAG     = 0x4
+};
+
+typedef struct {
+    uint32_t capabilites_flags;
+    uint32_t camera_width;
+    uint32_t camera_height;
+    uint32_t display_width;
+    uint32_t display_height;
+} vehicle_rvc_cap_t;
+
+/************************************************************************************/
+
+/**
+ * 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 {
+    struct hw_module_t common;
+} vehicle_rvc_module_t;
+
+
+typedef struct vehicle_rvc_device_t {
+    struct hw_device_t common;
+
+    /**
+     * Returns the capabilities of this RVC.
+     * @param device
+     * @return
+     */
+    int (*get_capabilities)(struct vehicle_rvc_device_t *device, vehicle_rvc_cap_t *cap);
+    /**
+     * Gets the current RVC crop settings.
+     * @param device
+     * @return
+     */
+    int (*get_rvc_crop)(struct vehicle_rvc_device_t *device, vehicle_rvc_rect_t *rect);
+    /**
+     * Sets the RVC crop.
+     * @param device
+     * @param rect Area of RVC camera input to crop
+     * @return
+     */
+    int (*set_rvc_crop)(struct vehicle_rvc_device_t *device, const vehicle_rvc_rect_t *rect);
+    /**
+     * Gets position of the RVC on the dispaly.
+     * @param device
+     * @param rect Area of display the RVC will appear when on
+     * @return
+     */
+    int (*get_rvc_position)(struct vehicle_rvc_device_t *device, vehicle_rvc_rect_t *rect);
+    /**
+     * Sets position of the RVC on the display.
+     * @param device
+     * @param rect
+     * @return
+     */
+    int (*set_rvc_position)(struct vehicle_rvc_device_t *device, const vehicle_rvc_rect_t *rect);
+    /**
+     * Gets the current camera state.
+     * @param device
+     * @return
+     */
+    int (*get_camera_state)(struct vehicle_rvc_device_t *device, vehicle_rvc_state_t *state);
+    /**
+     * Sets the camera state.  Calling this function will generate a
+     * callback notifying the user that the camera state has
+     * changed.
+     * @param device
+     * @return
+     */
+    int (*set_camera_state)(struct vehicle_rvc_device_t *device, const vehicle_rvc_state_t *state);
+} vehicle_rvc_device_t;
+
+__END_DECLS
+
+#endif  // ANDROID_VEHICLE_RVC_INTERFACE_H