dynamic_sensor: Add multi-HAL 2.1 sampling support. am: 43bc7bccdc
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/libhardware/+/15949542 Change-Id: I87a4243ba0c03062ebe311a4832edd2ef7b0ae69
This commit is contained in:
commit
157804a3f7
1 changed files with 24 additions and 10 deletions
|
@ -35,6 +35,21 @@ using ::android::hardware::Void;
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace SensorHalExt {
|
namespace SensorHalExt {
|
||||||
|
|
||||||
|
static Result ResultFromStatus(status_t err) {
|
||||||
|
switch (err) {
|
||||||
|
case ::android::OK:
|
||||||
|
return Result::OK;
|
||||||
|
case ::android::PERMISSION_DENIED:
|
||||||
|
return Result::PERMISSION_DENIED;
|
||||||
|
case ::android::NO_MEMORY:
|
||||||
|
return Result::NO_MEMORY;
|
||||||
|
case ::android::BAD_VALUE:
|
||||||
|
return Result::BAD_VALUE;
|
||||||
|
default:
|
||||||
|
return Result::INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DynamicSensorsSubHal::DynamicSensorsSubHal() {
|
DynamicSensorsSubHal::DynamicSensorsSubHal() {
|
||||||
// initialize dynamic sensor manager
|
// initialize dynamic sensor manager
|
||||||
mDynamicSensorManager.reset(
|
mDynamicSensorManager.reset(
|
||||||
|
@ -49,19 +64,18 @@ Return<Result> DynamicSensorsSubHal::setOperationMode(OperationMode mode) {
|
||||||
Result::OK : Result::BAD_VALUE);
|
Result::OK : Result::BAD_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<Result> DynamicSensorsSubHal::activate(int32_t sensor_handle __unused,
|
Return<Result> DynamicSensorsSubHal::activate(int32_t sensor_handle,
|
||||||
bool enabled __unused) {
|
bool enabled) {
|
||||||
ALOGE("DynamicSensorsSubHal::activate not supported.");
|
int rc = mDynamicSensorManager->activate(sensor_handle, enabled);
|
||||||
|
return ResultFromStatus(rc);
|
||||||
return Result::INVALID_OPERATION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<Result> DynamicSensorsSubHal::batch(
|
Return<Result> DynamicSensorsSubHal::batch(
|
||||||
int32_t sensor_handle __unused, int64_t sampling_period_ns __unused,
|
int32_t sensor_handle, int64_t sampling_period_ns,
|
||||||
int64_t max_report_latency_ns __unused) {
|
int64_t max_report_latency_ns) {
|
||||||
ALOGE("DynamicSensorsSubHal::batch not supported.");
|
int rc = mDynamicSensorManager->batch(sensor_handle, sampling_period_ns,
|
||||||
|
max_report_latency_ns);
|
||||||
return Result::INVALID_OPERATION;
|
return ResultFromStatus(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<Result> DynamicSensorsSubHal::flush(int32_t sensor_handle __unused) {
|
Return<Result> DynamicSensorsSubHal::flush(int32_t sensor_handle __unused) {
|
||||||
|
|
Loading…
Reference in a new issue