From db23aa825bad61eee3d53f261feb44151b70e84b Mon Sep 17 00:00:00 2001 From: Stan Rokita Date: Tue, 24 Sep 2019 11:08:27 -0700 Subject: [PATCH] MH2 | Implement direct channel and direct report methods Implement registerDirectChannel, unregisterDirectChannel, and configDirectReport methods of HalProxy. Bug: 136511617 Test: Compiles successfully. Simple enough change to ignore unit tests for now. Change-Id: I7e1e6a4da6ba2fc070836084210c83bd9b53aabe --- sensors/2.0/multihal/HalProxy.cpp | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/sensors/2.0/multihal/HalProxy.cpp b/sensors/2.0/multihal/HalProxy.cpp index f051a11a2c..7264e15c9f 100644 --- a/sensors/2.0/multihal/HalProxy.cpp +++ b/sensors/2.0/multihal/HalProxy.cpp @@ -162,25 +162,34 @@ Return HalProxy::injectSensorData(const Event& event) { return result; } -Return HalProxy::registerDirectChannel(const SharedMemInfo& /* mem */, +Return HalProxy::registerDirectChannel(const SharedMemInfo& mem, registerDirectChannel_cb _hidl_cb) { - // TODO: During init, discover the first sub-HAL in the config that has sensors with direct - // channel support, if any, and proxy the API call there. - _hidl_cb(Result::INVALID_OPERATION, -1 /* channelHandle */); + if (mDirectChannelSubHal == nullptr) { + _hidl_cb(Result::INVALID_OPERATION, -1 /* channelHandle */); + } else { + mDirectChannelSubHal->registerDirectChannel(mem, _hidl_cb); + } return Return(); } -Return HalProxy::unregisterDirectChannel(int32_t /* channelHandle */) { - // TODO: During init, discover the first sub-HAL in the config that has sensors with direct - // channel support, if any, and proxy the API call there. - return Result::INVALID_OPERATION; +Return HalProxy::unregisterDirectChannel(int32_t channelHandle) { + Result result; + if (mDirectChannelSubHal == nullptr) { + result = Result::INVALID_OPERATION; + } else { + result = mDirectChannelSubHal->unregisterDirectChannel(channelHandle); + } + return result; } -Return HalProxy::configDirectReport(int32_t /* sensorHandle */, int32_t /* channelHandle */, - RateLevel /* rate */, configDirectReport_cb _hidl_cb) { - // TODO: During init, discover the first sub-HAL in the config that has sensors with direct - // channel support, if any, and proxy the API call there. - _hidl_cb(Result::INVALID_OPERATION, 0 /* reportToken */); +Return HalProxy::configDirectReport(int32_t sensorHandle, int32_t channelHandle, + RateLevel rate, configDirectReport_cb _hidl_cb) { + if (mDirectChannelSubHal == nullptr) { + _hidl_cb(Result::INVALID_OPERATION, -1 /* reportToken */); + } else { + mDirectChannelSubHal->configDirectReport(clearSubHalIndex(sensorHandle), channelHandle, + rate, _hidl_cb); + } return Return(); }