diff options
-rw-r--r-- | sensors/2.0/multihal/HalProxy.cpp | 8 | ||||
-rw-r--r-- | sensors/2.0/multihal/include/HalProxy.h | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/sensors/2.0/multihal/HalProxy.cpp b/sensors/2.0/multihal/HalProxy.cpp index 80d7296793..964f5893aa 100644 --- a/sensors/2.0/multihal/HalProxy.cpp +++ b/sensors/2.0/multihal/HalProxy.cpp @@ -218,6 +218,14 @@ Return<void> HalProxy::onDynamicSensorsDisconnected( return Return<void>(); } +ISensorsSubHal* HalProxy::getSubHalForSensorHandle(uint32_t sensorHandle) { + return mSubHalList[static_cast<size_t>(sensorHandle >> 24)]; +} + +uint32_t HalProxy::zeroOutFirstByte(uint32_t num) { + return num & 0x00FFFFFF; +} + } // namespace implementation } // namespace V2_0 } // namespace sensors diff --git a/sensors/2.0/multihal/include/HalProxy.h b/sensors/2.0/multihal/include/HalProxy.h index 9d5787c655..809d07e98b 100644 --- a/sensors/2.0/multihal/include/HalProxy.h +++ b/sensors/2.0/multihal/include/HalProxy.h @@ -118,6 +118,24 @@ struct HalProxy : public ISensors { * SubHal object pointers that have been saved from vendor dynamic libraries. */ std::vector<ISensorsSubHal*> mSubHalList; + + /* + * Get the subhal pointer which can be found by indexing into the mSubHalList vector + * using the index from the first byte of sensorHandle. + * + * @param sensorHandle The handle used to identify a sensor in one of the subhals. + */ + ISensorsSubHal* getSubHalForSensorHandle(uint32_t sensorHandle); + + /* + * Zero out the first (most significant) byte in a number. Used in modifying the sensor handles + * before passing them to subhals. + * + * @param num The uint32_t number to work with. + * + * @return The modified version of num param. + */ + static uint32_t zeroOutFirstByte(uint32_t num); }; } // namespace implementation |