Merge "Fingerprint: Add auth token to enroll"
diff --git a/include/hardware/gps.h b/include/hardware/gps.h
index e264cf5..937436b 100644
--- a/include/hardware/gps.h
+++ b/include/hardware/gps.h
@@ -293,6 +293,8 @@
 #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY         (1<<16)
 /** A valid 'used in fix' flag is stored in the data structure. */
 #define GPS_MEASUREMENT_HAS_USED_IN_FIX                       (1<<17)
+/** The value of 'pseudorange rate' is uncorrected. */
+#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE      (1<<18)
 
 /**
  * Enumeration of the available values for the GPS Measurement's loss of lock.
@@ -1353,6 +1355,9 @@
      *
      * The value contains the 'drift uncertainty' in it.
      * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT.
+     *
+     * If GpsMeasurement's 'flags' field contains GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE,
+     * it is encouraged that this field is also provided.
      */
     double drift_nsps;
 
@@ -1416,11 +1421,15 @@
      *
      * However, if there is any ambiguity in integer millisecond,
      * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field.
+     *
+     * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN.
      */
     int64_t received_gps_tow_ns;
 
     /**
      * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds.
+     *
+     * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN.
      */
     int64_t received_gps_tow_uncertainty_ns;
 
@@ -1434,11 +1443,23 @@
 
     /**
      * Pseudorange rate at the timestamp in m/s.
-     * The value also includes the effects of the receiver clock frequency and satellite clock
-     * frequency errors.
+     * The effects of the receiver clock frequency and satellite clock frequency errors, are known
+     * as the correction of a given Pseudorange rate value.
+     *
+     * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is set in 'flags' field, this field must
+     * be populated with the 'uncorrected' reading.
+     * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is not set in 'flags' field, this field
+     * must be populated with the 'corrected' reading. This is the default behavior.
+     *
+     * It is encouraged to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's
+     * 'drift' field as well.
      *
      * The value includes the 'pseudorange rate uncertainty' in it.
-     * A positive value indicates that the pseudorange is getting larger.
+     * A positive 'uncorrected' value indicates that the SV is moving away from the receiver.
+     *
+     * The sign of the 'uncorrected' 'pseudorange rate' and its correlation to the sign of 'doppler
+     * shift' is given by the equation:
+     *      pseudorange rate = -k * doppler shift
      *
      * This is a Mandatory value.
      */
@@ -1462,13 +1483,21 @@
 
     /**
      * Accumulated delta range since the last channel reset in meters.
-     * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
+     * A positive value indicates that the SV is moving away fro the receiver.
+     *
+     * The sign of the 'accumulated delta range' and its correlation to the sign of 'carrier phase'
+     * is given by the equation:
+     *          accumulated delta range = -k * carrier phase
+     *
+     * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
+     * However, it is expected that the data is only accurate when:
+     *      'accumulated delta range state' == GPS_ADR_STATE_VALID.
      */
     double accumulated_delta_range_m;
 
     /**
      * 1-Sigma uncertainty of the accumulated delta range in meters.
-     * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
+     * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN.
      */
     double accumulated_delta_range_uncertainty_m;
 
diff --git a/include/hardware/keymaster_defs.h b/include/hardware/keymaster_defs.h
index 81a62fe..2b43f2c 100644
--- a/include/hardware/keymaster_defs.h
+++ b/include/hardware/keymaster_defs.h
@@ -206,7 +206,11 @@
  */
 typedef enum {
     KM_ORIGIN_GENERATED = 0, /* Generated in keymaster */
-    KM_ORIGIN_IMPORTED = 2, /* Imported, origin unknown */
+    KM_ORIGIN_IMPORTED = 2,  /* Imported, origin unknown */
+    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
+                              * was generated inside or imported into keymaster. */
 } keymaster_key_origin_t;
 
 /**
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;