libsensors: update flush() function for new Invensense hal

- Updated due to Motion Apps 5.1.6 Release Candidate 54 on sensors_mpl.cpp
- Avoid data abort on sensor init (on boot progress)

Change-Id: I0e00fbaff60d9605649fd80be192002554043b4d
diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp
index bd08a6f..72e549e 100644
--- a/libsensors/sensors.cpp
+++ b/libsensors/sensors.cpp
@@ -116,6 +116,7 @@
 
     // return true if the constructor is completed
     bool isValid() { return mInitialized; };
+    int flush(int handle);
 
 private:
     enum {
@@ -375,6 +376,13 @@
     if (index < 0) return index;
     return mSensor[index]->batch(handle, flags, period_ns, timeout);
 }
+
+int sensors_poll_context_t::flush(int handle)
+{
+    int index = handleToDriver(handle);
+    if (index < 0) return index;
+    return mSensor[index]->flush(handle);
+}
 /******************************************************************************/
 
 static int poll__close(struct hw_device_t *dev)
@@ -414,6 +422,13 @@
     sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
     return ctx->batch(handle, flags, period_ns, timeout);
 }
+
+static int poll__flush(struct sensors_poll_device_1 *dev,
+                      int handle)
+{
+    sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+    return ctx->flush(handle);
+}
 /******************************************************************************/
 
 /** Open a new instance of a sensor device using name */
@@ -440,6 +455,7 @@
 
     /* Batch processing */
     dev->device.batch           = poll__batch;
+    dev->device.flush           = poll__flush;
 
     *device = &dev->device.common;
     status = 0;