dynamic_sensor: Add multi-HAL 2.1 flush support.
Bug: 201730055 Test: Verified that flush, batch, and activate sensor VTS tests pass. Change-Id: I6721d9f8976b3ef9f6af02b2320833025b479ee6
This commit is contained in:
@@ -42,6 +42,7 @@ void BaseSensorObject::getUuid(uint8_t* uuid) const {
|
|||||||
int BaseSensorObject::flush() {
|
int BaseSensorObject::flush() {
|
||||||
static const sensors_event_t event = {
|
static const sensors_event_t event = {
|
||||||
.type = SENSOR_TYPE_META_DATA,
|
.type = SENSOR_TYPE_META_DATA,
|
||||||
|
.meta_data.what = META_DATA_FLUSH_COMPLETE,
|
||||||
.timestamp = TIMESTAMP_AUTO_FILL // timestamp will be filled at dispatcher
|
.timestamp = TIMESTAMP_AUTO_FILL // timestamp will be filled at dispatcher
|
||||||
};
|
};
|
||||||
generateEvent(event);
|
generateEvent(event);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ bool DynamicSensorManager::owns(int handle) const {
|
|||||||
|
|
||||||
int DynamicSensorManager::activate(int handle, bool enable) {
|
int DynamicSensorManager::activate(int handle, bool enable) {
|
||||||
if (handle == mHandleRange.first) {
|
if (handle == mHandleRange.first) {
|
||||||
// ignored
|
mMetaSensorActive = enable;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,13 +109,17 @@ int DynamicSensorManager::setDelay(int handle, nsecs_t sample_period) {
|
|||||||
|
|
||||||
int DynamicSensorManager::flush(int handle) {
|
int DynamicSensorManager::flush(int handle) {
|
||||||
if (handle == mHandleRange.first) {
|
if (handle == mHandleRange.first) {
|
||||||
// submit a flush complete here
|
if (mMetaSensorActive) {
|
||||||
static const sensors_event_t event = {
|
static const sensors_event_t event = {
|
||||||
.sensor = mHandleRange.first,
|
.sensor = mHandleRange.first,
|
||||||
.type = SENSOR_TYPE_META_DATA,
|
.type = SENSOR_TYPE_META_DATA,
|
||||||
.timestamp = TIMESTAMP_AUTO_FILL, // timestamp will be filled at dispatcher
|
.meta_data.what = META_DATA_FLUSH_COMPLETE,
|
||||||
};
|
.timestamp = TIMESTAMP_AUTO_FILL, // timestamp will be filled at dispatcher
|
||||||
submitEvent(nullptr, event);
|
};
|
||||||
|
submitEvent(nullptr, event);
|
||||||
|
} else {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return operateSensor(handle, [] (sp<BaseSensorObject> s)->int {return s->flush();});
|
return operateSensor(handle, [] (sp<BaseSensorObject> s)->int {return s->flush();});
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ private:
|
|||||||
// available sensor handle space
|
// available sensor handle space
|
||||||
const std::pair<int, int> mHandleRange;
|
const std::pair<int, int> mHandleRange;
|
||||||
sensor_t mMetaSensor;
|
sensor_t mMetaSensor;
|
||||||
|
bool mMetaSensorActive = false;
|
||||||
|
|
||||||
// immutable pointer to event callback, used in extention mode.
|
// immutable pointer to event callback, used in extention mode.
|
||||||
SensorEventCallback * const mCallback;
|
SensorEventCallback * const mCallback;
|
||||||
|
|||||||
@@ -78,10 +78,9 @@ Return<Result> DynamicSensorsSubHal::batch(
|
|||||||
return ResultFromStatus(rc);
|
return ResultFromStatus(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<Result> DynamicSensorsSubHal::flush(int32_t sensor_handle __unused) {
|
Return<Result> DynamicSensorsSubHal::flush(int32_t sensor_handle) {
|
||||||
ALOGE("DynamicSensorsSubHal::flush not supported.");
|
int rc = mDynamicSensorManager->flush(sensor_handle);
|
||||||
|
return ResultFromStatus(rc);
|
||||||
return Result::INVALID_OPERATION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> DynamicSensorsSubHal::registerDirectChannel(
|
Return<void> DynamicSensorsSubHal::registerDirectChannel(
|
||||||
|
|||||||
Reference in New Issue
Block a user