From cd4d9abdcc710462dfb8efa6ce3f5753f1fc7573 Mon Sep 17 00:00:00 2001 From: Anthony Stange Date: Thu, 9 Apr 2020 11:05:46 -0400 Subject: [PATCH] Don't modify -1 sensorHandle value A -1 sensorHandle value is used to denote all active sensors should be stopped for a given channel. Make sure the multi-HAL code doesn't modify handles of this value or it'll corrupt them before passing to the direct channel sub-HAL. Bug: 153413565 Test: atest VtsHalSensorsV2_0Target Change-Id: I3fe9cbf4661aa3db4ff534765d5112a193b7bf4a --- sensors/common/default/2.X/multihal/HalProxy.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sensors/common/default/2.X/multihal/HalProxy.cpp b/sensors/common/default/2.X/multihal/HalProxy.cpp index 518e138f6a..869c0330f4 100644 --- a/sensors/common/default/2.X/multihal/HalProxy.cpp +++ b/sensors/common/default/2.X/multihal/HalProxy.cpp @@ -260,9 +260,14 @@ Return HalProxy::configDirectReport(int32_t sensorHandle, int32_t channelH RateLevel rate, configDirectReport_cb _hidl_cb) { if (mDirectChannelSubHal == nullptr) { _hidl_cb(Result::INVALID_OPERATION, -1 /* reportToken */); + } else if (sensorHandle == -1 && rate != RateLevel::STOP) { + _hidl_cb(Result::BAD_VALUE, -1 /* reportToken */); } else { - mDirectChannelSubHal->configDirectReport(clearSubHalIndex(sensorHandle), channelHandle, - rate, _hidl_cb); + // -1 denotes all sensors should be disabled + if (sensorHandle != -1) { + sensorHandle = clearSubHalIndex(sensorHandle); + } + mDirectChannelSubHal->configDirectReport(sensorHandle, channelHandle, rate, _hidl_cb); } return Return(); }