Surface reportingMode for Sensors.

Change-Id: Iac8dd3408c90eb7d285a2e8043131fab3a7e58fa
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 1bee04f..9d28792 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -223,14 +223,23 @@
                     s.getHandle(),
                     s.getRequiredPermission().string());
 
-            if (s.getMinDelay() > 0) {
-                result.appendFormat(
-                        "maxRate=%7.2fHz | ", 1e6f / s.getMinDelay());
+            const int reportingMode = s.getReportingMode();
+            if (reportingMode == AREPORTING_MODE_CONTINUOUS) {
+                result.append("continuous      |");
+            } else if (reportingMode == AREPORTING_MODE_ON_CHANGE) {
+                result.append("on-change       | ");
+            } else if (reportingMode == AREPORTING_MODE_ONE_SHOT) {
+                result.append("one-shot        | ");
             } else {
-                result.append(s.getMinDelay() == 0
-                        ? "on-demand         | "
-                        : "one-shot          | ");
+                result.append("special-trigger | ");
             }
+
+            if (s.getMinDelay() > 0) {
+                result.appendFormat("maxRate=%7.2fHz | ", 1e6f / s.getMinDelay());
+            } else {
+                result.appendFormat("minDelay=%5dus |", s.getMinDelay());
+            }
+
             if (s.getFifoMaxEventCount() > 0) {
                 result.appendFormat("FifoMax=%d events | ",
                         s.getFifoMaxEventCount());
@@ -301,17 +310,15 @@
 
 void SensorService::cleanupAutoDisabledSensorLocked(const sp<SensorEventConnection>& connection,
         sensors_event_t const* buffer, const int count) {
-    SensorInterface* sensor;
-    status_t err = NO_ERROR;
     for (int i=0 ; i<count ; i++) {
         int handle = buffer[i].sensor;
-        int type = buffer[i].type;
-        if (type == SENSOR_TYPE_SIGNIFICANT_MOTION) {
-            if (connection->hasSensor(handle)) {
-                sensor = mSensorMap.valueFor(handle);
-                if (sensor != NULL) {
-                    sensor->autoDisable(connection.get(), handle);
-                }
+        if (connection->hasSensor(handle)) {
+            SensorInterface* sensor = mSensorMap.valueFor(handle);
+            // If this buffer has an event from a one_shot sensor and this connection is registered
+            // for this particular one_shot sensor, try cleaning up the connection.
+            if (sensor != NULL &&
+                sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
+                sensor->autoDisable(connection.get(), handle);
                 cleanupWithoutDisableLocked(connection, handle);
             }
         }
@@ -588,7 +595,7 @@
             // this sensor is already activated, but we are adding a connection that uses it.
             // Immediately send down the last known value of the requested sensor if it's not a
             // "continuous" sensor.
-            if (sensor->getSensor().getMinDelay() == 0) {
+            if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) {
                 // NOTE: The wake_up flag of this event may get set to
                 // WAKE_UP_SENSOR_EVENT_NEEDS_ACK if this is a wake_up event.
                 sensors_event_t& event(mLastEventSeen.editValueFor(handle));
@@ -732,8 +739,8 @@
         return BAD_VALUE;
     }
 
-    if (sensor->getSensor().getType() == SENSOR_TYPE_SIGNIFICANT_MOTION) {
-        ALOGE("flush called on Significant Motion sensor");
+    if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
+        ALOGE("flush called on a one-shot sensor");
         return INVALID_OPERATION;
     }
     return sensor->flush(connection.get(), handle);