Send wake event to ISensorHalWrapper fmq when switching to Hal Bypass Mode
When switching from NORMAL to HAL_BYPASS_REPLAY_DATA_INJECTION mode, the
ISensorHalWrapper::pollFmq() method continues to wait for sensor events.
Since the sensors are disabled when switching to Hal Bypass mode, the
polling thread may continue to wait on the fmq indefinitely.
Send an internal wake event to the fmq when switching to Hal Bypass
mode so that the thread drops out of pollFmq() and enters the branch for
accepting injected replay data.
Bug: 326433087
Test: manual
Change-Id: I984e55f64469cfac1c9156ea4660fc1dc4818695
diff --git a/services/sensorservice/AidlSensorHalWrapper.cpp b/services/sensorservice/AidlSensorHalWrapper.cpp
index e60db93..91c2d1f 100644
--- a/services/sensorservice/AidlSensorHalWrapper.cpp
+++ b/services/sensorservice/AidlSensorHalWrapper.cpp
@@ -178,6 +178,11 @@
if ((eventFlagState & asBaseType(INTERNAL_WAKE)) && mReconnecting) {
ALOGD("Event FMQ internal wake, returning from poll with no events");
return DEAD_OBJECT;
+ } else if ((eventFlagState & asBaseType(INTERNAL_WAKE)) && mInHalBypassMode &&
+ availableEvents == 0) {
+ ALOGD("Event FMQ internal wake due to HAL Bypass Mode, returning from poll with no "
+ "events");
+ return OK;
}
}
@@ -221,6 +226,17 @@
status_t AidlSensorHalWrapper::setOperationMode(SensorService::Mode mode) {
if (mSensors == nullptr) return NO_INIT;
+ if (mode == SensorService::Mode::HAL_BYPASS_REPLAY_DATA_INJECTION) {
+ if (!mInHalBypassMode) {
+ mInHalBypassMode = true;
+ mEventQueueFlag->wake(asBaseType(INTERNAL_WAKE));
+ }
+ return OK;
+ } else {
+ if (mInHalBypassMode) {
+ mInHalBypassMode = false;
+ }
+ }
return convertToStatus(mSensors->setOperationMode(static_cast<ISensors::OperationMode>(mode)));
}