dynamic_sensor: Add sensor manager init to sub-HAL 2.1. am: 28b58c62b5
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/libhardware/+/15831086 Change-Id: If722b13e3608c77280b2406002eb35fa841930e6
This commit is contained in:
commit
e9155bf1ab
2 changed files with 50 additions and 1 deletions
|
@ -16,16 +16,30 @@
|
|||
|
||||
#include "DynamicSensorsSubHal.h"
|
||||
|
||||
#include <cutils/properties.h>
|
||||
#include <hardware/sensors-base.h>
|
||||
#include <log/log.h>
|
||||
|
||||
using ::android::hardware::sensors::V1_0::Result;
|
||||
using ::android::hardware::sensors::V2_1::SensorInfo;
|
||||
using ::android::hardware::sensors::V2_1::SensorType;
|
||||
template<class T> using Return = ::android::hardware::Return<T>;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
namespace android {
|
||||
namespace SensorHalExt {
|
||||
|
||||
DynamicSensorsSubHal::DynamicSensorsSubHal() {
|
||||
// initialize dynamic sensor manager
|
||||
int32_t base = property_get_int32("sensor.dynamic_sensor_hal.handle_base",
|
||||
kDynamicHandleBase);
|
||||
int32_t count = property_get_int32("sensor.dynamic_sensor_hal.handle_count",
|
||||
kMaxDynamicHandleCount);
|
||||
mDynamicSensorManager.reset(
|
||||
DynamicSensorManager::createInstance(base, count,
|
||||
nullptr /* callback */));
|
||||
}
|
||||
|
||||
// ISensors.
|
||||
Return<Result> DynamicSensorsSubHal::setOperationMode(OperationMode mode) {
|
||||
return (mode == static_cast<OperationMode>(SENSOR_HAL_NORMAL_MODE) ?
|
||||
|
@ -77,9 +91,32 @@ Return<void> DynamicSensorsSubHal::configDirectReport(
|
|||
}
|
||||
|
||||
Return<void> DynamicSensorsSubHal::getSensorsList_2_1(
|
||||
getSensorsList_2_1_cb callback __unused) {
|
||||
getSensorsList_2_1_cb callback) {
|
||||
const sensor_t& sensor_info = mDynamicSensorManager->getDynamicMetaSensor();
|
||||
std::vector<SensorInfo> sensors;
|
||||
|
||||
ALOGD("DynamicSensorsSubHal::getSensorsList_2_1 invoked.");
|
||||
|
||||
// get the dynamic sensor info
|
||||
sensors.resize(1);
|
||||
sensors[0].sensorHandle = sensor_info.handle;
|
||||
sensors[0].name = sensor_info.name;
|
||||
sensors[0].vendor = sensor_info.vendor;
|
||||
sensors[0].version = 1;
|
||||
sensors[0].type = static_cast<SensorType>(sensor_info.type);
|
||||
sensors[0].typeAsString = sensor_info.stringType;
|
||||
sensors[0].maxRange = sensor_info.maxRange;
|
||||
sensors[0].resolution = sensor_info.resolution;
|
||||
sensors[0].power = sensor_info.power;
|
||||
sensors[0].minDelay = sensor_info.minDelay;
|
||||
sensors[0].fifoReservedEventCount = sensor_info.fifoReservedEventCount;
|
||||
sensors[0].fifoMaxEventCount = sensor_info.fifoMaxEventCount;
|
||||
sensors[0].requiredPermission = sensor_info.requiredPermission;
|
||||
sensors[0].maxDelay = sensor_info.maxDelay;
|
||||
sensors[0].flags = sensor_info.flags;
|
||||
|
||||
callback(sensors);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef ANDROID_SENSORHAL_EXT_DYNAMIC_SENSORS_SUB_HAL_H
|
||||
#define ANDROID_SENSORHAL_EXT_DYNAMIC_SENSORS_SUB_HAL_H
|
||||
|
||||
#include "DynamicSensorManager.h"
|
||||
|
||||
#include <V2_1/SubHal.h>
|
||||
|
||||
namespace android {
|
||||
|
@ -37,6 +39,8 @@ class DynamicSensorsSubHal :
|
|||
using SharedMemInfo = ::android::hardware::sensors::V1_0::SharedMemInfo;
|
||||
|
||||
public:
|
||||
DynamicSensorsSubHal();
|
||||
|
||||
// ISensors.
|
||||
Return<Result> setOperationMode(OperationMode mode) override;
|
||||
Return<Result> activate(int32_t sensor_handle, bool enabled) override;
|
||||
|
@ -60,6 +64,14 @@ public:
|
|||
const std::string getName() override { return "Dynamic-SubHAL"; }
|
||||
Return<Result> initialize(
|
||||
const sp<IHalProxyCallback>& hal_proxy_callback) override;
|
||||
|
||||
private:
|
||||
static constexpr int32_t kDynamicHandleBase = 0;
|
||||
static constexpr int32_t kDynamicHandleEnd = 0x1000000;
|
||||
static constexpr int32_t kMaxDynamicHandleCount = kDynamicHandleEnd -
|
||||
kDynamicHandleBase;
|
||||
|
||||
std::unique_ptr<DynamicSensorManager> mDynamicSensorManager;
|
||||
};
|
||||
|
||||
} // namespace SensorHalExt
|
||||
|
|
Loading…
Reference in a new issue