mirror of
https://gitee.com/openharmony/sensors_sensor
synced 2024-12-04 20:58:50 +00:00
commit
5aec5129ab
@ -56,7 +56,6 @@ ohos_shared_library("libsensor_client") {
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_single",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
@ -65,6 +64,10 @@ ohos_shared_library("libsensor_client") {
|
||||
external_deps += [ "hisysevent:libhisysevent" ]
|
||||
}
|
||||
|
||||
if (hiviewdfx_hitrace_enable) {
|
||||
external_deps += [ "hitrace:hitrace_meter" ]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "sensor"
|
||||
subsystem_name = "sensors"
|
||||
|
@ -59,6 +59,7 @@ private:
|
||||
int32_t InitServiceClient();
|
||||
void UpdateSensorInfoMap(int32_t sensorId, int64_t samplingPeriod, int64_t maxReportDelay);
|
||||
void DeleteSensorInfoItem(int32_t sensorId);
|
||||
int32_t CreateSocketClientFd(int32_t &clientFd);
|
||||
int32_t CreateSocketChannel();
|
||||
std::mutex clientMutex_;
|
||||
sptr<IRemoteObject::DeathRecipient> serviceDeathObserver_ = nullptr;
|
||||
|
@ -24,7 +24,9 @@
|
||||
#ifdef HIVIEWDFX_HISYSEVENT_ENABLE
|
||||
#include "hisysevent.h"
|
||||
#endif // HIVIEWDFX_HISYSEVENT_ENABLE
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
#include "hitrace_meter.h"
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
#include "ipc_skeleton.h"
|
||||
#include "sensor_errors.h"
|
||||
#include "sensor_service_proxy.h"
|
||||
@ -136,9 +138,13 @@ int32_t SensorServiceClient::EnableSensor(int32_t sensorId, int64_t samplingPeri
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "EnableSensor");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->EnableSensor(sensorId, samplingPeriod, maxReportDelay);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret == ERR_OK) {
|
||||
UpdateSensorInfoMap(sensorId, samplingPeriod, maxReportDelay);
|
||||
}
|
||||
@ -155,9 +161,13 @@ int32_t SensorServiceClient::DisableSensor(int32_t sensorId)
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "DisableSensor");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->DisableSensor(sensorId);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret == ERR_OK) {
|
||||
DeleteSensorInfoItem(sensorId);
|
||||
}
|
||||
@ -194,12 +204,16 @@ int32_t SensorServiceClient::TransferDataChannel(sptr<SensorDataChannel> sensorD
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "TransferDataChannel");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
CHKPR(sensorClientStub_, INVALID_POINTER);
|
||||
auto remoteObject = sensorClientStub_->AsObject();
|
||||
CHKPR(remoteObject, INVALID_POINTER);
|
||||
ret = sensorServer_->TransferDataChannel(sensorDataChannel, remoteObject);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -213,12 +227,16 @@ int32_t SensorServiceClient::DestroyDataChannel()
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "DestroyDataChannel");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
CHKPR(sensorClientStub_, INVALID_POINTER);
|
||||
auto remoteObject = sensorClientStub_->AsObject();
|
||||
CHKPR(remoteObject, INVALID_POINTER);
|
||||
ret = sensorServer_->DestroySensorChannel(remoteObject);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -307,9 +325,13 @@ int32_t SensorServiceClient::SuspendSensors(int32_t pid)
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "SuspendSensors");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->SuspendSensors(pid);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -323,9 +345,13 @@ int32_t SensorServiceClient::ResumeSensors(int32_t pid)
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "ResumeSensors");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->ResumeSensors(pid);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -339,9 +365,13 @@ int32_t SensorServiceClient::GetActiveInfoList(int32_t pid, std::vector<ActiveIn
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "GetActiveInfoList");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->GetActiveInfoList(pid, activeInfoList);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -382,20 +412,28 @@ int32_t SensorServiceClient::Unregister(SensorActiveInfoCB callback)
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "DisableActiveInfoCB");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->DisableActiveInfoCB();
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGE("Disable active info callback failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
Disconnect();
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "DestroySocketChannel");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
CHKPR(sensorClientStub_, INVALID_POINTER);
|
||||
auto remoteObject = sensorClientStub_->AsObject();
|
||||
CHKPR(remoteObject, INVALID_POINTER);
|
||||
ret = sensorServer_->DestroySocketChannel(remoteObject);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGE("Destroy socket channel failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -414,9 +452,13 @@ int32_t SensorServiceClient::ResetSensors()
|
||||
}
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "ResetSensors");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->ResetSensors();
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -482,6 +524,21 @@ void SensorServiceClient::Disconnect()
|
||||
Close();
|
||||
}
|
||||
|
||||
int32_t SensorServiceClient::CreateSocketClientFd(int32_t &clientFd)
|
||||
{
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "CreateSocketChannel");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
CHKPR(sensorClientStub_, INVALID_POINTER);
|
||||
auto remoteObject = sensorClientStub_->AsObject();
|
||||
CHKPR(remoteObject, INVALID_POINTER);
|
||||
int ret = sensorServer_->CreateSocketChannel(remoteObject, clientFd);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SensorServiceClient::CreateSocketChannel()
|
||||
{
|
||||
CALL_LOG_ENTER;
|
||||
@ -493,12 +550,7 @@ int32_t SensorServiceClient::CreateSocketChannel()
|
||||
std::lock_guard<std::mutex> clientLock(clientMutex_);
|
||||
CHKPR(sensorServer_, ERROR);
|
||||
int32_t clientFd = -1;
|
||||
StartTrace(HITRACE_TAG_SENSORS, "CreateSocketChannel");
|
||||
CHKPR(sensorClientStub_, INVALID_POINTER);
|
||||
auto remoteObject = sensorClientStub_->AsObject();
|
||||
CHKPR(remoteObject, INVALID_POINTER);
|
||||
ret = sensorServer_->CreateSocketChannel(remoteObject, clientFd);
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
ret = CreateSocketClientFd(clientFd);
|
||||
if (ret != ERR_OK || clientFd < 0) {
|
||||
Close();
|
||||
SEN_HILOGE("Create socket channel failed, ret:%{public}d", ret);
|
||||
@ -519,9 +571,13 @@ int32_t SensorServiceClient::CreateSocketChannel()
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "EnableActiveInfoCB");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
ret = sensorServer_->EnableActiveInfoCB();
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGE("Enable active info callback failed, ret:%{public}d", ret);
|
||||
Disconnect();
|
||||
|
@ -16,6 +16,7 @@ import("//build/ohos.gni")
|
||||
declare_args() {
|
||||
hiviewdfx_hisysevent_enable = false
|
||||
sensor_rust_socket_ipc = false
|
||||
hiviewdfx_hitrace_enable = false
|
||||
}
|
||||
|
||||
SUBSYSTEM_DIR = "//base/sensors/sensor"
|
||||
@ -55,3 +56,9 @@ if (defined(global_parts_info) &&
|
||||
hiviewdfx_hisysevent_enable = true
|
||||
sensor_default_defines += [ "HIVIEWDFX_HISYSEVENT_ENABLE" ]
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.hiviewdfx_hitrace)) {
|
||||
hiviewdfx_hitrace_enable = true
|
||||
sensor_default_defines += [ "HIVIEWDFX_HITRACE_ENABLE" ]
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ ohos_shared_library("libsensor_service") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
@ -74,6 +73,10 @@ ohos_shared_library("libsensor_service") {
|
||||
external_deps += [ "hisysevent:libhisysevent" ]
|
||||
}
|
||||
|
||||
if (hiviewdfx_hitrace_enable) {
|
||||
external_deps += [ "hitrace:hitrace_meter" ]
|
||||
}
|
||||
|
||||
if (hdf_drivers_interface_sensor) {
|
||||
sources += [
|
||||
"hdi_connection/adapter/src/hdi_connection.cpp",
|
||||
@ -151,7 +154,6 @@ ohos_static_library("libsensor_service_static") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
@ -166,6 +168,10 @@ ohos_static_library("libsensor_service_static") {
|
||||
external_deps += [ "hisysevent:libhisysevent" ]
|
||||
}
|
||||
|
||||
if (hiviewdfx_hitrace_enable) {
|
||||
external_deps += [ "hitrace:hitrace_meter" ]
|
||||
}
|
||||
|
||||
if (hdf_drivers_interface_sensor) {
|
||||
sources += [
|
||||
"hdi_connection/adapter/src/hdi_connection.cpp",
|
||||
|
@ -19,7 +19,9 @@
|
||||
#endif // BUILD_VARIANT_ENG
|
||||
|
||||
#include "hdi_connection.h"
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
#include "hitrace_meter.h"
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
#include "sensor_errors.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
@ -230,13 +232,17 @@ int32_t SensorHdiConnection::GetSensorList(std::vector<Sensor> &sensorList)
|
||||
|
||||
int32_t SensorHdiConnection::EnableSensor(int32_t sensorId)
|
||||
{
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "EnableSensor");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
int32_t ret = ENABLE_SENSOR_ERR;
|
||||
#ifdef BUILD_VARIANT_ENG
|
||||
if (FindOneInMockSet(sensorId)) {
|
||||
CHKPR(iSensorCompatibleHdiConnection_, ENABLE_SENSOR_ERR);
|
||||
ret = iSensorCompatibleHdiConnection_->EnableSensor(sensorId);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGE("Enable sensor failed in compatible, sensorId:%{public}d", sensorId);
|
||||
return ENABLE_SENSOR_ERR;
|
||||
@ -246,7 +252,9 @@ int32_t SensorHdiConnection::EnableSensor(int32_t sensorId)
|
||||
#endif // BUILD_VARIANT_ENG
|
||||
CHKPR(iSensorHdiConnection_, ENABLE_SENSOR_ERR);
|
||||
ret = iSensorHdiConnection_->EnableSensor(sensorId);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGI("Enable sensor failed, sensorId:%{public}d", sensorId);
|
||||
return ENABLE_SENSOR_ERR;
|
||||
@ -256,13 +264,17 @@ int32_t SensorHdiConnection::EnableSensor(int32_t sensorId)
|
||||
|
||||
int32_t SensorHdiConnection::DisableSensor(int32_t sensorId)
|
||||
{
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "DisableSensor");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
int32_t ret = DISABLE_SENSOR_ERR;
|
||||
#ifdef BUILD_VARIANT_ENG
|
||||
if (FindOneInMockSet(sensorId)) {
|
||||
CHKPR(iSensorCompatibleHdiConnection_, DISABLE_SENSOR_ERR);
|
||||
ret = iSensorCompatibleHdiConnection_->DisableSensor(sensorId);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGE("Disable sensor failed in compatible, sensorId:%{public}d", sensorId);
|
||||
return DISABLE_SENSOR_ERR;
|
||||
@ -272,7 +284,9 @@ int32_t SensorHdiConnection::DisableSensor(int32_t sensorId)
|
||||
#endif // BUILD_VARIANT_ENG
|
||||
CHKPR(iSensorHdiConnection_, DISABLE_SENSOR_ERR);
|
||||
ret = iSensorHdiConnection_->DisableSensor(sensorId);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGI("Disable sensor failed, sensorId:%{public}d", sensorId);
|
||||
return DISABLE_SENSOR_ERR;
|
||||
@ -282,13 +296,17 @@ int32_t SensorHdiConnection::DisableSensor(int32_t sensorId)
|
||||
|
||||
int32_t SensorHdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval)
|
||||
{
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "SetBatch");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
int32_t ret = SET_SENSOR_CONFIG_ERR;
|
||||
#ifdef BUILD_VARIANT_ENG
|
||||
if (FindOneInMockSet(sensorId)) {
|
||||
CHKPR(iSensorCompatibleHdiConnection_, SET_SENSOR_CONFIG_ERR);
|
||||
ret = iSensorCompatibleHdiConnection_->SetBatch(sensorId, samplingInterval, reportInterval);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGI("Set batch failed in compatible, sensorId:%{public}d", sensorId);
|
||||
return SET_SENSOR_CONFIG_ERR;
|
||||
@ -298,7 +316,9 @@ int32_t SensorHdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval
|
||||
#endif // BUILD_VARIANT_ENG
|
||||
CHKPR(iSensorHdiConnection_, SET_SENSOR_CONFIG_ERR);
|
||||
ret = iSensorHdiConnection_->SetBatch(sensorId, samplingInterval, reportInterval);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGI("Set batch failed, sensorId:%{public}d", sensorId);
|
||||
return SET_SENSOR_CONFIG_ERR;
|
||||
@ -308,13 +328,17 @@ int32_t SensorHdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval
|
||||
|
||||
int32_t SensorHdiConnection::SetMode(int32_t sensorId, int32_t mode)
|
||||
{
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "SetMode");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
int32_t ret = SET_SENSOR_MODE_ERR;
|
||||
#ifdef BUILD_VARIANT_ENG
|
||||
if (FindOneInMockSet(sensorId)) {
|
||||
CHKPR(iSensorCompatibleHdiConnection_, SET_SENSOR_MODE_ERR);
|
||||
ret = iSensorCompatibleHdiConnection_->SetMode(sensorId, mode);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGI("Set mode failed, sensorId:%{public}d", sensorId);
|
||||
return SET_SENSOR_MODE_ERR;
|
||||
@ -324,7 +348,9 @@ int32_t SensorHdiConnection::SetMode(int32_t sensorId, int32_t mode)
|
||||
#endif // BUILD_VARIANT_ENG
|
||||
CHKPR(iSensorHdiConnection_, SET_SENSOR_MODE_ERR);
|
||||
ret = iSensorHdiConnection_->SetMode(sensorId, mode);
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
if (ret != ERR_OK) {
|
||||
SEN_HILOGI("Set mode failed, sensorId:%{public}d", sensorId);
|
||||
return SET_SENSOR_MODE_ERR;
|
||||
@ -334,7 +360,9 @@ int32_t SensorHdiConnection::SetMode(int32_t sensorId, int32_t mode)
|
||||
|
||||
int32_t SensorHdiConnection::RegisterDataReport(ReportDataCb cb, sptr<ReportDataCallback> reportDataCallback)
|
||||
{
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
StartTrace(HITRACE_TAG_SENSORS, "RegisterDataReport");
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
CHKPR(iSensorHdiConnection_, REGIST_CALLBACK_ERR);
|
||||
int32_t ret = iSensorHdiConnection_->RegisterDataReport(cb, reportDataCallback);
|
||||
if (ret != ERR_OK) {
|
||||
@ -350,7 +378,9 @@ int32_t SensorHdiConnection::RegisterDataReport(ReportDataCb cb, sptr<ReportData
|
||||
}
|
||||
}
|
||||
#endif // BUILD_VARIANT_ENG
|
||||
#ifdef HIVIEWDFX_HITRACE_ENABLE
|
||||
FinishTrace(HITRACE_TAG_SENSORS);
|
||||
#endif // HIVIEWDFX_HITRACE_ENABLE
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user