diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-04-02 21:23:45 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-04-02 21:23:45 +0000 |
commit | cc1c580b68ef5c4df4a92d815d0139bdc97e1d07 (patch) | |
tree | 378dd81ba0e9764626967fcfcd70d9e7df0e0ff0 | |
parent | 41722d9266117c2793b94a7c2928b2b019056336 (diff) | |
parent | d1227d2dc81e468da62c9a4e9ead33ae0da81fa1 (diff) | |
download | chre-cc1c580b68ef5c4df4a92d815d0139bdc97e1d07.tar.gz |
Merge "Implements flushAsync for SMGR"
-rw-r--r-- | platform/slpi/smgr/platform_sensor.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/platform/slpi/smgr/platform_sensor.cc b/platform/slpi/smgr/platform_sensor.cc index fc47a9c4..216cbbb7 100644 --- a/platform/slpi/smgr/platform_sensor.cc +++ b/platform/slpi/smgr/platform_sensor.cc @@ -1544,8 +1544,24 @@ bool PlatformSensor::applyRequest(const SensorRequest& request) { } bool PlatformSensor::flushAsync() { - // TODO: Implement this - return false; + // NOTE: SMGR framework flushes all pending data when a new request comes in + // (ref sns_rh_sol_schedule_existing_report() in sns_rh_sol.c). + // In this implementation of flushAsync, we make a request identical to + // the existing sensor request, blocking on an asynchronous response, + // and assume that the flush request has completed when this identical + // sensor request is successfully handled and executed. This + // implementation mirrors the sensors HAL implementation of flush. + bool success = false; + Sensor *sensor = EventLoopManagerSingleton::get()->getSensorRequestManager() + .getSensor(getSensorType()); + if (sensor != nullptr) { + success = applyRequest(sensor->getRequest()); + if (success) { + EventLoopManagerSingleton::get()->getSensorRequestManager() + .handleFlushCompleteEvent(CHRE_ERROR_NONE, getSensorType()); + } + } + return success; } SensorType PlatformSensor::getSensorType() const { |