summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Fennema <fennema@google.com>2019-01-08 17:02:25 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-01-08 17:02:25 -0800
commit77a53f250e2b23f3e7ccbe987736fcefa264e40f (patch)
treea458d380997fd6e5c006de193cc4066a0836e351
parent6cac791c88c222c13b8586f64ccf1ce165c3a754 (diff)
parent52bd2fa354a2edba9b7c1e93b66b426d0e5c8b91 (diff)
downloaddevice_google_contexthub-77a53f250e2b23f3e7ccbe987736fcefa264e40f.tar.gz
device_google_contexthub-77a53f250e2b23f3e7ccbe987736fcefa264e40f.tar.bz2
device_google_contexthub-77a53f250e2b23f3e7ccbe987736fcefa264e40f.zip
sensorhal: fix incorrect rate/latency retention for alt sensors
am: 52bd2fa354 Change-Id: Ie85b23403fd2fa83fdcc483b59840e0d54dd520d
-rw-r--r--sensorhal/hubconnection.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/sensorhal/hubconnection.cpp b/sensorhal/hubconnection.cpp
index 83392f21..01a5d2dd 100644
--- a/sensorhal/hubconnection.cpp
+++ b/sensorhal/hubconnection.cpp
@@ -1668,9 +1668,18 @@ void HubConnection::initConfigCmd(struct ConfigCmd *cmd, int handle)
cmd->evtType = EVT_NO_SENSOR_CONFIG_EVENT;
cmd->sensorType = mSensorState[handle].sensorType;
- cmd->cmd = mSensorState[handle].enable ? CONFIG_CMD_ENABLE : CONFIG_CMD_DISABLE;
- cmd->rate = mSensorState[handle].rate;
- cmd->latency = mSensorState[handle].latency;
+
+ if (mSensorState[handle].enable) {
+ cmd->cmd = CONFIG_CMD_ENABLE;
+ cmd->rate = mSensorState[handle].rate;
+ cmd->latency = mSensorState[handle].latency;
+ } else {
+ cmd->cmd = CONFIG_CMD_DISABLE;
+ // set rate and latency to values that will always be overwritten by the
+ // first enabled alt sensor
+ cmd->rate = UINT32_C(0);
+ cmd->latency = UINT64_MAX;
+ }
for (int i=0; i<MAX_ALTERNATES; ++i) {
uint8_t alt = mSensorState[handle].alt[i];