Loading sensors/2.0/multihal/HalProxy.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ Return<Result> HalProxy::setOperationMode(OperationMode mode) { Return<Result> HalProxy::activate(int32_t sensorHandle, bool enabled) { return getSubHalForSensorHandle(sensorHandle) ->activate(zeroOutFirstByte(sensorHandle), enabled); ->activate(clearSubHalIndex(sensorHandle), enabled); } Return<Result> HalProxy::initialize( Loading Loading @@ -154,11 +154,11 @@ Return<Result> HalProxy::initialize( Return<Result> HalProxy::batch(int32_t sensorHandle, int64_t samplingPeriodNs, int64_t maxReportLatencyNs) { return getSubHalForSensorHandle(sensorHandle) ->batch(zeroOutFirstByte(sensorHandle), samplingPeriodNs, maxReportLatencyNs); ->batch(clearSubHalIndex(sensorHandle), samplingPeriodNs, maxReportLatencyNs); } Return<Result> HalProxy::flush(int32_t sensorHandle) { return getSubHalForSensorHandle(sensorHandle)->flush(zeroOutFirstByte(sensorHandle)); return getSubHalForSensorHandle(sensorHandle)->flush(clearSubHalIndex(sensorHandle)); } Return<Result> HalProxy::injectSensorData(const Event& /* event */) { Loading Loading @@ -244,7 +244,7 @@ void HalProxy::initializeSensorList() { ISensorsSubHal* subHal = mSubHalList[subHalIndex]; auto result = subHal->getSensorsList([&](const auto& list) { for (SensorInfo sensor : list) { if ((sensor.sensorHandle & 0xFF000000) != 0) { if ((sensor.sensorHandle & kSensorHandleSubHalIndexMask) != 0) { ALOGE("SubHal sensorHandle's first byte was not 0"); } else { ALOGV("Loaded sensor: %s", sensor.name.c_str()); Loading Loading @@ -278,8 +278,8 @@ ISensorsSubHal* HalProxy::getSubHalForSensorHandle(uint32_t sensorHandle) { return mSubHalList[static_cast<size_t>(sensorHandle >> 24)]; } uint32_t HalProxy::zeroOutFirstByte(uint32_t num) { return num & 0x00FFFFFF; uint32_t HalProxy::clearSubHalIndex(uint32_t sensorHandle) { return sensorHandle & (~kSensorHandleSubHalIndexMask); } } // namespace implementation Loading sensors/2.0/multihal/include/HalProxy.h +7 −5 Original line number Diff line number Diff line Loading @@ -135,6 +135,9 @@ class HalProxy : public ISensors { //! The single subHal that supports directChannel reporting. ISensorsSubHal* mDirectChannelSubHal = nullptr; //! The bit mask used to get the subhal index from a sensor handle. static constexpr uint32_t kSensorHandleSubHalIndexMask = 0xFF000000; /** * Initialize the list of SubHal objects in mSubHalList by reading from dynamic libraries * listed in a config file. Loading Loading @@ -167,14 +170,13 @@ class HalProxy : public ISensors { 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. * Clear out the subhal index bytes from a sensorHandle. * * @param num The uint32_t number to work with. * @param sensorHandle The sensor handle to modify. * * @return The modified version of num param. * @return The modified version of the sensor handle. */ static uint32_t zeroOutFirstByte(uint32_t num); static uint32_t clearSubHalIndex(uint32_t sensorHandle); }; } // namespace implementation Loading Loading
sensors/2.0/multihal/HalProxy.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ Return<Result> HalProxy::setOperationMode(OperationMode mode) { Return<Result> HalProxy::activate(int32_t sensorHandle, bool enabled) { return getSubHalForSensorHandle(sensorHandle) ->activate(zeroOutFirstByte(sensorHandle), enabled); ->activate(clearSubHalIndex(sensorHandle), enabled); } Return<Result> HalProxy::initialize( Loading Loading @@ -154,11 +154,11 @@ Return<Result> HalProxy::initialize( Return<Result> HalProxy::batch(int32_t sensorHandle, int64_t samplingPeriodNs, int64_t maxReportLatencyNs) { return getSubHalForSensorHandle(sensorHandle) ->batch(zeroOutFirstByte(sensorHandle), samplingPeriodNs, maxReportLatencyNs); ->batch(clearSubHalIndex(sensorHandle), samplingPeriodNs, maxReportLatencyNs); } Return<Result> HalProxy::flush(int32_t sensorHandle) { return getSubHalForSensorHandle(sensorHandle)->flush(zeroOutFirstByte(sensorHandle)); return getSubHalForSensorHandle(sensorHandle)->flush(clearSubHalIndex(sensorHandle)); } Return<Result> HalProxy::injectSensorData(const Event& /* event */) { Loading Loading @@ -244,7 +244,7 @@ void HalProxy::initializeSensorList() { ISensorsSubHal* subHal = mSubHalList[subHalIndex]; auto result = subHal->getSensorsList([&](const auto& list) { for (SensorInfo sensor : list) { if ((sensor.sensorHandle & 0xFF000000) != 0) { if ((sensor.sensorHandle & kSensorHandleSubHalIndexMask) != 0) { ALOGE("SubHal sensorHandle's first byte was not 0"); } else { ALOGV("Loaded sensor: %s", sensor.name.c_str()); Loading Loading @@ -278,8 +278,8 @@ ISensorsSubHal* HalProxy::getSubHalForSensorHandle(uint32_t sensorHandle) { return mSubHalList[static_cast<size_t>(sensorHandle >> 24)]; } uint32_t HalProxy::zeroOutFirstByte(uint32_t num) { return num & 0x00FFFFFF; uint32_t HalProxy::clearSubHalIndex(uint32_t sensorHandle) { return sensorHandle & (~kSensorHandleSubHalIndexMask); } } // namespace implementation Loading
sensors/2.0/multihal/include/HalProxy.h +7 −5 Original line number Diff line number Diff line Loading @@ -135,6 +135,9 @@ class HalProxy : public ISensors { //! The single subHal that supports directChannel reporting. ISensorsSubHal* mDirectChannelSubHal = nullptr; //! The bit mask used to get the subhal index from a sensor handle. static constexpr uint32_t kSensorHandleSubHalIndexMask = 0xFF000000; /** * Initialize the list of SubHal objects in mSubHalList by reading from dynamic libraries * listed in a config file. Loading Loading @@ -167,14 +170,13 @@ class HalProxy : public ISensors { 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. * Clear out the subhal index bytes from a sensorHandle. * * @param num The uint32_t number to work with. * @param sensorHandle The sensor handle to modify. * * @return The modified version of num param. * @return The modified version of the sensor handle. */ static uint32_t zeroOutFirstByte(uint32_t num); static uint32_t clearSubHalIndex(uint32_t sensorHandle); }; } // namespace implementation Loading