sm8450-common: Add hals.conf to load sensors.xiaomi to odm and move notifier to subdir
Change-Id: I9e16531e60fa6a0122330ee352cddd0840feb39c
This commit is contained in:
57
sensors/sensor-notifier/utils/SensorNotifierUtils.cpp
Normal file
57
sensors/sensor-notifier/utils/SensorNotifierUtils.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "SensorNotifierUtils"
|
||||
|
||||
#include "SensorNotifierUtils.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
bool readBool(int fd) {
|
||||
char c;
|
||||
int rc;
|
||||
|
||||
rc = lseek(fd, 0, SEEK_SET);
|
||||
if (rc) {
|
||||
LOG(ERROR) << "failed to seek fd, err: " << rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = read(fd, &c, sizeof(char));
|
||||
if (rc != 1) {
|
||||
LOG(ERROR) << "failed to read bool from fd, err: " << rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
return c != '0';
|
||||
}
|
||||
|
||||
disp_event_resp* parseDispEvent(int fd) {
|
||||
disp_event header;
|
||||
ssize_t headerSize = read(fd, &header, sizeof(header));
|
||||
if (headerSize < sizeof(header)) {
|
||||
LOG(ERROR) << "unexpected display event header size: " << headerSize;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct disp_event_resp* response =
|
||||
reinterpret_cast<struct disp_event_resp*>(malloc(header.length));
|
||||
response->base = header;
|
||||
|
||||
int dataLength = response->base.length - sizeof(response->base);
|
||||
if (dataLength < 0) {
|
||||
LOG(ERROR) << "invalid data length: " << response->base.length;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ssize_t dataSize = read(fd, &response->data, dataLength);
|
||||
if (dataSize < dataLength) {
|
||||
LOG(ERROR) << "unexpected display event data size: " << dataSize;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
53
sensors/sensor-notifier/utils/SscCalApiWrapper.cpp
Normal file
53
sensors/sensor-notifier/utils/SscCalApiWrapper.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define LOG_TAG "SscCalApiWrapper"
|
||||
|
||||
#include "SscCalApi.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
SscCalApiWrapper::SscCalApiWrapper() {
|
||||
mSscCalApiHandle = dlopen("libssccalapi@2.0.so", RTLD_NOW);
|
||||
if (mSscCalApiHandle) {
|
||||
init_current_sensors =
|
||||
(init_current_sensors_t)dlsym(mSscCalApiHandle, "_Z20init_current_sensorsb");
|
||||
if (init_current_sensors == NULL) {
|
||||
LOG(ERROR) << "could not find init_current_sensors: " << dlerror();
|
||||
}
|
||||
|
||||
process_msg = (process_msg_t)dlsym(mSscCalApiHandle, "_Z11process_msgP8_oem_msg");
|
||||
if (process_msg == NULL) {
|
||||
LOG(ERROR) << "could not find process_msg: " << dlerror();
|
||||
}
|
||||
} else {
|
||||
LOG(INFO) << "could not dlopen libssccalapi@2.0.so: " << dlerror();
|
||||
}
|
||||
}
|
||||
|
||||
SscCalApiWrapper::~SscCalApiWrapper() {
|
||||
dlclose(mSscCalApiHandle);
|
||||
}
|
||||
|
||||
SscCalApiWrapper& SscCalApiWrapper::getInstance() {
|
||||
static SscCalApiWrapper instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void SscCalApiWrapper::initCurrentSensors(bool debug) {
|
||||
if (init_current_sensors != NULL) {
|
||||
init_current_sensors(debug);
|
||||
}
|
||||
}
|
||||
|
||||
void SscCalApiWrapper::processMsg(_oem_msg* msg) {
|
||||
if (process_msg != NULL) {
|
||||
LOG(DEBUG) << "sending oem_msg for sensor " << msg->sensorType
|
||||
<< " with type: " << msg->notifyType << " and value: " << msg->value;
|
||||
process_msg(msg);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user