diff options
author | Ben Fennema <fennema@google.com> | 2019-01-02 13:57:19 -0800 |
---|---|---|
committer | Ben Fennema <fennema@google.com> | 2019-01-02 14:06:22 -0800 |
commit | 52bd2fa354a2edba9b7c1e93b66b426d0e5c8b91 (patch) | |
tree | a458d380997fd6e5c006de193cc4066a0836e351 | |
parent | 8880b727517b86b5472684d1330dc1c01449ce69 (diff) | |
download | device_google_contexthub-52bd2fa354a2edba9b7c1e93b66b426d0e5c8b91.tar.gz device_google_contexthub-52bd2fa354a2edba9b7c1e93b66b426d0e5c8b91.tar.bz2 device_google_contexthub-52bd2fa354a2edba9b7c1e93b66b426d0e5c8b91.zip |
sensorhal: fix incorrect rate/latency retention for alt sensors
When disabling a sensor with alt versions enabled the rate and latency
from the disabled sensor would be used if it was higher (rate) or lower
(latency) than any of the enabled alt versions.
Initialize rate and latency to values such that they will always be
set by the first enabled alt sensor. (0 for rate and max value for
latency)
Test: enable accel at 50Hz; enable uncal accel at 200Hz; disable uncal
accel; verify accel is running at 50Hz, not 200Hz
Bug: 122115010
Change-Id: Iac172495235360fbd15bd76abf9b7fdef4d1f6f5
Signed-off-by: Ben Fennema <fennema@google.com>
-rw-r--r-- | sensorhal/hubconnection.cpp | 15 |
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]; |