am ec9236ef: am ef2c616c: Merge "Update definition of the heart rate monitor to include confidence" into klp-modular-dev

* commit 'ec9236ef18e13b40a1b28aa05b4d5f483cc6ab74':
  Update definition of the heart rate monitor to include confidence
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index 9327c41..6a3bbae 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -416,10 +416,17 @@
  * trigger-mode: on-change
  * wake-up sensor: no
  *
- *  A sensor of this type returns the current heart rate if activated.
- *  The value is returned as a float which represents the heart rate in beats
- *  per minute (BPM).
- *  When the sensor cannot measure the heart rate, the returned value must be 0.
+ *  A sensor of this type returns the current heart rate.
+ *  The events contain the current heart rate in beats per minute (BPM) and the
+ *  status of the sensor during the measurement. See heart_rate_event_t for more
+ *  details.
+ *
+ *  Because this sensor is on-change, events must be generated when and only
+ *  when heart_rate.bpm or heart_rate.status have changed since the last
+ *  event. The event should be generated no faster than every period_ns passed
+ *  to setDelay() or to batch(). See the definition of the on-change trigger
+ *  mode for more information.
+ *
  *  sensor_t.requiredPermission must be set to SENSOR_PERMISSION_BODY_SENSORS.
  */
 #define SENSOR_TYPE_HEART_RATE                      (21)
@@ -567,17 +574,15 @@
 /** Minimum magnetic field on Earth's surface */
 #define MAGNETIC_FIELD_EARTH_MIN    (30.0f)
 
-
 /**
- * status of orientation sensor
+ * Possible values of the status field of sensor events.
  */
-
+#define SENSOR_STATUS_NO_CONTACT        -1
 #define SENSOR_STATUS_UNRELIABLE        0
 #define SENSOR_STATUS_ACCURACY_LOW      1
 #define SENSOR_STATUS_ACCURACY_MEDIUM   2
 #define SENSOR_STATUS_ACCURACY_HIGH     3
 
-
 /**
  * sensor event data
  */
@@ -627,6 +632,17 @@
 } meta_data_event_t;
 
 /**
+ * Heart rate event data
+ */
+typedef struct {
+  // Heart rate in beats per minute.
+  // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT
+  float bpm;
+  // Status of the sensor for this reading. Set to one SENSOR_STATUS_...
+  int8_t status;
+} heart_rate_event_t;
+
+/**
  * Union of the various types of sensor data
  * that can be returned.
  */
@@ -683,8 +699,8 @@
             /* uncalibrated magnetometer values are in micro-Teslas */
             uncalibrated_event_t uncalibrated_magnetic;
 
-            /* heart rate in bpm */
-            float           heart_rate;
+            /* heart rate data containing value in bpm and status */
+            heart_rate_event_t heart_rate;
 
             /* this is a special event. see SENSOR_TYPE_META_DATA above.
              * sensors_meta_data_event_t events are all reported with a type of