Loading services/sensorservice/SensorInterface.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -87,14 +87,15 @@ VirtualSensor::VirtualSensor() : // --------------------------------------------------------------------------- RuntimeSensor::RuntimeSensor(const sensor_t& sensor, sp<StateChangeCallback> callback) RuntimeSensor::RuntimeSensor(const sensor_t& sensor, sp<SensorCallback> callback) : BaseSensor(sensor), mCallback(std::move(callback)) { } status_t RuntimeSensor::activate(void*, bool enabled) { if (enabled != mEnabled) { mEnabled = enabled; mCallback->onStateChanged(mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); return mCallback->onConfigurationChanged(mSensor.getHandle(), mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); } return OK; } Loading @@ -105,7 +106,8 @@ status_t RuntimeSensor::batch(void*, int, int, int64_t samplingPeriodNs, mSamplingPeriodNs = samplingPeriodNs; mBatchReportLatencyNs = maxBatchReportLatencyNs; if (mEnabled) { mCallback->onStateChanged(mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); return mCallback->onConfigurationChanged(mSensor.getHandle(), mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); } } return OK; Loading @@ -115,7 +117,8 @@ status_t RuntimeSensor::setDelay(void*, int, int64_t ns) { if (mSamplingPeriodNs != ns) { mSamplingPeriodNs = ns; if (mEnabled) { mCallback->onStateChanged(mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); return mCallback->onConfigurationChanged(mSensor.getHandle(), mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); } } return OK; Loading services/sensorservice/SensorInterface.h +5 −5 Original line number Diff line number Diff line Loading @@ -108,12 +108,12 @@ class RuntimeSensor : public BaseSensor { public: static constexpr int DEFAULT_DEVICE_ID = 0; class StateChangeCallback : public virtual RefBase { class SensorCallback : public virtual RefBase { public: virtual void onStateChanged(bool enabled, int64_t samplingPeriodNs, virtual status_t onConfigurationChanged(int handle, bool enabled, int64_t samplingPeriodNs, int64_t batchReportLatencyNs) = 0; }; RuntimeSensor(const sensor_t& sensor, sp<StateChangeCallback> callback); RuntimeSensor(const sensor_t& sensor, sp<SensorCallback> callback); virtual status_t activate(void* ident, bool enabled) override; virtual status_t batch(void* ident, int handle, int flags, int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) override; Loading @@ -125,7 +125,7 @@ private: bool mEnabled = false; int64_t mSamplingPeriodNs = 0; int64_t mBatchReportLatencyNs = 0; sp<StateChangeCallback> mCallback; sp<SensorCallback> mCallback; }; // --------------------------------------------------------------------------- Loading services/sensorservice/SensorService.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -116,16 +116,17 @@ int32_t nextRuntimeSensorHandle() { return nextHandle++; } class RuntimeSensorCallbackProxy : public RuntimeSensor::StateChangeCallback { class RuntimeSensorCallbackProxy : public RuntimeSensor::SensorCallback { public: RuntimeSensorCallbackProxy(sp<SensorService::RuntimeSensorStateChangeCallback> callback) RuntimeSensorCallbackProxy(sp<SensorService::RuntimeSensorCallback> callback) : mCallback(std::move(callback)) {} void onStateChanged(bool enabled, int64_t samplingPeriodNs, status_t onConfigurationChanged(int handle, bool enabled, int64_t samplingPeriodNs, int64_t batchReportLatencyNs) override { mCallback->onStateChanged(enabled, samplingPeriodNs, batchReportLatencyNs); return mCallback->onConfigurationChanged(handle, enabled, samplingPeriodNs, batchReportLatencyNs); } private: sp<SensorService::RuntimeSensorStateChangeCallback> mCallback; sp<SensorService::RuntimeSensorCallback> mCallback; }; } // namespace Loading Loading @@ -166,7 +167,7 @@ SensorService::SensorService() } int SensorService::registerRuntimeSensor( const sensor_t& sensor, int deviceId, sp<RuntimeSensorStateChangeCallback> callback) { const sensor_t& sensor, int deviceId, sp<RuntimeSensorCallback> callback) { int handle = 0; while (handle == 0 || !mSensors.isNewHandle(handle)) { handle = nextRuntimeSensorHandle(); Loading @@ -179,7 +180,7 @@ int SensorService::registerRuntimeSensor( ALOGI("Registering runtime sensor handle 0x%x, type %d, name %s", handle, sensor.type, sensor.name); sp<RuntimeSensor::StateChangeCallback> runtimeSensorCallback( sp<RuntimeSensor::SensorCallback> runtimeSensorCallback( new RuntimeSensorCallbackProxy(std::move(callback))); sensor_t runtimeSensor = sensor; // force the handle to be consistent Loading services/sensorservice/SensorService.h +5 −4 Original line number Diff line number Diff line Loading @@ -147,11 +147,12 @@ public: virtual void onProximityActive(bool isActive) = 0; }; class RuntimeSensorStateChangeCallback : public virtual RefBase { class RuntimeSensorCallback : public virtual RefBase { public: // Note that the callback is invoked from an async thread and can interact with the // SensorService directly. virtual void onStateChanged(bool enabled, int64_t samplingPeriodNanos, virtual status_t onConfigurationChanged(int handle, bool enabled, int64_t samplingPeriodNanos, int64_t batchReportLatencyNanos) = 0; }; Loading Loading @@ -182,7 +183,7 @@ public: status_t removeProximityActiveListener(const sp<ProximityActiveListener>& callback) ANDROID_API; int registerRuntimeSensor(const sensor_t& sensor, int deviceId, sp<RuntimeSensorStateChangeCallback> callback) ANDROID_API; sp<RuntimeSensorCallback> callback) ANDROID_API; status_t unregisterRuntimeSensor(int handle) ANDROID_API; status_t sendRuntimeSensorEvent(const sensors_event_t& event) ANDROID_API; Loading Loading
services/sensorservice/SensorInterface.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -87,14 +87,15 @@ VirtualSensor::VirtualSensor() : // --------------------------------------------------------------------------- RuntimeSensor::RuntimeSensor(const sensor_t& sensor, sp<StateChangeCallback> callback) RuntimeSensor::RuntimeSensor(const sensor_t& sensor, sp<SensorCallback> callback) : BaseSensor(sensor), mCallback(std::move(callback)) { } status_t RuntimeSensor::activate(void*, bool enabled) { if (enabled != mEnabled) { mEnabled = enabled; mCallback->onStateChanged(mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); return mCallback->onConfigurationChanged(mSensor.getHandle(), mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); } return OK; } Loading @@ -105,7 +106,8 @@ status_t RuntimeSensor::batch(void*, int, int, int64_t samplingPeriodNs, mSamplingPeriodNs = samplingPeriodNs; mBatchReportLatencyNs = maxBatchReportLatencyNs; if (mEnabled) { mCallback->onStateChanged(mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); return mCallback->onConfigurationChanged(mSensor.getHandle(), mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); } } return OK; Loading @@ -115,7 +117,8 @@ status_t RuntimeSensor::setDelay(void*, int, int64_t ns) { if (mSamplingPeriodNs != ns) { mSamplingPeriodNs = ns; if (mEnabled) { mCallback->onStateChanged(mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); return mCallback->onConfigurationChanged(mSensor.getHandle(), mEnabled, mSamplingPeriodNs, mBatchReportLatencyNs); } } return OK; Loading
services/sensorservice/SensorInterface.h +5 −5 Original line number Diff line number Diff line Loading @@ -108,12 +108,12 @@ class RuntimeSensor : public BaseSensor { public: static constexpr int DEFAULT_DEVICE_ID = 0; class StateChangeCallback : public virtual RefBase { class SensorCallback : public virtual RefBase { public: virtual void onStateChanged(bool enabled, int64_t samplingPeriodNs, virtual status_t onConfigurationChanged(int handle, bool enabled, int64_t samplingPeriodNs, int64_t batchReportLatencyNs) = 0; }; RuntimeSensor(const sensor_t& sensor, sp<StateChangeCallback> callback); RuntimeSensor(const sensor_t& sensor, sp<SensorCallback> callback); virtual status_t activate(void* ident, bool enabled) override; virtual status_t batch(void* ident, int handle, int flags, int64_t samplingPeriodNs, int64_t maxBatchReportLatencyNs) override; Loading @@ -125,7 +125,7 @@ private: bool mEnabled = false; int64_t mSamplingPeriodNs = 0; int64_t mBatchReportLatencyNs = 0; sp<StateChangeCallback> mCallback; sp<SensorCallback> mCallback; }; // --------------------------------------------------------------------------- Loading
services/sensorservice/SensorService.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -116,16 +116,17 @@ int32_t nextRuntimeSensorHandle() { return nextHandle++; } class RuntimeSensorCallbackProxy : public RuntimeSensor::StateChangeCallback { class RuntimeSensorCallbackProxy : public RuntimeSensor::SensorCallback { public: RuntimeSensorCallbackProxy(sp<SensorService::RuntimeSensorStateChangeCallback> callback) RuntimeSensorCallbackProxy(sp<SensorService::RuntimeSensorCallback> callback) : mCallback(std::move(callback)) {} void onStateChanged(bool enabled, int64_t samplingPeriodNs, status_t onConfigurationChanged(int handle, bool enabled, int64_t samplingPeriodNs, int64_t batchReportLatencyNs) override { mCallback->onStateChanged(enabled, samplingPeriodNs, batchReportLatencyNs); return mCallback->onConfigurationChanged(handle, enabled, samplingPeriodNs, batchReportLatencyNs); } private: sp<SensorService::RuntimeSensorStateChangeCallback> mCallback; sp<SensorService::RuntimeSensorCallback> mCallback; }; } // namespace Loading Loading @@ -166,7 +167,7 @@ SensorService::SensorService() } int SensorService::registerRuntimeSensor( const sensor_t& sensor, int deviceId, sp<RuntimeSensorStateChangeCallback> callback) { const sensor_t& sensor, int deviceId, sp<RuntimeSensorCallback> callback) { int handle = 0; while (handle == 0 || !mSensors.isNewHandle(handle)) { handle = nextRuntimeSensorHandle(); Loading @@ -179,7 +180,7 @@ int SensorService::registerRuntimeSensor( ALOGI("Registering runtime sensor handle 0x%x, type %d, name %s", handle, sensor.type, sensor.name); sp<RuntimeSensor::StateChangeCallback> runtimeSensorCallback( sp<RuntimeSensor::SensorCallback> runtimeSensorCallback( new RuntimeSensorCallbackProxy(std::move(callback))); sensor_t runtimeSensor = sensor; // force the handle to be consistent Loading
services/sensorservice/SensorService.h +5 −4 Original line number Diff line number Diff line Loading @@ -147,11 +147,12 @@ public: virtual void onProximityActive(bool isActive) = 0; }; class RuntimeSensorStateChangeCallback : public virtual RefBase { class RuntimeSensorCallback : public virtual RefBase { public: // Note that the callback is invoked from an async thread and can interact with the // SensorService directly. virtual void onStateChanged(bool enabled, int64_t samplingPeriodNanos, virtual status_t onConfigurationChanged(int handle, bool enabled, int64_t samplingPeriodNanos, int64_t batchReportLatencyNanos) = 0; }; Loading Loading @@ -182,7 +183,7 @@ public: status_t removeProximityActiveListener(const sp<ProximityActiveListener>& callback) ANDROID_API; int registerRuntimeSensor(const sensor_t& sensor, int deviceId, sp<RuntimeSensorStateChangeCallback> callback) ANDROID_API; sp<RuntimeSensorCallback> callback) ANDROID_API; status_t unregisterRuntimeSensor(int handle) ANDROID_API; status_t sendRuntimeSensorEvent(const sensors_event_t& event) ANDROID_API; Loading