Merge "Complete updates to gps.h to enhance the definition of GPS Measurements interface. b/19938206"
diff --git a/include/hardware/fingerprint.h b/include/hardware/fingerprint.h
index 1d190a6..68687b2 100644
--- a/include/hardware/fingerprint.h
+++ b/include/hardware/fingerprint.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
 #define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
 
+#include <hardware/hw_auth_token.h>
+
 #define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
 #define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
 #define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint"
@@ -24,7 +26,6 @@
 typedef enum fingerprint_msg_type {
     FINGERPRINT_ERROR = -1,
     FINGERPRINT_ACQUIRED = 1,
-    FINGERPRINT_PROCESSED = 2,
     FINGERPRINT_TEMPLATE_ENROLLING = 3,
     FINGERPRINT_TEMPLATE_REMOVED = 4,
     FINGERPRINT_AUTHENTICATED = 5
@@ -97,19 +98,9 @@
     fingerprint_acquired_info_t acquired_info; /* information about the image */
 } fingerprint_acquired_t;
 
-typedef struct fingerprint_processed {
-    fingerprint_finger_id_t finger; /* all 0s is a special case and means no match */
-} fingerprint_processed_t;
-
 typedef struct fingerprint_authenticated {
-    uint32_t user_id;
-    uint32_t auth_id;
-    uint32_t timestamp;
-    uint32_t app_id;
-    uint64_t crypto_op_id;
-    uint8_t hmac[16];  /* 128-bit */
-    uint32_t auth_token_size;
-    uint8_t *auth_token;
+    fingerprint_finger_id_t finger;
+    hw_auth_token_t hat;
 } fingerprint_authenticated_t;
 
 typedef struct fingerprint_msg {
@@ -119,7 +110,6 @@
         fingerprint_enroll_t enroll;
         fingerprint_removed_t removed;
         fingerprint_acquired_t acquired;
-        fingerprint_processed_t processed;
         fingerprint_authenticated_t authenticated;
     } data;
 } fingerprint_msg_t;
@@ -151,7 +141,8 @@
      *                 -1 otherwise. A notify() function may be called
      *                    indicating the error condition.
      */
-    int (*enroll)(struct fingerprint_device *dev, uint32_t gid, uint32_t timeout_sec);
+    int (*enroll)(struct fingerprint_device *dev, const hw_auth_token_t *hat,
+                    uint32_t gid, uint32_t timeout_sec);
 
     /*
      * Fingerprint pre-enroll enroll request:
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index e917c0a..90036b6 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -35,6 +35,7 @@
 #define SENSORS_DEVICE_API_VERSION_1_1  HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION)
 #define SENSORS_DEVICE_API_VERSION_1_2  HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION)
 #define SENSORS_DEVICE_API_VERSION_1_3  HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION)
+#define SENSORS_DEVICE_API_VERSION_1_4  HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION)
 
 /**
  * Please see the Sensors section of source.android.com for an
@@ -93,6 +94,28 @@
 #define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS"
 
 /*
+ * Availability: SENSORS_DEVICE_API_VERSION_1_4
+ * Sensor HAL modes uses in set_operation_mode method
+ */
+enum {
+    /*
+     * Operating modes for the HAL.
+     */
+
+    /*
+     * Normal mode operation. This is the default state of operation.
+     * The HAL shall initialize into this mode on device startup.
+     */
+    SENSOR_HAL_NORMAL_MODE        = 0,
+
+    /* Loopback mode. In this mode, the device shall not source data from the
+     * physical sensors as it would in normal mode. Instead sensor data is
+     * injected by the sensor service.
+     */
+    SENSOR_HAL_LOOPBACK_MODE      = 0x1
+};
+
+/*
  * Availability: SENSORS_DEVICE_API_VERSION_1_3
  * Sensor flags used in sensor_t.flags.
  */
