Loading services/sensorservice/SensorDevice.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -491,6 +491,11 @@ void SensorDevice::notifyConnectionDestroyed(void* ident) { } int32_t SensorDevice::registerDirectChannel(const sensors_direct_mem_t* memory) { if (!isDirectReportSupported()) { return INVALID_OPERATION; } Mutex::Autolock _l(mLock); int32_t channelHandle = mSensorDevice->register_direct_channel( Loading @@ -506,6 +511,11 @@ void SensorDevice::unregisterDirectChannel(int32_t channelHandle) { int32_t SensorDevice::configureDirectChannel(int32_t sensorHandle, int32_t channelHandle, const struct sensors_direct_cfg_t *config) { if (!isDirectReportSupported()) { return INVALID_OPERATION; } Mutex::Autolock _l(mLock); int32_t ret = mSensorDevice->config_direct_report( Loading @@ -513,6 +523,12 @@ int32_t SensorDevice::configureDirectChannel(int32_t sensorHandle, int32_t chann ALOGE_IF(ret < 0, "SensorDevice::configureDirectChannel ret %d", ret); return ret; } bool SensorDevice::isDirectReportSupported() const { bool ret = mSensorDevice->register_direct_channel != nullptr && mSensorDevice->config_direct_report != nullptr; return ret; } // --------------------------------------------------------------------------- }; // namespace android services/sensorservice/SensorDevice.h +3 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ public: status_t flush(void* ident, int handle); status_t setMode(uint32_t mode); bool isDirectReportSupported() const; int32_t registerDirectChannel(const sensors_direct_mem_t *memory); void unregisterDirectChannel(int32_t channelHandle); int32_t configureDirectChannel(int32_t sensorHandle, Loading Loading @@ -147,6 +148,8 @@ private: const hardware::hidl_vec<Event> &src, const hardware::hidl_vec<SensorInfo> &dynamicSensorsAdded, sensors_event_t *dst); bool mIsDirectReportSupported; #endif // ENABLE_TREBLE }; Loading services/sensorservice/SensorDeviceTreble.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,9 @@ SensorDevice::SensorDevice() { mSensors->activate(list[i].sensorHandle, 0 /* enabled */); } }); mIsDirectReportSupported = (mSensors->unregisterDirectChannel(-1) != Result::INVALID_OPERATION); } void SensorDevice::handleDynamicSensorConnection(int handle, bool connected) { Loading Loading @@ -581,6 +584,10 @@ int32_t SensorDevice::configureDirectChannel(int32_t sensorHandle, return ret; } bool SensorDevice::isDirectReportSupported() const { return mIsDirectReportSupported; } void SensorDevice::convertToSensorEvent( const Event &src, sensors_event_t *dst) { ::android::hardware::sensors::V1_0::implementation::convertToSensorEvent( Loading Loading
services/sensorservice/SensorDevice.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -491,6 +491,11 @@ void SensorDevice::notifyConnectionDestroyed(void* ident) { } int32_t SensorDevice::registerDirectChannel(const sensors_direct_mem_t* memory) { if (!isDirectReportSupported()) { return INVALID_OPERATION; } Mutex::Autolock _l(mLock); int32_t channelHandle = mSensorDevice->register_direct_channel( Loading @@ -506,6 +511,11 @@ void SensorDevice::unregisterDirectChannel(int32_t channelHandle) { int32_t SensorDevice::configureDirectChannel(int32_t sensorHandle, int32_t channelHandle, const struct sensors_direct_cfg_t *config) { if (!isDirectReportSupported()) { return INVALID_OPERATION; } Mutex::Autolock _l(mLock); int32_t ret = mSensorDevice->config_direct_report( Loading @@ -513,6 +523,12 @@ int32_t SensorDevice::configureDirectChannel(int32_t sensorHandle, int32_t chann ALOGE_IF(ret < 0, "SensorDevice::configureDirectChannel ret %d", ret); return ret; } bool SensorDevice::isDirectReportSupported() const { bool ret = mSensorDevice->register_direct_channel != nullptr && mSensorDevice->config_direct_report != nullptr; return ret; } // --------------------------------------------------------------------------- }; // namespace android
services/sensorservice/SensorDevice.h +3 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ public: status_t flush(void* ident, int handle); status_t setMode(uint32_t mode); bool isDirectReportSupported() const; int32_t registerDirectChannel(const sensors_direct_mem_t *memory); void unregisterDirectChannel(int32_t channelHandle); int32_t configureDirectChannel(int32_t sensorHandle, Loading Loading @@ -147,6 +148,8 @@ private: const hardware::hidl_vec<Event> &src, const hardware::hidl_vec<SensorInfo> &dynamicSensorsAdded, sensors_event_t *dst); bool mIsDirectReportSupported; #endif // ENABLE_TREBLE }; Loading
services/sensorservice/SensorDeviceTreble.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,9 @@ SensorDevice::SensorDevice() { mSensors->activate(list[i].sensorHandle, 0 /* enabled */); } }); mIsDirectReportSupported = (mSensors->unregisterDirectChannel(-1) != Result::INVALID_OPERATION); } void SensorDevice::handleDynamicSensorConnection(int handle, bool connected) { Loading Loading @@ -581,6 +584,10 @@ int32_t SensorDevice::configureDirectChannel(int32_t sensorHandle, return ret; } bool SensorDevice::isDirectReportSupported() const { return mIsDirectReportSupported; } void SensorDevice::convertToSensorEvent( const Event &src, sensors_event_t *dst) { ::android::hardware::sensors::V1_0::implementation::convertToSensorEvent( Loading