Skip to content

Commit

Permalink
Add some missed APIs for sensor HAL
Browse files Browse the repository at this point in the history
Add following APIs for sensor HAL:
int32_t getHandle();
std::string getName();
std::string getStringType();
std::string getVendor();
int32_t getVersion();
float getResolution();
float getMaximumRange();
float getPower();
int32_t getType();
int32_t getMinDelay();
int32_t getMaxDelay();
uint32_t getFifoReservedEventCount();
uint32_t getFifoMaxEventCount();
std::string getRequiredPermission();
uint32_t getFlags();

Tracked-On: OAM-118727
Signed-off-by: Xu Bing <[email protected]>
  • Loading branch information
XuBing0 committed Jun 19, 2024
1 parent abbf86a commit f24c7fd
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
60 changes: 60 additions & 0 deletions sensors/aidl/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,66 @@ void Sensor::setAdditionalInfoFrames() {
mAdditionalInfoFrames.insert(mAdditionalInfoFrames.end(),{additionalInfoBegin,additionalInfoSensorPlacement,additionalInfoEnd});
}

int32_t Sensor::getHandle() {
return mSensorInfo.sensorHandle;
}

std::string Sensor::getName() {
return mSensorInfo.name;
}

std::string Sensor::getStringType() {
return mSensorInfo.typeAsString;
}

std::string Sensor::getVendor() {
return mSensorInfo.vendor;
}

int32_t Sensor::getVersion() {
return mSensorInfo.version;
}

float Sensor::getResolution() {
return mSensorInfo.resolution;
}

float Sensor::getMaximumRange() {
return mSensorInfo.maxRange;
}

float Sensor::getPower() {
return mSensorInfo.power;
}

int32_t Sensor::getType() {
return (int32_t)mSensorInfo.type;
}

int32_t Sensor::getMinDelay() {
return mSensorInfo.minDelayUs;
}

int32_t Sensor::getMaxDelay() {
return mSensorInfo.maxDelayUs;
}

uint32_t Sensor::getFifoReservedEventCount() {
return mSensorInfo.fifoReservedEventCount;
}

uint32_t Sensor::getFifoMaxEventCount() {
return mSensorInfo.fifoMaxEventCount;
}

std::string Sensor::getRequiredPermission() {
return mSensorInfo.requiredPermission;
}

uint32_t Sensor::getFlags() {
return mSensorInfo.flags;
}

AccelSensor::AccelSensor(int32_t sensorHandle, ISensorsEventCallback* callback) : Sensor(callback) {
mSensorInfo.sensorHandle = sensorHandle;
mSensorInfo.name = "Accel Sensor";
Expand Down
15 changes: 15 additions & 0 deletions sensors/aidl/include/sensors-impl/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ class Sensor {
ndk::ScopedAStatus injectEvent(const Event& event);
void setAdditionalInfoFrames();
std::vector<AdditionalInfo> mAdditionalInfoFrames;
int32_t getHandle();
std::string getName();
std::string getStringType();
std::string getVendor();
int32_t getVersion();
float getResolution();
float getMaximumRange();
float getPower();
int32_t getType();
int32_t getMinDelay();
int32_t getMaxDelay();
uint32_t getFifoReservedEventCount();
uint32_t getFifoMaxEventCount();
std::string getRequiredPermission();
uint32_t getFlags();

protected:
void run();
Expand Down

0 comments on commit f24c7fd

Please sign in to comment.