@@ -619,6 +642,36 @@
 #define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE                  "android.sensor.wrist_tilt_gesture"
 
 /**
+ * SENSOR_TYPE_TIME_SYNC
+ * reporting-mode: continuous
+ *
+ *  A time synchronization mechanism sensor to synchronize timing between
+ *  differnt parts of the device.
+ *  This sensor returns the following values in the sensor_event
+ *      Time_stamp of the event
+ *        u64.data[0] -> Type of event latched
+ *        u64.data[1] -> count
+ *
+ *  Implement only the wake-up version of this sensor.
+ */
+#define SENSOR_TYPE_TIME_SYNC                        (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0x10)
+#define SENSOR_STRING_TYPE_TIME_SYNC                 "android.sensor.time_sync"
+
+/**
+ * SENSOR_TYPE_NUDGE_GESTURE
+ * reporting-mode: one-shot
+ *
+ * A sensor of this type triggers when the device is nudged.
+ *
+ * The only allowed return value is 1.0. This sensor
+ * de-activates itself immediately after it triggers.
+ *
+ * Implement only the wake-up version of this sensor.
+ */
+#define SENSOR_TYPE_NUDGE_GESTURE                   (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0x11)
+#define SENSOR_STRING_NUDGE_UP_GESTURE              "android.sensor.nudge_gesture"
+
+/**
  * Values returned by the accelerometer in various locations in the universe.
  * all values are in SI units (m/s^2)
  */
@@ -807,6 +860,15 @@
      */
     int (*get_sensors_list)(struct sensors_module_t* module,
             struct sensor_t const** list);
+
+    /**
+     *  Place the module in a specific mode. The following modes are defined
+     *
+     *  0  - Normal operation. Default state of the module.
+     *  1 - Loopback mode. Data is injected for the the supported sensors by
+     *      the sensor service in this mode.
+     */
+    int (*set_operation_mode)(unsigned int mode);
 };
 
 struct sensor_t {
@@ -1004,7 +1066,12 @@
      */
     int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle);
 
-    void (*reserved_procs[8])(void);
+    /*
+     * Inject a sensor samples to be to this device.
+     */
+    int (*inject_sensor_data)(struct sensors_poll_device_1 *dev, const sensors_event_t *data);
+
+    void (*reserved_procs[7])(void);
 
 } sensors_poll_device_1_t;
 
diff --git a/modules/fingerprint/fingerprint.c b/modules/fingerprint/fingerprint.c
index f9fd44b..ac7e35b 100644
--- a/modules/fingerprint/fingerprint.c
+++ b/modules/fingerprint/fingerprint.c
@@ -33,6 +33,7 @@
 }
 
 static int fingerprint_enroll(struct fingerprint_device __unused *dev,
+                                const hw_auth_token_t __unused *hat,
                                 uint32_t __unused gid,
                                 uint32_t __unused timeout_sec) {
     return FINGERPRINT_ERROR;
diff --git a/tests/hardware/struct-offset.cpp b/tests/hardware/struct-offset.cpp
index 0f4ef41..d6ea073 100644
--- a/tests/hardware/struct-offset.cpp
+++ b/tests/hardware/struct-offset.cpp
@@ -115,7 +115,8 @@
     CHECK_MEMBER_AT(sensors_poll_device_1_t, poll, 72, 136);
     CHECK_MEMBER_AT(sensors_poll_device_1_t, batch, 76, 144);
     CHECK_MEMBER_AT(sensors_poll_device_1_t, flush, 80, 152);
-    CHECK_MEMBER_AT(sensors_poll_device_1_t, reserved_procs, 84, 160);
+    CHECK_MEMBER_AT(sensors_poll_device_1_t, inject_sensor_data, 84, 160);
+    CHECK_MEMBER_AT(sensors_poll_device_1_t, reserved_procs, 88, 168);
 
     //Types defined in fb.h
     CHECK_MEMBER_AT(framebuffer_device_t, common, 0, 0);