Refactor the native RuntimeSensor API.
Return a status from the virtual sensor callback indicating whether
the callback invocation was successful.
Bug: 266042170
Test: atest CtsSensorTestCases
Change-Id: I001019c1915dc33db26e84444314d162a801fb9a
diff --git a/services/sensorservice/SensorInterface.h b/services/sensorservice/SensorInterface.h
index 5ee5e12..c446d61 100644
--- a/services/sensorservice/SensorInterface.h
+++ b/services/sensorservice/SensorInterface.h
@@ -108,12 +108,12 @@
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,
- int64_t batchReportLatencyNs) = 0;
+ 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;
@@ -125,7 +125,7 @@
bool mEnabled = false;
int64_t mSamplingPeriodNs = 0;
int64_t mBatchReportLatencyNs = 0;
- sp<StateChangeCallback> mCallback;
+ sp<SensorCallback> mCallback;
};
// ---------------------------------------------------------------------------