From c100a94716f0d458b1b09a204a05af2aae96fa0e Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 31 Mar 2022 11:37:48 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=95=B4=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../adapter/src/compatible_connection.cpp | 26 ++--- .../adapter/src/hdi_connection.cpp | 100 ++++++++--------- .../adapter/src/sensor_event_callback.cpp | 4 +- .../hardware/src/hdi_service_impl.cpp | 24 ++-- .../interface/src/sensor_hdi_connection.cpp | 27 +++-- services/sensor/src/client_info.cpp | 94 ++++++++-------- services/sensor/src/flush_info_record.cpp | 15 ++- services/sensor/src/sensor_client_stub.cpp | 4 +- services/sensor/src/sensor_data_processer.cpp | 44 ++++---- services/sensor/src/sensor_dump.cpp | 17 +-- services/sensor/src/sensor_manager.cpp | 30 ++--- services/sensor/src/sensor_service.cpp | 105 +++++++++--------- services/sensor/src/sensor_service_stub.cpp | 28 ++--- services/sensor/src/sensor_suspend_policy.cpp | 31 +++--- 14 files changed, 268 insertions(+), 281 deletions(-) diff --git a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp index 13b0d0db..3fbbfb82 100644 --- a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp @@ -33,7 +33,7 @@ std::mutex ISensorHdiConnection::dataMutex_; std::condition_variable ISensorHdiConnection::dataCondition_; int32_t CompatibleConnection::ConnectHdi() { - HiLog::Info(LABEL, "%{public}s connect hdi success", __func__); + SEN_HILOGI("connect hdi success"); return ERR_OK; } @@ -42,7 +42,7 @@ int32_t CompatibleConnection::GetSensorList(std::vector& sensorList) std::vector sensorInfos; int32_t ret = hdiServiceImpl_.GetSensorList(sensorInfos); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s get sensor list failed", __func__); + SEN_HILOGE("get sensor list failed"); return ret; } for (int32_t i = 0; i < static_cast(sensorInfos.size()); i++) { @@ -71,7 +71,7 @@ int32_t CompatibleConnection::EnableSensor(int32_t sensorId) { int32_t ret = hdiServiceImpl_.EnableSensor(sensorId); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s enable sensor failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGE("enable sensor failed, sensorId: %{public}d", sensorId); return ret; } return ERR_OK; @@ -81,7 +81,7 @@ int32_t CompatibleConnection::DisableSensor(int32_t sensorId) { int32_t ret = hdiServiceImpl_.DisableSensor(sensorId); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s disable sensor failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGE("disable sensor failed, sensorId: %{public}d", sensorId); return ret; } return ERR_OK; @@ -91,7 +91,7 @@ int32_t CompatibleConnection::SetBatch(int32_t sensorId, int64_t samplingInterva { int32_t ret = hdiServiceImpl_.SetBatch(sensorId, samplingInterval, reportInterval); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s set batch failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGE("set batch failed, sensorId: %{public}d", sensorId); return ret; } return ERR_OK; @@ -101,7 +101,7 @@ int32_t CompatibleConnection::SetMode(int32_t sensorId, int32_t mode) { int32_t ret = hdiServiceImpl_.SetMode(sensorId, mode); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s set mode failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("set mode failed, sensorId: %{public}d", sensorId); return ret; } return ERR_OK; @@ -116,7 +116,7 @@ int32_t CompatibleConnection::SetOption(int32_t sensorId, int32_t option) { int32_t ret = hdiServiceImpl_.SetOption(sensorId, option); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s set option failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("set option failed, sensorId: %{public}d", sensorId); return ret; } return ERR_OK; @@ -125,11 +125,11 @@ int32_t CompatibleConnection::SetOption(int32_t sensorId, int32_t option) int32_t CompatibleConnection::SensorDataCallback(const struct SensorEvents *event) { if ((event == nullptr) || (event->dataLen == 0)) { - HiLog::Error(LABEL, "%{public}s event is NULL", __func__); + SEN_HILOGE("event is NULL"); return ERR_INVALID_VALUE; } if (reportDataCb_ == nullptr || reportDataCallback_ == nullptr) { - HiLog::Error(LABEL, "%{public}s reportDataCb_ cannot be null", __func__); + SEN_HILOGE("reportDataCb_ cannot be null"); return ERR_NO_INIT; } @@ -144,7 +144,7 @@ int32_t CompatibleConnection::SensorDataCallback(const struct SensorEvents *even sensorEvent.data = new uint8_t[SENSOR_DATA_LENGHT]; errno_t ret = memcpy_s(sensorEvent.data, event->dataLen, event->data, event->dataLen); if (ret != EOK) { - HiLog::Error(LABEL, "%{public}s copy data failed", __func__); + SEN_HILOGE("copy data failed"); delete[] sensorEvent.data; return COPY_ERR; } @@ -156,12 +156,12 @@ int32_t CompatibleConnection::SensorDataCallback(const struct SensorEvents *even int32_t CompatibleConnection::RegisteDataReport(ZReportDataCb cb, sptr reportDataCallback) { if (reportDataCallback == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, reportDataCallback cannot be null", __func__); + SEN_HILOGE("failed, reportDataCallback cannot be null"); return ERR_INVALID_VALUE; } int32_t ret = hdiServiceImpl_.Register(SensorDataCallback); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s failed", __func__); + SEN_HILOGE("failed"); return ret; } reportDataCb_ = cb; @@ -173,7 +173,7 @@ int32_t CompatibleConnection::DestroyHdiConnection() { int32_t ret = hdiServiceImpl_.Unregister(); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s failed", __func__); + SEN_HILOGE("failed"); return ret; } return ERR_OK; diff --git a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp index 1f77cb9a..72f17d79 100644 --- a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp @@ -44,39 +44,39 @@ sptr HdiConnection::reportDataCallback_ = nullptr; int32_t HdiConnection::ConnectHdi() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; int32_t retry = 0; while (retry < GET_HDI_SERVICE_COUNT) { sensorInterface_ = ISensorInterface::Get(); if (sensorInterface_ != nullptr) { - HiLog::Info(LABEL, "%{public}s connect v1_0 hdi success", __func__); + SEN_HILOGI("connect v1_0 hdi success"); eventCallback_ = new (std::nothrow) SensorEventCallback(); if (eventCallback_ == nullptr) { - HiLog::Error(LABEL, "%{public}s failed to initialize eventCallback", __func__); + SEN_HILOGE("failed to initialize eventCallback"); return ERR_NO_INIT; } RegisterHdiDeathRecipient(); return ERR_OK; } retry++; - HiLog::Warn(LABEL, "%{public}s connect hdi service failed, retry : %{public}d", __func__, retry); + SEN_HILOGE("connect hdi service failed, retry : %{public}d", retry); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); } - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("get sensor list failed"); return ERR_NO_INIT; } int32_t HdiConnection::GetSensorList(std::vector& sensorList) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("get sensor list failed"); return ERR_NO_INIT; } std::vector sensorInfos; int32_t ret = sensorInterface_->GetAllSensorInfo(sensorInfos); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s get sensor list failed", __func__); + SEN_HILOGE("get sensor list failed"); return ret; } for (size_t i = 0; i < sensorInfos.size(); i++) { @@ -92,19 +92,18 @@ int32_t HdiConnection::GetSensorList(std::vector& sensorList) sensor.SetPower(sensorInfos[i].power); sensorList.push_back(sensor); } - HiLog::Debug(LABEL, "%{public}s end", __func__); return ERR_OK; } int32_t HdiConnection::EnableSensor(int32_t sensorId) { if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->Enable(sensorId); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s is failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ret; } setSensorBasicInfoState(sensorId, true); @@ -114,12 +113,12 @@ int32_t HdiConnection::EnableSensor(int32_t sensorId) int32_t HdiConnection::DisableSensor(int32_t sensorId) { if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->Disable(sensorId); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s is failed", __func__); + SEN_HILOGE("is failed"); return ret; } deleteSensorBasicInfoState(sensorId); @@ -129,12 +128,12 @@ int32_t HdiConnection::DisableSensor(int32_t sensorId) int32_t HdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) { if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->SetBatch(sensorId, samplingInterval, reportInterval); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s failed", __func__); + SEN_HILOGE("failed"); return ret; } updateSensorBasicInfo(sensorId, samplingInterval, reportInterval); @@ -143,69 +142,65 @@ int32_t HdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int6 int32_t HdiConnection::SetMode(int32_t sensorId, int32_t mode) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->SetMode(sensorId, mode); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s is failed", __func__); + SEN_HILOGE("is failed"); return ret; } - HiLog::Debug(LABEL, "%{public}s end", __func__); return ERR_OK; } int32_t HdiConnection::SetOption(int32_t sensorId, int32_t option) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->SetOption(sensorId, option); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s is failed", __func__); + SEN_HILOGE("is failed"); return ret; } - HiLog::Debug(LABEL, "%{public}s end", __func__); return ERR_OK; } int32_t HdiConnection::RegisteDataReport(ZReportDataCb cb, sptr reportDataCallback) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (reportDataCallback == nullptr || sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, reportDataCallback or sensorInterface_ cannot be null", __func__); + SEN_HILOGE("failed, reportDataCallback or sensorInterface_ cannot be null"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->Register(0, eventCallback_); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s failed", __func__); + SEN_HILOGE("failed"); return ret; } reportDataCb_ = cb; reportDataCallback_ = reportDataCallback; - HiLog::Debug(LABEL, "%{public}s end", __func__); return ERR_OK; } int32_t HdiConnection::DestroyHdiConnection() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } int32_t ret = sensorInterface_->Unregister(0, eventCallback_); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s failed", __func__); + SEN_HILOGE("failed"); return ret; } eventCallback_ = nullptr; UnregisterHdiDeathRecipient(); - HiLog::Debug(LABEL, "%{public}s end", __func__); return ERR_OK; } @@ -216,21 +211,19 @@ int32_t HdiConnection::RunCommand(int32_t sensorId, int32_t cmd, int32_t params) ZReportDataCb HdiConnection::getReportDataCb() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (reportDataCb_ == nullptr) { - HiLog::Error(LABEL, "%{public}s reportDataCb_ cannot be null", __func__); + SEN_HILOGE("reportDataCb_ cannot be null"); } - HiLog::Debug(LABEL, "%{public}s end", __func__); return reportDataCb_; } sptr HdiConnection::getReportDataCallback() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (reportDataCallback_ == nullptr) { - HiLog::Error(LABEL, "%{public}s reportDataCallback_ cannot be null", __func__); + SEN_HILOGE("reportDataCallback_ cannot be null"); } - HiLog::Debug(LABEL, "%{public}s end", __func__); return reportDataCallback_; } @@ -248,7 +241,7 @@ void HdiConnection::setSensorBasicInfoState(int32_t sensorId, bool state) std::lock_guard sensorInfoLock(sensorBasicInfoMutex_); auto it = sensorBasicInfoMap_.find(sensorId); if (it == sensorBasicInfoMap_.end()) { - HiLog::Warn(LABEL, "%{public}s should set batch first", __func__); + SEN_HILOGW("should set batch first"); return; } sensorBasicInfoMap_[sensorId].SetSensorState(state); @@ -265,62 +258,59 @@ void HdiConnection::deleteSensorBasicInfoState(int32_t sensorId) void HdiConnection::RegisterHdiDeathRecipient() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorInterface_ == nullptr) { - HiLog::Error(LABEL, "%{public}s connect v1_0 hdi failed", __func__); + SEN_HILOGE("connect v1_0 hdi failed"); return; } hdiDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); if (hdiDeathObserver_ == nullptr) { - HiLog::Error(LABEL, "%{public}s hdiDeathObserver_ cannot be null", __func__); + SEN_HILOGE("hdiDeathObserver_ cannot be null"); return; } sensorInterface_->AsObject()->AddDeathRecipient(hdiDeathObserver_); - HiLog::Debug(LABEL, "%{public}s end", __func__); } void HdiConnection::UnregisterHdiDeathRecipient() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorInterface_ == nullptr || hdiDeathObserver_ == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorInterface_ or hdiDeathObserver_ is null", __func__); + SEN_HILOGE("sensorInterface_ or hdiDeathObserver_ is null"); return; } sensorInterface_->AsObject()->RemoveDeathRecipient(hdiDeathObserver_); - HiLog::Debug(LABEL, "%{public}s end", __func__); } void HdiConnection::ProcessDeathObserver(const wptr &object) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; sptr hdiService = object.promote(); if (hdiService == nullptr) { - HiLog::Error(LABEL, "%{public}s invalid remote object", __func__); + SEN_HILOGE("invalid remote object"); return; } hdiService->RemoveDeathRecipient(hdiDeathObserver_); eventCallback_ = nullptr; reconnect(); - HiLog::Debug(LABEL, "%{public}s end", __func__); } void HdiConnection::reconnect() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; int32_t ret = ConnectHdi(); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s failed to get an instance of hdi service", __func__); + SEN_HILOGE("failed to get an instance of hdi service"); return; } ret = sensorInterface_->Register(0, eventCallback_); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s register callback fail", __func__); + SEN_HILOGE("register callback fail"); return; } std::vector sensorList; ret = GetSensorList(sensorList); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s get sensor list fail", __func__); + SEN_HILOGE("get sensor list fail"); return; } std::lock_guard sensorInfoLock(sensorBasicInfoMutex_); @@ -329,16 +319,14 @@ void HdiConnection::reconnect() ret = SetBatch(sensorTypeId, sensorInfo.second.GetSamplingPeriodNs(), sensorInfo.second.GetMaxReportDelayNs()); if (ret < 0 || sensorInfo.second.GetSensorState() != true) { - HiLog::Error(LABEL, "%{public}s sensorTypeId: %{public}d set batch fail or not need enable sensor", - __func__, sensorTypeId); + SEN_HILOGE("sensorTypeId: %{public}d set batch fail or not need enable sensor", sensorTypeId); continue; } ret = EnableSensor(sensorTypeId); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s enable sensor fail, sensorTypeId: %{public}d", __func__, sensorTypeId); + SEN_HILOGE("enable sensor fail, sensorTypeId: %{public}d", sensorTypeId); } } - HiLog::Debug(LABEL, "%{public}s end", __func__); } } // namespace Sensors } // namespace OHOS diff --git a/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp b/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp index 0c3d7c88..02bd1bd0 100644 --- a/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp +++ b/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp @@ -30,12 +30,12 @@ int32_t SensorEventCallback::OnDataEvent(const HdfSensorEvents& event) ZReportDataCb reportDataCb_ = HdiConnection_->getReportDataCb(); sptr reportDataCallback_ = HdiConnection_->getReportDataCallback(); if (reportDataCb_ == nullptr || reportDataCallback_ == nullptr) { - HiLog::Error(LABEL, "%{public}s reportDataCb_ or reportDataCallback_ cannot be null", __func__); + SEN_HILOGI("reportDataCb_ or reportDataCallback_ cannot be null"); return ERR_NO_INIT; } int32_t dataSize = static_cast(event.data.size()); if (dataSize == 0) { - HiLog::Error(LABEL, "%{public}s data is empty", __func__); + SEN_HILOGI("data is empty"); return ERR_INVALID_VALUE; } struct SensorEvent sensorEvent = { diff --git a/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp b/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp index a4c0f50f..14d5fd02 100644 --- a/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp +++ b/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp @@ -44,14 +44,14 @@ std::atomic_bool HdiServiceImpl::g_isStop = false; int32_t HdiServiceImpl::GetSensorList(std::vector& sensorList) { - HiLog::Info(LABEL, "%{public}s in", __func__); + SEN_HILOGI("in"); sensorList.assign(g_sensorInfos.begin(), g_sensorInfos.end()); return ERR_OK; } void HdiServiceImpl::DataReportThread() { - HiLog::Info(LABEL, "%{public}s in", __func__); + SEN_HILOGI("in"); while (true) { usleep(g_samplingInterval / CONVERT_MULTIPLES); g_callback(&testEvent); @@ -59,23 +59,23 @@ void HdiServiceImpl::DataReportThread() break; } } - HiLog::Info(LABEL, "%{public}s thread stop", __func__); + SEN_HILOGI("thread stop"); return; } int32_t HdiServiceImpl::EnableSensor(uint32_t sensorId) { - HiLog::Info(LABEL, "%{public}s in", __func__); + SEN_HILOGI("in"); if (g_callback == nullptr) { - HiLog::Error(LABEL, "%{public}s enable sensor failed", __func__); + SEN_HILOGE("enable sensor failed"); return -1; } if (std::find(supportSensors.begin(), supportSensors.end(), sensorId) == supportSensors.end()) { - HiLog::Error(LABEL, "%{public}s not support enable sensorId: %{public}d", __func__, sensorId); + SEN_HILOGE("not support enable sensorId: %{public}d", sensorId); return ERR_NO_INIT; } if (std::find(g_enableSensors.begin(), g_enableSensors.end(), sensorId) != g_enableSensors.end()) { - HiLog::Info(LABEL, "%{public}s sensorId: %{public}d has been enabled", __func__, sensorId); + SEN_HILOGI("sensorId: %{public}d has been enabled", sensorId); return ERR_OK; } g_enableSensors.push_back(sensorId); @@ -92,13 +92,13 @@ int32_t HdiServiceImpl::EnableSensor(uint32_t sensorId) int32_t HdiServiceImpl::DisableSensor(uint32_t sensorId) { - HiLog::Info(LABEL, "%{public}s in", __func__); + SEN_HILOGI("in"); if (std::find(supportSensors.begin(), supportSensors.end(), sensorId) == supportSensors.end()) { - HiLog::Error(LABEL, "%{public}s not support disable sensorId: %{public}d", __func__, sensorId); + SEN_HILOGE("not support disable sensorId: %{public}d", sensorId); return ERR_NO_INIT; } if (std::find(g_enableSensors.begin(), g_enableSensors.end(), sensorId) == g_enableSensors.end()) { - HiLog::Error(LABEL, "%{public}s sensorId: %{public}d should be enable first", __func__, sensorId); + SEN_HILOGE("sensorId: %{public}d should be enable first", sensorId); return ERR_NO_INIT; } std::vector::iterator iter; @@ -116,7 +116,7 @@ int32_t HdiServiceImpl::DisableSensor(uint32_t sensorId) int32_t HdiServiceImpl::SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) { - HiLog::Info(LABEL, "%{public}s in", __func__); + SEN_HILOGI("in); if (samplingInterval < 0 || reportInterval < 0) { samplingInterval = SAMPLING_INTERVAL_NS; reportInterval = 0; @@ -144,7 +144,7 @@ int32_t HdiServiceImpl::SetOption(int32_t sensorId, uint32_t option) int32_t HdiServiceImpl::Register(RecordDataCallback cb) { if (cb == nullptr) { - HiLog::Error(LABEL, "%{public}s cb cannot be null", __func__); + SEN_HILOGE("cb cannot be null"); return -1; } g_callback = cb; diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index 0d5c04fd..f3fda294 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -30,18 +30,17 @@ int32_t SensorHdiConnection::ConnectHdi() { iSensorHdiConnection_ = std::make_unique(); if (iSensorHdiConnection_ == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, iSensorHdiConnection_ cannot be null", __func__); + SEN_HILOGE("failed, iSensorHdiConnection_ cannot be null"); return ERROR; } int32_t ret = connectHdiService(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s connect hdi service failed, try to connect compatible connection", - __func__); + SEN_HILOGE("connect hdi service failed, try to connect compatible connection"); iSensorHdiConnection_ = std::make_unique(); ret = connectHdiService(); } if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s connect hdi failed", __func__); + SEN_HILOGE("connect hdi failed"); } return ERR_OK; } @@ -50,12 +49,12 @@ int32_t SensorHdiConnection::connectHdiService() { int32_t ret = iSensorHdiConnection_->ConnectHdi(); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s connect hdi service failed", __func__); + SEN_HILOGE("connect hdi service failed"); return CONNECT_SENSOR_HDF_ERR; } ret = iSensorHdiConnection_->GetSensorList(sensorList_); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s get sensor list failed", __func__); + SEN_HILOGE("get sensor list failed"); return GET_SENSOR_LIST_ERR; } return ERR_OK; @@ -71,7 +70,7 @@ int32_t SensorHdiConnection::EnableSensor(int32_t sensorId) { int32_t ret = iSensorHdiConnection_->EnableSensor(sensorId); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s enable sensor failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("enable sensor failed, sensorId: %{public}d", sensorId); return ENABLE_SENSOR_ERR; } return ret; @@ -81,7 +80,7 @@ int32_t SensorHdiConnection::DisableSensor(int32_t sensorId) { int32_t ret = iSensorHdiConnection_->DisableSensor(sensorId); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s disable sensor failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("disable sensor failed, sensorId: %{public}d", sensorId); return DISABLE_SENSOR_ERR; } return ret; @@ -91,7 +90,7 @@ int32_t SensorHdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval { int32_t ret = iSensorHdiConnection_->SetBatch(sensorId, samplingInterval, reportInterval); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s set batch failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("set batch failed, sensorId: %{public}d", sensorId); return SET_SENSOR_CONFIG_ERR; } return ret; @@ -101,7 +100,7 @@ int32_t SensorHdiConnection::SetMode(int32_t sensorId, int32_t mode) { int32_t ret = iSensorHdiConnection_->SetMode(sensorId, mode); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s set mode failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("set mode failed, sensorId: %{public}d", sensorId); return SET_SENSOR_MODE_ERR; } return ret; @@ -111,7 +110,7 @@ int32_t SensorHdiConnection::SetOption(int32_t sensorId, int32_t option) { int32_t ret = iSensorHdiConnection_->SetOption(sensorId, option); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s set option failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("set option failed, sensorId: %{public}d", sensorId); return SET_SENSOR_OPTION_ERR; } return ret; @@ -121,7 +120,7 @@ int32_t SensorHdiConnection::RunCommand(int32_t sensorId, int32_t cmd, int32_t p { int32_t ret = iSensorHdiConnection_->RunCommand(sensorId, cmd, params); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s run command failed, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("run command failed, sensorId: %{public}d", sensorId); return RUN_COMMAND_ERR; } return ret; @@ -131,7 +130,7 @@ int32_t SensorHdiConnection::RegisteDataReport(ZReportDataCb cb, sptrRegisteDataReport(cb, reportDataCallback); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s registe dataReport failed", __func__); + SEN_HILOGI("registe dataReport failed"); return REGIST_CALLBACK_ERR; } return ret; @@ -141,7 +140,7 @@ int32_t SensorHdiConnection::DestroyHdiConnection() { int32_t ret = iSensorHdiConnection_->DestroyHdiConnection(); if (ret != 0) { - HiLog::Info(LABEL, "%{public}s destroy hdi connection failed", __func__); + SEN_HILOGI("destroy hdi connection failed"); return DEVICE_ERR; } return ret; diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index 8a0d593e..27db98b4 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -44,14 +44,14 @@ bool ClientInfo::GetSensorState(uint32_t sensorId) { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return false; } std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Error(LABEL, "%{public}s cannot find sensorId : %{public}u", __func__, sensorId); + SEN_HILOGE("cannot find sensorId : %{public}u", sensorId); return false; } for (const auto &pidIt : it->second) { @@ -59,7 +59,7 @@ bool ClientInfo::GetSensorState(uint32_t sensorId) return true; } } - HiLog::Error(LABEL, "%{public}s cannot find sensorinfo, sensorId : %{public}u", __func__, sensorId); + SEN_HILOGE("cannot find sensorinfo, sensorId : %{public}u", sensorId); return false; } @@ -72,14 +72,14 @@ SensorBasicInfo ClientInfo::GetBestSensorInfo(uint32_t sensorId) sensorInfo.SetSamplingPeriodNs(minSamplingPeriodNs); sensorInfo.SetMaxReportDelayNs(minReportDelayNs); if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return sensorInfo; } std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Error(LABEL, "%{public}s cannot find sensorId : %{public}u", __func__, sensorId); + SEN_HILOGE("cannot find sensorId : %{public}u", sensorId); return sensorInfo; } @@ -98,14 +98,14 @@ bool ClientInfo::OnlyCurPidSensorEnabled(uint32_t sensorId, int32_t pid) { CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || (pid <= INVALID_PID)) { - HiLog::Error(LABEL, "%{public}s sensorId or pid is invalid", __func__); + SEN_HILOGE("sensorId or pid is invalid"); return false; } std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Error(LABEL, "%{public}s cannot find sensorId : %{public}u", __func__, sensorId); + SEN_HILOGE("cannot find sensorId : %{public}u", sensorId); return false; } bool ret = false; @@ -125,7 +125,7 @@ bool ClientInfo::UpdateAppThreadInfo(int32_t pid, int32_t uid, AccessTokenID cal { CALL_LOG_ENTER; if ((uid == INVALID_UID) || (pid <= INVALID_PID)) { - HiLog::Error(LABEL, "%{public}s uid or pid is invalid", __func__); + SEN_HILOGE("uid or pid is invalid"); return false; } std::lock_guard uidLock(uidMutex_); @@ -133,7 +133,7 @@ bool ClientInfo::UpdateAppThreadInfo(int32_t pid, int32_t uid, AccessTokenID cal auto appThreadInfoItr = appThreadInfoMap_.find(pid); if (appThreadInfoItr == appThreadInfoMap_.end()) { if (appThreadInfoMap_.size() == MAX_SUPPORT_CHANNEL) { - HiLog::Error(LABEL, "%{public}s max support channel size is %{public}u", __func__, MAX_SUPPORT_CHANNEL); + SEN_HILOGE("max support channel size is %{public}u", MAX_SUPPORT_CHANNEL); return false; } auto ret = appThreadInfoMap_.insert(std::make_pair(pid, appThreadInfo)); @@ -147,13 +147,13 @@ void ClientInfo::DestroyAppThreadInfo(int32_t pid) { CALL_LOG_ENTER; if (pid == INVALID_PID) { - HiLog::Error(LABEL, "%{public}s pid is invalid", __func__); + SEN_HILOGE("pid is invalid"); return; } std::lock_guard uidLock(uidMutex_); auto appThreadInfoItr = appThreadInfoMap_.find(pid); if (appThreadInfoItr == appThreadInfoMap_.end()) { - HiLog::Debug(LABEL, "%{public}s uid not exist, no need to destroy it", __func__); + SEN_HILOGD("uid not exist, no need to destroy it"); return; } appThreadInfoMap_.erase(appThreadInfoItr); @@ -163,7 +163,7 @@ std::vector> ClientInfo::GetSensorChannelByUid(int3 { CALL_LOG_ENTER; if (uid == INVALID_UID) { - HiLog::Error(LABEL, "%{public}s uid is invalid", __func__); + SEN_HILOGE("uid is invalid"); return {}; } std::vector> sensorChannel; @@ -186,13 +186,13 @@ sptr ClientInfo::GetSensorChannelByPid(int32_t pid) { CALL_LOG_ENTER; if (pid == INVALID_PID) { - HiLog::Error(LABEL, "%{public}s pid is invalid", __func__); + SEN_HILOGE("pid is invalid"); return nullptr; } std::lock_guard channelLock(channelMutex_); auto channelIt = channelMap_.find(pid); if (channelIt == channelMap_.end()) { - HiLog::Error(LABEL, "%{public}s there is no channel belong to the pid", __func__); + SEN_HILOGE("there is no channel belong to the pid"); return nullptr; } return channelIt->second; @@ -201,14 +201,14 @@ sptr ClientInfo::GetSensorChannelByPid(int32_t pid) std::vector> ClientInfo::GetSensorChannel(uint32_t sensorId) { if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return {}; } std::lock_guard clientLock(clientMutex_); auto clientIt = clientMap_.find(sensorId); if (clientIt == clientMap_.end()) { - HiLog::Debug(LABEL, "%{public}s there is no channel belong to sensorId : %{public}u", __func__, sensorId); + SEN_HILOGD("there is no channel belong to sensorId : %{public}u", sensorId); return {}; } std::vector> sensorChannel; @@ -227,7 +227,7 @@ bool ClientInfo::UpdateSensorInfo(uint32_t sensorId, int32_t pid, const SensorBa { CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || (pid <= INVALID_PID) || (!sensorInfo.GetSensorState())) { - HiLog::Error(LABEL, "%{public}s params are invalid", __func__); + SEN_HILOGE("params are invalid"); return false; } std::lock_guard clientLock(clientMutex_); @@ -252,7 +252,7 @@ void ClientInfo::RemoveSubscriber(uint32_t sensorId, uint32_t pid) std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Warn(LABEL, "%{public}s sensorId not exist", __func__); + SEN_HILOGW("sensorId not exist"); return; } auto pidIt = it->second.find(pid); @@ -265,18 +265,18 @@ bool ClientInfo::UpdateSensorChannel(int32_t pid, const sptr channelLock(channelMutex_); auto it = channelMap_.find(pid); if (it == channelMap_.end()) { if (channelMap_.size() == MAX_SUPPORT_CHANNEL) { - HiLog::Error(LABEL, "%{public}s max support channel size : %{public}u", __func__, MAX_SUPPORT_CHANNEL); + SEN_HILOGE("max support channel size : %{public}u", MAX_SUPPORT_CHANNEL); return false; } auto ret = channelMap_.insert(std::make_pair(pid, channel)); - HiLog::Debug(LABEL, "%{public}s ret.second : %{public}d", __func__, ret.second); + SEN_HILOGD("ret.second : %{public}d", ret.second); return ret.second; } channelMap_[pid] = channel; @@ -287,13 +287,13 @@ void ClientInfo::ClearSensorInfo(uint32_t sensorId) { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return; } std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Debug(LABEL, "%{public}s sensorId not exist, no need to clear it", __func__); + SEN_HILOGD("sensorId not exist, no need to clear it"); return; } clientMap_.erase(it); @@ -303,18 +303,18 @@ void ClientInfo::ClearCurPidSensorInfo(uint32_t sensorId, int32_t pid) { CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || (pid <= INVALID_PID)) { - HiLog::Error(LABEL, "%{public}s sensorId or pid is invalid", __func__); + SEN_HILOGE("sensorId or pid is invalid"); return; } std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Debug(LABEL, "%{public}s sensorId not exist, no need to clear it", __func__); + SEN_HILOGD("sensorId not exist, no need to clear it"); return; } auto pidIt = it->second.find(pid); if (pidIt == it->second.end()) { - HiLog::Debug(LABEL, "%{public}s pid not exist, no need to clear it", __func__); + SEN_HILOGD("pid not exist, no need to clear it"); return; } pidIt = it->second.erase(pidIt); @@ -327,7 +327,7 @@ bool ClientInfo::DestroySensorChannel(int32_t pid) { CALL_LOG_ENTER; if (pid <= INVALID_PID) { - HiLog::Error(LABEL, "%{public}s pid is invalid", __func__); + SEN_HILOGE("pid is invalid"); return false; } std::lock_guard clientLock(clientMutex_); @@ -348,7 +348,7 @@ bool ClientInfo::DestroySensorChannel(int32_t pid) std::lock_guard channelLock(channelMutex_); auto it = channelMap_.find(pid); if (it == channelMap_.end()) { - HiLog::Debug(LABEL, "%{public}s there is no channel belong to pid, no need to destroy", __func__); + SEN_HILOGD("there is no channel belong to pid, no need to destroy"); return true; } it = channelMap_.erase(it); @@ -357,25 +357,25 @@ bool ClientInfo::DestroySensorChannel(int32_t pid) SensorBasicInfo ClientInfo::GetCurPidSensorInfo(uint32_t sensorId, int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u", __func__, sensorId); + SEN_HILOGD("begin, sensorId : %{public}u", sensorId); int64_t minSamplingPeriodNs = LLONG_MAX; int64_t minReportDelayNs = LLONG_MAX; SensorBasicInfo sensorInfo; sensorInfo.SetSamplingPeriodNs(minSamplingPeriodNs); sensorInfo.SetMaxReportDelayNs(minReportDelayNs); if ((sensorId == INVALID_SENSOR_ID) || (pid <= INVALID_PID)) { - HiLog::Error(LABEL, "%{public}s sensorId or channel is invalid", __func__); + SEN_HILOGE("sensorId or channel is invalid"); return sensorInfo; } std::lock_guard clientLock(clientMutex_); auto it = clientMap_.find(sensorId); if (it == clientMap_.end()) { - HiLog::Error(LABEL, "%{public}s cannot find sensorId : %{public}u", __func__, sensorId); + SEN_HILOGE("cannot find sensorId : %{public}u", sensorId); return sensorInfo; } auto pidIt = it->second.find(pid); if (pidIt == it->second.end()) { - HiLog::Error(LABEL, "%{public}s cannot find pid : %{public}d", __func__, pid); + SEN_HILOGE("cannot find pid : %{public}d", pid); return sensorInfo; } sensorInfo.SetSamplingPeriodNs(pidIt->second.GetSamplingPeriodNs()); @@ -386,7 +386,7 @@ SensorBasicInfo ClientInfo::GetCurPidSensorInfo(uint32_t sensorId, int32_t pid) uint64_t ClientInfo::ComputeBestPeriodCount(uint32_t sensorId, sptr &channel) { if (sensorId == INVALID_SENSOR_ID || channel == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid or channel cannot be null", __func__); + SEN_HILOGE("sensorId is invalid or channel cannot be null"); return 0UL; } int32_t pid = INVALID_PID; @@ -402,7 +402,7 @@ uint64_t ClientInfo::ComputeBestPeriodCount(uint32_t sensorId, sptr &channel) { if (channel == nullptr || sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid or channel cannot be null", __func__); + SEN_HILOGE("sensorId is invalid or channel cannot be null"); return 0UL; } int32_t pid = INVALID_PID; @@ -427,7 +427,7 @@ uint64_t ClientInfo::ComputeBestFifoCount(uint32_t sensorId, sptrsecond, sizeof(struct SensorEvent)); if (ret != EOK) { - HiLog::Error(LABEL, "%{public}s memcpy_s failed, sensorId : %{public}d", __func__, sensorId); + SEN_HILOGE("memcpy_s failed, sensorId : %{public}d", sensorId); return ret; } return ERR_OK; } - HiLog::Error(LABEL, "%{public}s can't get store event, sensorId : %{public}u", __func__, sensorId); + SEN_HILOGE("can't get store event, sensorId : %{public}u", sensorId); return NO_STROE_EVENT; } @@ -457,23 +457,23 @@ void ClientInfo::StoreEvent(const struct SensorEvent &event) struct SensorEvent storedEvent; auto sensorHdiConnection = &SensorHdiConnection::GetInstance(); if (sensorHdiConnection == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorHdiConnection cannot be null", __func__); + SEN_HILOGE("sensorHdiConnection cannot be null"); return; } std::vector sensors; int32_t ret = sensorHdiConnection->GetSensorList(sensors); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s GetSensorList failed", __func__); + SEN_HILOGE("GetSensorList failed"); return; } errno_t retVal = memcpy_s(&storedEvent, sizeof(storedEvent), &event, sizeof(event)); if (retVal != EOK) { - HiLog::Error(LABEL, "%{public}s memcpy_s failed", __func__); + SEN_HILOGE("memcpy_s failed"); return; } for (size_t i = 0; i < sensors.size(); i++) { if ((int32_t)(sensors[i].GetSensorId()) == storedEvent.sensorTypeId) { - HiLog::Debug(LABEL, "%{public}s sensorFlags : %{public}u", __func__, sensors[i].GetFlags()); + SEN_HILOGD("sensorFlags : %{public}u", sensors[i].GetFlags()); foundSensor = true; break; } @@ -489,7 +489,7 @@ bool ClientInfo::SaveClientPid(const sptr &sensorClient, int32_t { CALL_LOG_ENTER; if (sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); + SEN_HILOGE("sensorClient cannot be null"); return false; } std::lock_guard lock(clientPidMutex_); @@ -506,13 +506,13 @@ int32_t ClientInfo::FindClientPid(const sptr &sensorClient) { CALL_LOG_ENTER; if (sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); + SEN_HILOGE("sensorClient cannot be null"); return INVALID_PID; } std::lock_guard lock(clientPidMutex_); auto it = clientPidMap_.find(sensorClient); if (it == clientPidMap_.end()) { - HiLog::Error(LABEL, "%{public}s cannot find client pid", __func__); + SEN_HILOGE("cannot find client pid"); return INVALID_PID; } return it->second; @@ -522,13 +522,13 @@ void ClientInfo::DestroyClientPid(const sptr &sensorClient) { CALL_LOG_ENTER; if (sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); + SEN_HILOGE("sensorClient cannot be null"); return; } std::lock_guard lock(clientPidMutex_); auto it = clientPidMap_.find(sensorClient); if (it == clientPidMap_.end()) { - HiLog::Error(LABEL, "%{public}s cannot find client pid", __func__); + SEN_HILOGE("cannot find client pid"); return; } clientPidMap_.erase(it); diff --git a/services/sensor/src/flush_info_record.cpp b/services/sensor/src/flush_info_record.cpp index 3e714118..2f8bf68e 100644 --- a/services/sensor/src/flush_info_record.cpp +++ b/services/sensor/src/flush_info_record.cpp @@ -50,9 +50,9 @@ void FlushInfoRecord::ClearFlushInfoItem(uint32_t sensorId) ErrCode FlushInfoRecord::SetFlushInfo(uint32_t sensorId, const sptr &channel, bool isFirstFlush) { - HiLog::Debug(LABEL, "%{public}s, sensorId : %{public}u", __func__, sensorId); + SEN_HILOGD("sensorId : %{public}u", sensorId); if (channel == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, channel cannot be null", __func__); + SEN_HILOGE("failed, channel cannot be null"); return INVALID_POINTER; } struct FlushInfo flush(channel, isFirstFlush); @@ -72,10 +72,9 @@ ErrCode FlushInfoRecord::SetFlushInfo(uint32_t sensorId, const sptr> &currChannelList, const sptr &flushChannel) { - HiLog::Debug(LABEL, "%{public}s channel list size : %{public}u", __func__, - static_cast(currChannelList.size())); + SEN_HILOGD("channel list size : %{public}u", static_cast(currChannelList.size())); for (const auto &channel : currChannelList) { - HiLog::Debug(LABEL, "%{public}s channel : %{public}p, flushchannel : %{public}p", __func__, channel.GetRefPtr(), + SEN_HILOGD("channel : %{public}p, flushchannel : %{public}p", channel.GetRefPtr(), flushChannel.GetRefPtr()); if (channel == flushChannel) { return true; @@ -101,17 +100,17 @@ ErrCode FlushInfoRecord::FlushProcess(const uint32_t sensorId, const uint32_t fl { auto ret = sensorHdiConnection_.RunCommand(sensorId, FLUSH, 0); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s flush command failed", __func__); + SEN_HILOGE("flush command failed"); return ret; } sptr channel = clientInfo_.GetSensorChannelByPid(pid); if (channel == nullptr) { - HiLog::Error(LABEL, "%{public}s channel cannot be null", __func__); + SEN_HILOGE("channel cannot be null"); return ERROR; } ret = SetFlushInfo(sensorId, channel, false); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s set flush info failed", __func__); + SEN_HILOGE("set flush info failed"); return ret; } return ERR_OK; diff --git a/services/sensor/src/sensor_client_stub.cpp b/services/sensor/src/sensor_client_stub.cpp index 8d9491f0..7d3c0931 100644 --- a/services/sensor/src/sensor_client_stub.cpp +++ b/services/sensor/src/sensor_client_stub.cpp @@ -33,10 +33,10 @@ int32_t SensorClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me std::u16string descriptor = SensorClientStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { - HiLog::Error(LABEL, "%{public}s client and service descriptors are inconsistent", __func__); + SEN_HILOGE("client and service descriptors are inconsistent"); return OBJECT_NULL; } - HiLog::Debug(LABEL, "%{public}s begin, cmd : %{public}u", __func__, code); + SEN_HILOGD("begin, cmd : %{public}u", code); return NO_ERROR; } } // namespace Sensors diff --git a/services/sensor/src/sensor_data_processer.cpp b/services/sensor/src/sensor_data_processer.cpp index 748bef5f..4fa5254f 100644 --- a/services/sensor/src/sensor_data_processer.cpp +++ b/services/sensor/src/sensor_data_processer.cpp @@ -50,7 +50,7 @@ constexpr uint32_t FLUSH_COMPLETE_ID = ((uint32_t)OTHER << SENSOR_CATAGORY_SHIFT SensorDataProcesser::SensorDataProcesser(const std::unordered_map &sensorMap) { sensorMap_.insert(sensorMap.begin(), sensorMap.end()); - HiLog::Debug(LABEL, "%{public}s sensorMap_.size : %{public}d", __func__, int32_t { sensorMap_.size() }); + SEN_HILOGD("sensorMap_.size : %{public}d", int32_t { sensorMap_.size() }); } SensorDataProcesser::~SensorDataProcesser() @@ -75,7 +75,7 @@ void SensorDataProcesser::SendNoneFifoCacheData(std::unordered_map> channelFifoList; sptr fifoCacheData = new (std::nothrow) FifoCacheData(); if (fifoCacheData == nullptr) { - HiLog::Error(LABEL, "%{public}s fifoCacheData cannot be null", __func__); + SEN_HILOGE("fifoCacheData cannot be null"); return; } fifoCacheData->SetChannel(channel); @@ -103,7 +103,7 @@ void SensorDataProcesser::SendNoneFifoCacheData(std::unordered_map fifoCacheData = new (std::nothrow) FifoCacheData(); if (fifoCacheData == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, fifoCacheData cannot be null", __func__); + SEN_HILOGE("failed, fifoCacheData cannot be null"); return; } fifoCacheData->SetChannel(channel); @@ -127,7 +127,7 @@ void SensorDataProcesser::SendFifoCacheData(std::unordered_map> channelFifoList; sptr fifoCacheData = new (std::nothrow) FifoCacheData(); if (fifoCacheData == nullptr) { - HiLog::Error(LABEL, "%{public}s fifoCacheData cannot be null", __func__); + SEN_HILOGE("fifoCacheData cannot be null"); return; } fifoCacheData->SetChannel(channel); @@ -163,7 +163,7 @@ void SensorDataProcesser::SendFifoCacheData(std::unordered_map fifoCacheData = new (std::nothrow) FifoCacheData(); if (fifoCacheData == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, fifoCacheData cannot be null", __func__); + SEN_HILOGE("failed, fifoCacheData cannot be null"); return; } fifoCacheData->SetChannel(channel); @@ -174,7 +174,7 @@ void SensorDataProcesser::SendFifoCacheData(std::unordered_map &channel, struct SensorEvent &event) { if (channel == nullptr) { - HiLog::Error(LABEL, "%{public}s channel cannot be null", __func__); + SEN_HILOGE("channel cannot be null", code); return; } uint32_t sensorId = static_cast(event.sensorTypeId); @@ -208,7 +208,7 @@ bool SensorDataProcesser::ReportNotContinuousData(std::unordered_mapsecond.SetFlags(event.mode); if (sensor == sensorMap_.end()) { - HiLog::Error(LABEL, "%{public}s data's sensorId is not supported", __func__); + SEN_HILOGE("data's sensorId is not supported"); return false; } if (((SENSOR_ON_CHANGE & sensor->second.GetFlags()) == SENSOR_ON_CHANGE) || @@ -232,11 +232,11 @@ void SensorDataProcesser::SendRawData(std::unordered_map channel, std::vector event) { if (channel == nullptr || event.empty()) { - HiLog::Error(LABEL, "%{public}s channel cannot be null or event cannot be empty", __func__); + SEN_HILOGE("channel cannot be null or event cannot be empty"); return; } if (!CheckSendDataPermission(channel, event[0].sensorTypeId)) { - HiLog::Error(LABEL, "%{public}s permission denied", __func__); + SEN_HILOGE("permission denied"); return; } @@ -253,14 +253,14 @@ void SensorDataProcesser::SendRawData(std::unordered_mapSendData(transferEvents.data(), eventSize * sizeof(struct TransferSensorEvents)); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s send data failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("send data failed, ret : %{public}d", ret); uint32_t sensorId = static_cast(event[eventSize - 1].sensorTypeId); if (sensorId == FLUSH_COMPLETE_ID) { sensorId = static_cast(event[eventSize - 1].sensorTypeId); @@ -272,7 +272,7 @@ void SensorDataProcesser::SendRawData(std::unordered_map &channel) { if (channel == nullptr) { - HiLog::Error(LABEL, "%{public}s channel cannot be null", __func__); + SEN_HILOGE("channel cannot be null"); return INVALID_POINTER; } int32_t ret = ERR_OK; @@ -286,11 +286,11 @@ int32_t SensorDataProcesser::CacheSensorEvent(const struct SensorEvent &event, s // Try to send the last failed value, if it still fails, replace the previous cache directly ret = channel->SendData(&cacheEvent->second, sizeof(struct SensorEvent)); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s ret : %{public}d", __func__, ret); + SEN_HILOGE("ret : %{public}d", ret); } ret = channel->SendData(&event, sizeof(struct SensorEvent)); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s ret : %{public}d", __func__, ret); + SEN_HILOGE("ret : %{public}d", ret); cacheBuf[sensorId] = event; } else { cacheBuf.erase(cacheEvent); @@ -298,7 +298,7 @@ int32_t SensorDataProcesser::CacheSensorEvent(const struct SensorEvent &event, s } else { ret = channel->SendData(&event, sizeof(struct SensorEvent)); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s ret : %{public}d", __func__, ret); + SEN_HILOGE("ret : %{public}d", ret); cacheBuf[sensorId] = event; } } @@ -319,7 +319,7 @@ void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) auto flushInfo = flushInfo_.GetFlushInfo(); std::vector flushVec; if (sensorId == FLUSH_COMPLETE_ID) { - HiLog::Debug(LABEL, "%{public}s sensorId : %{public}u", __func__, sensorId); + SEN_HILOGD("sensorId : %{public}u", sensorId); auto it = flushInfo.find(realSensorId); if (it != flushInfo.end()) { flushVec = it->second; @@ -330,7 +330,7 @@ void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) break; } else { // The channel that store in the flushVec has invalid, so erase this channel directly - HiLog::Debug(LABEL, "%{public}s clear flush info", __func__); + SEN_HILOGD("clear flush info"); flushInfo_.ClearFlushInfoItem(realSensorId); } } @@ -340,7 +340,7 @@ void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) int32_t index = flushInfo_.GetFlushChannelIndex(flushVec, channel); if (index >= 0) { if (flushVec[index].flushFromEnable) { - HiLog::Info(LABEL, "%{public}s flushFromEnable", __func__); + SEN_HILOGE("flushFromEnable"); continue; } } @@ -356,14 +356,14 @@ void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) int32_t SensorDataProcesser::ProcessEvents(sptr dataCallback) { if (dataCallback == nullptr) { - HiLog::Error(LABEL, "%{public}s dataCallback cannot be null", __func__); + SEN_HILOGE("dataCallback cannot be null"); return INVALID_POINTER; } std::unique_lock lk(ISensorHdiConnection::dataMutex_); ISensorHdiConnection::dataCondition_.wait(lk); auto &eventsBuf = dataCallback->GetEventData(); if (eventsBuf.eventNum <= 0) { - HiLog::Error(LABEL, "%{public}s data cannot be empty", __func__); + SEN_HILOGE("data cannot be empty"); return NO_EVENT; } int32_t eventNum = eventsBuf.eventNum; @@ -382,7 +382,7 @@ int32_t SensorDataProcesser::ProcessEvents(sptr dataCallback int32_t SensorDataProcesser::SendEvents(sptr &channel, struct SensorEvent &event) { if (channel == nullptr) { - HiLog::Error(LABEL, "%{public}s channel cannot be null", __func__); + SEN_HILOGE("channel cannot be null"); return INVALID_POINTER; } clientInfo_.UpdateDataQueue(event.sensorTypeId, event); @@ -401,7 +401,7 @@ int32_t SensorDataProcesser::DataThread(sptr dataProcesser, CALL_LOG_ENTER; do { if (dataProcesser->ProcessEvents(dataCallback) == INVALID_POINTER) { - HiLog::Error(LABEL, "%{public}s callback cannot be null", __func__); + SEN_HILOGE("callback cannot be null"); return INVALID_POINTER; } } while (1); diff --git a/services/sensor/src/sensor_dump.cpp b/services/sensor/src/sensor_dump.cpp index 86b6c7a1..a3ac9a78 100644 --- a/services/sensor/src/sensor_dump.cpp +++ b/services/sensor/src/sensor_dump.cpp @@ -19,6 +19,7 @@ #include #include +#include "sensors_errors.h" #include "sensors_log_domain.h" namespace OHOS { @@ -115,7 +116,7 @@ std::unordered_map SensorDump::sensorMap_ = { bool SensorDump::DumpSensorHelp(int32_t fd, const std::vector &args) { if ((args.empty()) || (args[0].compare(u"-h") != 0)) { - HiLog::Error(LABEL, "%{public}s args cannot be empty or invalid", __func__); + SEN_HILOGE("args cannot be empty or invalid"); return false; } DumpHelp(fd); @@ -135,7 +136,7 @@ void SensorDump::DumpHelp(int32_t fd) bool SensorDump::DumpSensorList(int32_t fd, const std::vector &sensors, const std::vector &args) { if ((args.empty()) || (args[0].compare(u"-l") != 0)) { - HiLog::Error(LABEL, "%{public}s args cannot be empty or invalid", __func__); + SEN_HILOGE("args cannot be empty or invalid"); return false; } DumpCurrentTime(fd); @@ -155,7 +156,7 @@ bool SensorDump::DumpSensorList(int32_t fd, const std::vector &sensors, bool SensorDump::DumpSensorChannel(int32_t fd, ClientInfo &clientInfo, const std::vector &args) { if ((args.empty()) || (args[0].compare(u"-c") != 0)) { - HiLog::Error(LABEL, "%{public}s args cannot be empty or invalid", __func__); + SEN_HILOGE("args cannot be empty or invalid"); return false; } DumpCurrentTime(fd); @@ -182,7 +183,7 @@ bool SensorDump::DumpOpeningSensor(int32_t fd, const std::vector &sensor const std::vector &args) { if ((args.empty()) || (args[0].compare(u"-o") != 0)) { - HiLog::Error(LABEL, "%{public}s args cannot be empty or invalid", __func__); + SEN_HILOGE("args cannot be empty or invalid"); return false; } DumpCurrentTime(fd); @@ -199,7 +200,7 @@ bool SensorDump::DumpOpeningSensor(int32_t fd, const std::vector &sensor bool SensorDump::DumpSensorData(int32_t fd, ClientInfo &clientInfo, const std::vector &args) { if ((args.empty()) || (args[0].compare(u"-d") != 0)) { - HiLog::Error(LABEL, "%{public}s args cannot be empty or invalid", __func__); + SEN_HILOGE("args cannot be empty or invalid"); return false; } dprintf(fd, "Last 10 packages sensor data:\n"); @@ -214,7 +215,7 @@ bool SensorDump::DumpSensorData(int32_t fd, ClientInfo &clientInfo, const std::v timespec time = { 0, 0 }; struct tm *timeinfo = localtime(&(time.tv_sec)); if (timeinfo == nullptr) { - HiLog::Error(LABEL, "%{public}s timeinfo cannot be null", __func__); + SEN_HILOGE("timeinfo cannot be null"); return false; } dprintf(fd, " %2d (ts=%.9f, time=%02d:%02d:%02d.%03d) | data:%s", ++j, data.timestamp / 1e9, @@ -231,7 +232,7 @@ void SensorDump::DumpCurrentTime(int32_t fd) clock_gettime(CLOCK_REALTIME, &curTime); struct tm *timeinfo = localtime(&(curTime.tv_sec)); if (timeinfo == nullptr) { - HiLog::Error(LABEL, "%{public}s timeinfo cannot be null", __func__); + SEN_HILOGE("timeinfo cannot be null"); return; } dprintf(fd, "Current time: %02d:%02d:%02d.%03d\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, @@ -267,7 +268,7 @@ int32_t SensorDump::DataSizeBySensorId(uint32_t sensorId) std::string SensorDump::GetDataBySensorId(uint32_t sensorId, struct SensorEvent &sensorData) { - HiLog::Debug(LABEL, "%{public}s sensorId: %{public}u", __func__, sensorId); + SEN_HILOGD("sensorId: %{public}u", sensorId); std::string buffer; int32_t dataLen = DataSizeBySensorId(sensorId); for (int32_t i = 0; i < dataLen; ++i) { diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index d7ad7e16..c6a167b6 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -37,7 +37,7 @@ void SensorManager::InitSensorMap(std::unordered_map &sensorMa sensorMap_.insert(sensorMap.begin(), sensorMap.end()); sensorDataProcesser_ = dataProcesser; reportDataCallback_ = dataCallback; - HiLog::Debug(LABEL, "%{public}s begin sensorMap_.size : %{public}d", __func__, int32_t { sensorMap_.size() }); + SEN_HILOGD("begin sensorMap_.size : %{public}d", int32_t { sensorMap_.size() }); return; } @@ -55,22 +55,22 @@ bool SensorManager::SetBestSensorParams(uint32_t sensorId, int64_t samplingPerio { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return false; } SensorBasicInfo sensorInfo = clientInfo_.GetBestSensorInfo(sensorId); int64_t bestSamplingPeriodNs = sensorInfo.GetSamplingPeriodNs(); int64_t bestReportDelayNs = sensorInfo.GetMaxReportDelayNs(); if ((samplingPeriodNs > bestSamplingPeriodNs) && (maxReportDelayNs > bestReportDelayNs)) { - HiLog::Debug(LABEL, "%{public}s no need to reset sensor params", __func__); + SEN_HILOGD("no need to reset sensor params"); return true; } bestSamplingPeriodNs = (samplingPeriodNs < bestSamplingPeriodNs) ? samplingPeriodNs : bestSamplingPeriodNs; bestReportDelayNs = (maxReportDelayNs < bestReportDelayNs) ? maxReportDelayNs : bestReportDelayNs; - HiLog::Debug(LABEL, "%{public}s bestSamplingPeriodNs : %{public}d", __func__, int32_t { bestSamplingPeriodNs }); + SEN_HILOGD("bestSamplingPeriodNs : %{public}d", int32_t { bestSamplingPeriodNs }); auto ret = sensorHdiConnection_.SetBatch(sensorId, bestSamplingPeriodNs, bestReportDelayNs); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SetBatch failed", __func__); + SEN_HILOGE("SetBatch failed"); return false; } return true; @@ -80,14 +80,14 @@ bool SensorManager::ResetBestSensorParams(uint32_t sensorId) { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return false; } SensorBasicInfo sensorInfo = clientInfo_.GetBestSensorInfo(sensorId); auto ret = sensorHdiConnection_.SetBatch(sensorId, sensorInfo.GetSamplingPeriodNs(), sensorInfo.GetMaxReportDelayNs()); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SetBatch failed", __func__); + SEN_HILOGE("SetBatch failed"); return false; } return true; @@ -103,7 +103,7 @@ SensorBasicInfo SensorManager::GetSensorInfo(uint32_t sensorId, int64_t sampling sensorInfo.SetSamplingPeriodNs(samplingPeriodNs); sensorInfo.SetMaxReportDelayNs(maxReportDelayNs); sensorInfo.SetSensorState(true); - HiLog::Error(LABEL, "%{public}s sensorId invalid", __func__); + SEN_HILOGE("sensorId invalid"); return sensorInfo; } int64_t curSamplingPeriodNs = @@ -114,7 +114,7 @@ SensorBasicInfo SensorManager::GetSensorInfo(uint32_t sensorId, int64_t sampling } int32_t maxEventCount = it->second.GetFifoMaxEventCount(); if ((samplingPeriodNs == 0) || (maxEventCount > (INT64_MAX / samplingPeriodNs))) { - HiLog::Error(LABEL, "%{public}s failed, samplingPeriodNs overflow", __func__); + SEN_HILOGE("failed, samplingPeriodNs overflow"); return sensorInfo; } int64_t supportDelay = samplingPeriodNs * maxEventCount; @@ -131,7 +131,7 @@ ErrCode SensorManager::SaveSubscriber(uint32_t sensorId, uint32_t pid, int64_t s SensorBasicInfo sensorInfo = GetSensorInfo(sensorId, samplingPeriodNs, maxReportDelayNs); auto updateRet = clientInfo_.UpdateSensorInfo(sensorId, pid, sensorInfo); if (!updateRet) { - HiLog::Error(LABEL, "%{public}s UpdateSensorInfo failed", __func__); + SEN_HILOGE("UpdateSensorInfo failed"); return UPDATE_SENSOR_INFO_ERR; } return ERR_OK; @@ -141,7 +141,7 @@ void SensorManager::StartDataReportThread() { CALL_LOG_ENTER; if (!dataThread_.joinable()) { - HiLog::Warn(LABEL, "%{public}s dataThread_ started", __func__); + SEN_HILOGW("dataThread_ started"); std::thread senocdDataThread(SensorDataProcesser::DataThread, sensorDataProcesser_, reportDataCallback_); dataThread_ = std::move(senocdDataThread); } @@ -151,14 +151,14 @@ bool SensorManager::IsOtherClientUsingSensor(uint32_t sensorId, int32_t clientPi { CALL_LOG_ENTER; if (clientInfo_.OnlyCurPidSensorEnabled(sensorId, clientPid)) { - HiLog::Warn(LABEL, "%{public}s Only current client using this sensor", __func__); + SEN_HILOGW("Only current client using this sensor"); return false; } clientInfo_.ClearCurPidSensorInfo(sensorId, clientPid); if (!ResetBestSensorParams(sensorId)) { - HiLog::Warn(LABEL, "%{public}s ResetBestSensorParams failed", __func__); + SEN_HILOGW("ResetBestSensorParams failed"); } - HiLog::Debug(LABEL, "%{public}s other client is using this sensor", __func__); + SEN_HILOGD("other client is using this sensor"); return true; } @@ -170,7 +170,7 @@ ErrCode SensorManager::AfterDisableSensor(uint32_t sensorId) struct SensorEvent event; auto ret = clientInfo_.GetStoreEvent(sensorId, event); if (ret == ERR_OK) { - HiLog::Debug(LABEL, "%{public}s change the default state is far", __func__); + SEN_HILOGD("change the default state is far"); event.data[0] = PROXIMITY_FAR; clientInfo_.StoreEvent(event); } diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 564e5595..602705b3 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -55,39 +55,39 @@ SensorService::SensorService(int32_t systemAbilityId, bool runOnCreate) void SensorService::OnDump() { - HiLog::Info(LABEL, "OnDump"); + SEN_HILOGI("OnDump"); } void SensorService::OnStart() { CALL_LOG_ENTER; if (state_ == SensorServiceState::STATE_RUNNING) { - HiLog::Warn(LABEL, "%{public}s SensorService has already started", __func__); + SEN_HILOGW("SensorService has already started"); return; } if (!InitInterface()) { - HiLog::Error(LABEL, "%{public}s Init interface error", __func__); + SEN_HILOGE("Init interface error"); return; } if (!InitDataCallback()) { - HiLog::Error(LABEL, "%{public}s Init data callback error", __func__); + SEN_HILOGE("Init data callback error"); return; } if (!InitSensorList()) { - HiLog::Error(LABEL, "%{public}s Init sensor list error", __func__); + SEN_HILOGE("Init sensor list error"); return; } sensorDataProcesser_ = new (std::nothrow) SensorDataProcesser(sensorMap_); if (sensorDataProcesser_ == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, sensorDataProcesser_ cannot be null", __func__); + SEN_HILOGE("failed, sensorDataProcesser_ cannot be null"); return; } if (!InitSensorPolicy()) { - HiLog::Error(LABEL, "%{public}s Init sensor policy error", __func__); + SEN_HILOGE("Init sensor policy error"); } if (!SystemAbility::Publish(this)) { - HiLog::Error(LABEL, "%{public}s publish SensorService error", __func__); + SEN_HILOGE("publish SensorService error"); return; } sensorManager_.InitSensorMap(sensorMap_, sensorDataProcesser_, reportDataCallback_); @@ -98,7 +98,7 @@ bool SensorService::InitInterface() { auto ret = sensorHdiConnection_.ConnectHdi(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s connect hdi failed", __func__); + SEN_HILOGE("connect hdi failed"); return false; } return true; @@ -108,13 +108,13 @@ bool SensorService::InitDataCallback() { reportDataCallback_ = new (std::nothrow) ReportDataCallback(); if (reportDataCallback_ == nullptr) { - HiLog::Error(LABEL, "%{public}s failed, reportDataCallback_ cannot be null", __func__); + SEN_HILOGE("failed, reportDataCallback_ cannot be null"); return false; } ZReportDataCb cb = &ReportDataCallback::ReportEventCallback; auto ret = sensorHdiConnection_.RegisteDataReport(cb, reportDataCallback_); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s RegisterDataReport failed", __func__); + SEN_HILOGE("RegisterDataReport failed"); return false; } return true; @@ -125,14 +125,14 @@ bool SensorService::InitSensorList() std::lock_guard sensorLock(sensorsMutex_); int32_t ret = sensorHdiConnection_.GetSensorList(sensors_); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s GetSensorList failed", __func__); + SEN_HILOGE("GetSensorList failed"); return false; } { std::lock_guard sensorMapLock(sensorMapMutex_); for (const auto &it : sensors_) { if (!(sensorMap_.insert(std::make_pair(it.GetSensorId(), it)).second)) { - HiLog::Warn(LABEL, "%{public}s sensorMap_ Insert failed", __func__); + SEN_HILOGW("sensorMap_ Insert failed"); } } } @@ -148,13 +148,13 @@ void SensorService::OnStop() { CALL_LOG_ENTER; if (state_ == SensorServiceState::STATE_STOPPED) { - HiLog::Warn(LABEL, "%{public}s already stopped", __func__); + SEN_HILOGW("already stopped"); return; } state_ = SensorServiceState::STATE_STOPPED; int32_t ret = sensorHdiConnection_.DestroyHdiConnection(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s destroy hdi connect fail", __func__); + SEN_HILOGE("destroy hdi connect fail"); } } @@ -166,7 +166,7 @@ void SensorService::ReportSensorSysEvent(uint32_t sensorId, bool enable) sensorManager_.GetPackageNameFromUid(uid, packageName); int32_t ret = sprintf_s(uidChar, sizeof(uidChar) - 1, "%d", uid); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s sprintf uidChar failed", __func__); + SEN_HILOGE("sprintf uidChar failed"); return; } @@ -186,7 +186,7 @@ void SensorService::ReportSensorSysEvent(uint32_t sensorId, bool enable) "LEVEL", logLevel, "TAG", "DUBAI_TAG_HSENSOR_DISABLE", "MESSAGE", message); } - HiLog::Info(LABEL, "%{public}s end, packageName : %{public}s", __func__, packageName.c_str()); + SEN_HILOGI("end, packageName : %{public}s", packageName.c_str()); } void SensorService::ReportOnChangeData(uint32_t sensorId) @@ -194,27 +194,27 @@ void SensorService::ReportOnChangeData(uint32_t sensorId) std::lock_guard sensorMapLock(sensorMapMutex_); auto it = sensorMap_.find(sensorId); if (it == sensorMap_.end()) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return; } if ((SENSOR_ON_CHANGE & it->second.GetFlags()) != SENSOR_ON_CHANGE) { - HiLog::Warn(LABEL, "%{public}s it is not onchange data, no need to report", __func__); + SEN_HILOGW("it is not onchange data, no need to report"); return; } struct SensorEvent event; auto ret = clientInfo_.GetStoreEvent(sensorId, event); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s there is no data to be reported", __func__); + SEN_HILOGE("there is no data to be reported"); return; } sptr channel = clientInfo_.GetSensorChannelByPid(this->GetCallingPid()); if (channel == nullptr) { - HiLog::Error(LABEL, "%{public}s there is no channel to be reported", __func__); + SEN_HILOGE("there is no channel to be reported"); return; } auto sendRet = channel->SendData(&event, sizeof(event)); if (sendRet != ERR_OK) { - HiLog::Error(LABEL, "%{public}s send data failed", __func__); + SEN_HILOGE("send data failed"); return; } } @@ -223,13 +223,13 @@ ErrCode SensorService::SaveSubscriber(uint32_t sensorId, int64_t samplingPeriodN { auto ret = sensorManager_.SaveSubscriber(sensorId, this->GetCallingPid(), samplingPeriodNs, maxReportDelayNs); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SaveSubscriber failed", __func__); + SEN_HILOGE("SaveSubscriber failed"); return ret; } sensorManager_.StartDataReportThread(); if (!sensorManager_.SetBestSensorParams(sensorId, samplingPeriodNs, maxReportDelayNs)) { - HiLog::Error(LABEL, "%{public}s SetBestSensorParams failed", __func__); + SEN_HILOGE("SetBestSensorParams failed"); clientInfo_.RemoveSubscriber(sensorId, this->GetCallingPid()); return ENABLE_SENSOR_ERR; } @@ -241,37 +241,37 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || ((samplingPeriodNs != 0L) && ((maxReportDelayNs / samplingPeriodNs) > MAX_EVENT_COUNT))) { - HiLog::Error(LABEL, "%{public}s sensorId is 0 or maxReportDelayNs exceeded the maximum value", __func__); + SEN_HILOGE("sensorId is 0 or maxReportDelayNs exceeded the maximum value"); return ERR_NO_INIT; } ReportSensorSysEvent(sensorId, true); std::lock_guard serviceLock(serviceLock_); if (clientInfo_.GetSensorState(sensorId)) { - HiLog::Warn(LABEL, "%{public}s sensor has been enabled already", __func__); + SEN_HILOGW("sensor has been enabled already"); auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SaveSubscriber failed", __func__); + SEN_HILOGE("SaveSubscriber failed"); return ret; } uint32_t flag = sensorManager_.GetSensorFlag(sensorId); int32_t pid = this->GetCallingPid(); ret = flushInfo_.FlushProcess(sensorId, flag, pid, true); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s ret : %{public}d", __func__, ret); + SEN_HILOGE("ret : %{public}d", ret); } ReportOnChangeData(sensorId); return ERR_OK; } auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SaveSubscriber failed", __func__); + SEN_HILOGE("SaveSubscriber failed"); clientInfo_.RemoveSubscriber(sensorId, this->GetCallingPid()); return ret; } ret = sensorHdiConnection_.EnableSensor(sensorId); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s EnableSensor failed", __func__); + SEN_HILOGE("EnableSensor failed"); clientInfo_.RemoveSubscriber(sensorId, this->GetCallingPid()); return ENABLE_SENSOR_ERR; } @@ -283,26 +283,26 @@ ErrCode SensorService::DisableSensor(uint32_t sensorId) { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return ERR_NO_INIT; } ReportSensorSysEvent(sensorId, false); std::lock_guard serviceLock(serviceLock_); const int32_t clientPid = this->GetCallingPid(); if (clientPid < 0) { - HiLog::Error(LABEL, "%{public}s clientPid is invalid, clientPid : %{public}d", __func__, clientPid); + SEN_HILOGE("clientPid is invalid, clientPid : %{public}d"); return CLIENT_PID_INVALID_ERR; } if (!clientInfo_.GetSensorState(sensorId)) { - HiLog::Error(LABEL, "%{public}s sensor should be enabled first", __func__); + SEN_HILOGE("sensor should be enabled first"); return DISABLE_SENSOR_ERR; } if (sensorManager_.IsOtherClientUsingSensor(sensorId, clientPid)) { - HiLog::Warn(LABEL, "%{public}s other client is using this sensor now, cannot disable", __func__); + SEN_HILOGW("other client is using this sensor now, cannot disable"); return ERR_OK; } if (sensorHdiConnection_.DisableSensor(sensorId) != ERR_OK) { - HiLog::Error(LABEL, "%{public}s DisableSensor failed", __func__); + SEN_HILOGE("DisableSensor failed"); return DISABLE_SENSOR_ERR; } clientInfo_.DestroyCmd(this->GetCallingUid()); @@ -313,7 +313,7 @@ ErrCode SensorService::DisableSensor(uint32_t sensorId) int32_t SensorService::GetSensorState(uint32_t sensorId) { if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is 0", __func__); + SEN_HILOGE("sensorId is 0"); return ERR_NO_INIT; } auto state = clientInfo_.GetSensorState(sensorId); @@ -324,22 +324,22 @@ ErrCode SensorService::RunCommand(uint32_t sensorId, uint32_t cmdType, uint32_t { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID || ((cmdType != FLUSH) && (cmdType != SET_MODE))) { - HiLog::Error(LABEL, "%{public}s sensorId or cmd is invalid", __func__); + SEN_HILOGE("sensorId or cmd is invalid"); return ERR_NO_INIT; } std::lock_guard serviceLock(serviceLock_); uint32_t flag = sensorManager_.GetSensorFlag(sensorId); if (cmdType == FLUSH) { int32_t pid = this->GetCallingPid(); - HiLog::Info(LABEL, "%{public}s sensorId : %{public}u, flag : %{public}u", __func__, sensorId, flag); + SEN_HILOGI("sensorId : %{public}u, flag : %{public}u", sensorId, flag); auto retFlush = flushInfo_.FlushProcess(sensorId, flag, pid, false); if (retFlush != ERR_OK) { - HiLog::Error(LABEL, "%{public}s ret : %{public}d", __func__, retFlush); + SEN_HILOGE("ret : %{public}d", retFlush); } return retFlush; } if (sensorHdiConnection_.RunCommand(sensorId, cmdType, params) != ERR_OK) { - HiLog::Error(LABEL, "%{public}s RunCommand failed", __func__); + SEN_HILOGE("RunCommand failed"); return RUN_COMMAND_ERR; } auto uid = this->GetCallingUid(); @@ -352,7 +352,7 @@ std::vector SensorService::GetSensorList() std::lock_guard sensorLock(sensorsMutex_); int32_t ret = sensorHdiConnection_.GetSensorList(sensors_); if (ret < 0) { - HiLog::Error(LABEL, "%{public}s GetSensorList failed", __func__); + SEN_HILOGE("GetSensorList failed"); return sensors_; } for (const auto &it : sensors_) { @@ -366,18 +366,18 @@ ErrCode SensorService::TransferDataChannel(const sptr &s const sptr &sensorClient) { if ((sensorBasicDataChannel == nullptr)) { - HiLog::Error(LABEL, "%{public}s sensorBasicDataChannel cannot be null", __func__); + SEN_HILOGE("sensorBasicDataChannel cannot be null"); return ERR_NO_INIT; } auto pid = this->GetCallingPid(); auto uid = this->GetCallingUid(); auto callerToken = this->GetCallingTokenID(); if (!clientInfo_.UpdateAppThreadInfo(pid, uid, callerToken)) { - HiLog::Error(LABEL, "%{public}s UpdateUid failed", __func__); + SEN_HILOGE("UpdateUid failed"); return UPDATE_UID_ERR; } if (!clientInfo_.UpdateSensorChannel(pid, sensorBasicDataChannel)) { - HiLog::Error(LABEL, "%{public}s UpdateSensorChannel failed", __func__); + SEN_HILOGE("UpdateSensorChannel failed"); return UPDATE_SENSOR_CHANNEL_ERR; } sensorBasicDataChannel->SetSensorStatus(true); @@ -390,13 +390,14 @@ ErrCode SensorService::DestroySensorChannel(sptr sensorClient) CALL_LOG_ENTER; const int32_t clientPid = this->GetCallingPid(); if (clientPid < 0) { - HiLog::Error(LABEL, "%{public}s clientPid is invalid, clientPid : %{public}d", __func__, clientPid); + SEN_HILOGE("clientPid is invalid, clientPid : %{public}d", clientPid); + return CLIENT_PID_INVALID_ERR; } std::lock_guard serviceLock(serviceLock_); bool destoryRet = clientInfo_.DestroySensorChannel(clientPid); if (!destoryRet) { - HiLog::Error(LABEL, "%{public}s DestroySensorChannel failed", __func__); + SEN_HILOGE("DestroySensorChannel failed"); return DESTROY_SENSOR_CHANNEL_ERR; } clientInfo_.DestroyCmd(this->GetCallingUid()); @@ -409,15 +410,15 @@ void SensorService::ProcessDeathObserver(const wptr &object) CALL_LOG_ENTER; sptr client = object.promote(); if (client == nullptr) { - HiLog::Error(LABEL, "%{public}s client cannot be null", __func__); + SEN_HILOGE("client cannot be null"); return; } int32_t pid = clientInfo_.FindClientPid(client); if (pid == INVALID_PID) { - HiLog::Error(LABEL, "%{public}s pid is -1", __func__); + SEN_HILOGE("pid is -1"); return; } - HiLog::Info(LABEL, "%{public}s pid is %d", __func__, pid); + SEN_HILOGI("pid is %d", pid); clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); clientInfo_.DestroyCmd(this->GetCallingUid()); @@ -429,7 +430,7 @@ void SensorService::RegisterClientDeathRecipient(sptr sensorClien sptr client = iface_cast(sensorClient); clientDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); if (clientDeathObserver_ == nullptr) { - HiLog::Error(LABEL, "%{public}s clientDeathObserver_ cannot be null", __func__); + SEN_HILOGE("clientDeathObserver_ cannot be null"); return; } client->AsObject()->AddDeathRecipient(clientDeathObserver_); @@ -442,7 +443,7 @@ void SensorService::UnregisterClientDeathRecipient(sptr sensorCli sptr client = iface_cast(sensorClient); clientDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); if (clientDeathObserver_ == nullptr) { - HiLog::Error(LABEL, "%{public}s clientDeathObserver_ cannot be null", __func__); + SEN_HILOGE("clientDeathObserver_ cannot be null"); return; } client->AsObject()->RemoveDeathRecipient(clientDeathObserver_); @@ -454,7 +455,7 @@ int32_t SensorService::Dump(int32_t fd, const std::vector &args) CALL_LOG_ENTER; SensorDump &sensorDump = SensorDump::GetInstance(); if ((args.empty()) || (args[0].size() != MAX_DMUP_PARAM)) { - HiLog::Error(LABEL, "%{public}s param cannot be empty or the length is not 2", __func__); + SEN_HILOGE("param cannot be empty or the length is not 2"); dprintf(fd, "cmd param number is not equal to 2\n"); sensorDump.DumpHelp(fd); return DUMP_PARAM_ERR; diff --git a/services/sensor/src/sensor_service_stub.cpp b/services/sensor/src/sensor_service_stub.cpp index 067ab007..a1265430 100644 --- a/services/sensor/src/sensor_service_stub.cpp +++ b/services/sensor/src/sensor_service_stub.cpp @@ -37,7 +37,7 @@ constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "Sens SensorServiceStub::SensorServiceStub() { - HiLog::Info(LABEL, "%{public}s begin, %{public}p", __func__, this); + SEN_HILOGI("begin, %{public}p", this); baseFuncs_[ENABLE_SENSOR] = &SensorServiceStub::SensorEnableInner; baseFuncs_[DISABLE_SENSOR] = &SensorServiceStub::SensorDisableInner; baseFuncs_[GET_SENSOR_STATE] = &SensorServiceStub::GetSensorStateInner; @@ -49,18 +49,18 @@ SensorServiceStub::SensorServiceStub() SensorServiceStub::~SensorServiceStub() { - HiLog::Info(LABEL, "%{public}s begin, yigou %{public}p", __func__, this); + SEN_HILOGI("begin, yigou %{public}p", this); baseFuncs_.clear(); } int32_t SensorServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - HiLog::Debug(LABEL, "%{public}s begin, cmd : %{public}u", __func__, code); + SEN_HILOGD("begin, cmd : %{public}u", code); std::u16string descriptor = SensorServiceStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { - HiLog::Error(LABEL, "%{public}s client and service descriptors are inconsistent", __func__); + SEN_HILOGE("client and service descriptors are inconsistent"); return OBJECT_NULL; } auto itFunc = baseFuncs_.find(code); @@ -70,7 +70,7 @@ int32_t SensorServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M return (this->*memberFunc)(data, reply); } } - HiLog::Debug(LABEL, "%{public}s no member func supporting, applying default process", __func__); + SEN_HILOGD("no member func supporting, applying default process"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -80,7 +80,7 @@ ErrCode SensorServiceStub::SensorEnableInner(MessageParcel &data, MessageParcel uint32_t sensorId = data.ReadUint32(); PermissionUtil &permissionUtil = PermissionUtil::GetInstance(); if (!permissionUtil.CheckSensorPermission(this->GetCallingTokenID(), sensorId)) { - HiLog::Error(LABEL, "%{public}s permission denied", __func__); + SEN_HILOGE("permission denied"); return ERR_PERMISSION_DENIED; } return EnableSensor(sensorId, data.ReadInt64(), data.ReadInt64()); @@ -92,7 +92,7 @@ ErrCode SensorServiceStub::SensorDisableInner(MessageParcel &data, MessageParcel uint32_t sensorId = data.ReadUint32(); PermissionUtil &permissionUtil = PermissionUtil::GetInstance(); if (!permissionUtil.CheckSensorPermission(this->GetCallingTokenID(), sensorId)) { - HiLog::Error(LABEL, "%{public}s permission denied", __func__); + SEN_HILOGE("permission denied"); return ERR_PERMISSION_DENIED; } return DisableSensor(sensorId); @@ -104,7 +104,7 @@ ErrCode SensorServiceStub::GetSensorStateInner(MessageParcel &data, MessageParce uint32_t sensorId = data.ReadUint32(); PermissionUtil &permissionUtil = PermissionUtil::GetInstance(); if (!permissionUtil.CheckSensorPermission(this->GetCallingTokenID(), sensorId)) { - HiLog::Error(LABEL, "%{public}s permission denied", __func__); + SEN_HILOGE("permission denied"); return ERR_PERMISSION_DENIED; } return GetSensorState(sensorId); @@ -116,7 +116,7 @@ ErrCode SensorServiceStub::RunCommandInner(MessageParcel &data, MessageParcel &r uint32_t sensorId = data.ReadUint32(); PermissionUtil &permissionUtil = PermissionUtil::GetInstance(); if (!permissionUtil.CheckSensorPermission(this->GetCallingTokenID(), sensorId)) { - HiLog::Error(LABEL, "%{public}s permission denied", __func__); + SEN_HILOGE("permission denied"); return ERR_PERMISSION_DENIED; } return RunCommand(sensorId, data.ReadUint32(), data.ReadUint32()); @@ -131,7 +131,7 @@ ErrCode SensorServiceStub::GetAllSensorsInner(MessageParcel &data, MessageParcel for (int32_t i = 0; i < sensorCount; i++) { bool flag = sensors[i].Marshalling(reply); if (!flag) { - HiLog::Error(LABEL, "Marshalling sensor %{public}d failed", i); + SEN_HILOGE("sensor %{public}d failed", i); return GET_SENSOR_LIST_ERR; } } @@ -143,17 +143,17 @@ ErrCode SensorServiceStub::CreateDataChannelInner(MessageParcel &data, MessagePa (void)reply; sptr sensorChannel = new (std::nothrow) SensorBasicDataChannel(); if (sensorChannel == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorChannel cannot be null", __func__); + SEN_HILOGE("sensorChannel cannot be null"); return OBJECT_NULL; } auto ret = sensorChannel->CreateSensorBasicChannel(data); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s CreateSensorBasicChannel ret : %{public}d", __func__, ret); + SEN_HILOGE("CreateSensorBasicChannel ret : %{public}d", ret); return OBJECT_NULL; } sptr sensorClient = data.ReadRemoteObject(); if (sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); + SEN_HILOGE("sensorClient cannot be null"); return OBJECT_NULL; } return TransferDataChannel(sensorChannel, sensorClient); @@ -163,7 +163,7 @@ ErrCode SensorServiceStub::DestroyDataChannelInner(MessageParcel &data, MessageP { sptr sensorClient = data.ReadRemoteObject(); if (sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); + SEN_HILOGE("sensorClient cannot be null"); return OBJECT_NULL; } return DestroySensorChannel(sensorClient); diff --git a/services/sensor/src/sensor_suspend_policy.cpp b/services/sensor/src/sensor_suspend_policy.cpp index a1c8dec1..8b32a2a5 100755 --- a/services/sensor/src/sensor_suspend_policy.cpp +++ b/services/sensor/src/sensor_suspend_policy.cpp @@ -46,15 +46,15 @@ ErrCode SensorSuspendPolicy::DisableSensor(uint32_t sensorId, int32_t pid) { CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return ERR_NO_INIT; } if (sensorManager_.IsOtherClientUsingSensor(sensorId, pid)) { - HiLog::Warn(LABEL, "%{public}s other client is using this sensor now, cannot disable", __func__); + SEN_HILOGW("other client is using this sensor now, cannot disable"); return ERR_OK; } if (interface_.DisableSensor(sensorId) != ERR_OK) { - HiLog::Error(LABEL, "%{public}s DisableSensor failed", __func__); + SEN_HILOGE("DisableSensor failed"); return DISABLE_SENSOR_ERR; } return sensorManager_.AfterDisableSensor(sensorId); @@ -87,12 +87,12 @@ ErrCode SensorSuspendPolicy::SaveSubscriber(uint32_t sensorId, int64_t samplingP { auto ret = sensorManager_.SaveSubscriber(sensorId, pid, samplingPeriodNs, maxReportDelayNs); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SaveSubscriber failed", __func__); + SEN_HILOGE("SaveSubscriber failed"); return ret; } sensorManager_.StartDataReportThread(); if (!sensorManager_.SetBestSensorParams(sensorId, samplingPeriodNs, maxReportDelayNs)) { - HiLog::Error(LABEL, "%{public}s SetBestSensorParams failed", __func__); + SEN_HILOGE("SetBestSensorParams failed"); clientInfo_.RemoveSubscriber(sensorId, pid); return ENABLE_SENSOR_ERR; } @@ -105,31 +105,31 @@ ErrCode SensorSuspendPolicy::EnableSensor(uint32_t sensorId, int32_t pid, int64_ CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || (samplingPeriodNs == 0) || ((samplingPeriodNs != 0L) && (maxReportDelayNs / samplingPeriodNs > MAX_EVENT_COUNT))) { - HiLog::Error(LABEL, "%{public}s sensorId is 0 or maxReportDelayNs exceed the maximum value", __func__); + SEN_HILOGE("sensorId is 0 or maxReportDelayNs exceed the maximum value"); return ERR_NO_INIT; } if (clientInfo_.GetSensorState(sensorId) == SENSOR_ENABLED) { - HiLog::Warn(LABEL, "%{public}s sensor has been enabled already", __func__); + SEN_HILOGW("sensor has been enabled already"); auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs, pid); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SaveSubscriber failed", __func__); + SEN_HILOGE("SaveSubscriber failed"); return ret; } uint32_t flag = sensorManager_.GetSensorFlag(sensorId); ret = flushInfo_.FlushProcess(sensorId, flag, pid, true); if (ret != ERR_OK) { - HiLog::Warn(LABEL, "%{public}s ret : %{public}d", __func__, ret); + SEN_HILOGW("ret : %{public}d", ret); } return ERR_OK; } auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs, pid); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s SaveSubscriber failed", __func__); + SEN_HILOGE("SaveSubscriber failed"); return ret; } ret = interface_.EnableSensor(sensorId); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s EnableSensor failed", __func__); + SEN_HILOGE("EnableSensor failed"); clientInfo_.RemoveSubscriber(sensorId, pid); return ENABLE_SENSOR_ERR; } @@ -138,13 +138,13 @@ ErrCode SensorSuspendPolicy::EnableSensor(uint32_t sensorId, int32_t pid, int64_ std::vector SensorSuspendPolicy::GetSensorIdByPid(int32_t pid) { - HiLog::Debug(LABEL, "%{public}s pid : %{public}d", __func__, pid); + SEN_HILOGD("pid : %{public}d", pid); auto it = pidSensorIdMap_.find(pid); if (it != pidSensorIdMap_.end()) { - HiLog::Debug(LABEL, "%{public}s pid : %{public}d found", __func__, pid); + SEN_HILOGD("pid : %{public}d found", pid); return it->second; } - HiLog::Debug(LABEL, "%{public}s pid : %{public}d not found", __func__, pid); + SEN_HILOGD("pid : %{public}d not found", pid); return {}; } @@ -169,8 +169,7 @@ void SensorSuspendPolicy::DoActive(const std::shared_ptr Date: Thu, 31 Mar 2022 11:46:22 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=95=B4=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- services/sensor/hdi_connection/adapter/src/hdi_connection.cpp | 2 +- .../sensor/hdi_connection/adapter/src/sensor_event_callback.cpp | 2 +- services/sensor/src/sensor_data_processer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp index 72f17d79..025d4fc6 100644 --- a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp @@ -59,7 +59,7 @@ int32_t HdiConnection::ConnectHdi() return ERR_OK; } retry++; - SEN_HILOGE("connect hdi service failed, retry : %{public}d", retry); + SEN_HILOGW("connect hdi service failed, retry : %{public}d", retry); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); } SEN_HILOGE("get sensor list failed"); diff --git a/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp b/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp index 02bd1bd0..719c7973 100644 --- a/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp +++ b/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp @@ -30,7 +30,7 @@ int32_t SensorEventCallback::OnDataEvent(const HdfSensorEvents& event) ZReportDataCb reportDataCb_ = HdiConnection_->getReportDataCb(); sptr reportDataCallback_ = HdiConnection_->getReportDataCallback(); if (reportDataCb_ == nullptr || reportDataCallback_ == nullptr) { - SEN_HILOGI("reportDataCb_ or reportDataCallback_ cannot be null"); + SEN_HILOGE("reportDataCb_ or reportDataCallback_ cannot be null"); return ERR_NO_INIT; } int32_t dataSize = static_cast(event.data.size()); diff --git a/services/sensor/src/sensor_data_processer.cpp b/services/sensor/src/sensor_data_processer.cpp index 4fa5254f..99836e91 100644 --- a/services/sensor/src/sensor_data_processer.cpp +++ b/services/sensor/src/sensor_data_processer.cpp @@ -340,7 +340,7 @@ void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) int32_t index = flushInfo_.GetFlushChannelIndex(flushVec, channel); if (index >= 0) { if (flushVec[index].flushFromEnable) { - SEN_HILOGE("flushFromEnable"); + SEN_HILOGI("flushFromEnable"); continue; } } -- Gitee From 3f9d01e8b96d29fc3df06d4eca5ffbb7ace8a0e9 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 31 Mar 2022 12:18:38 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=94=B9=E4=B8=BACALL=5FLOG=5FENTER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../hdi_connection/adapter/src/hdi_connection.cpp | 4 ++-- .../hdi_connection/hardware/src/hdi_service_impl.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp index 025d4fc6..bbed4724 100644 --- a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp @@ -62,7 +62,7 @@ int32_t HdiConnection::ConnectHdi() SEN_HILOGW("connect hdi service failed, retry : %{public}d", retry); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); } - SEN_HILOGE("get sensor list failed"); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } @@ -70,7 +70,7 @@ int32_t HdiConnection::GetSensorList(std::vector& sensorList) { CALL_LOG_ENTER; if (sensorInterface_ == nullptr) { - SEN_HILOGE("get sensor list failed"); + SEN_HILOGE("connect v1_0 hdi failed"); return ERR_NO_INIT; } std::vector sensorInfos; diff --git a/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp b/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp index 14d5fd02..7a2bb7eb 100644 --- a/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp +++ b/services/sensor/hdi_connection/hardware/src/hdi_service_impl.cpp @@ -44,14 +44,14 @@ std::atomic_bool HdiServiceImpl::g_isStop = false; int32_t HdiServiceImpl::GetSensorList(std::vector& sensorList) { - SEN_HILOGI("in"); + CALL_LOG_ENTER; sensorList.assign(g_sensorInfos.begin(), g_sensorInfos.end()); return ERR_OK; } void HdiServiceImpl::DataReportThread() { - SEN_HILOGI("in"); + CALL_LOG_ENTER; while (true) { usleep(g_samplingInterval / CONVERT_MULTIPLES); g_callback(&testEvent); @@ -65,7 +65,7 @@ void HdiServiceImpl::DataReportThread() int32_t HdiServiceImpl::EnableSensor(uint32_t sensorId) { - SEN_HILOGI("in"); + CALL_LOG_ENTER; if (g_callback == nullptr) { SEN_HILOGE("enable sensor failed"); return -1; @@ -92,7 +92,7 @@ int32_t HdiServiceImpl::EnableSensor(uint32_t sensorId) int32_t HdiServiceImpl::DisableSensor(uint32_t sensorId) { - SEN_HILOGI("in"); + CALL_LOG_ENTER; if (std::find(supportSensors.begin(), supportSensors.end(), sensorId) == supportSensors.end()) { SEN_HILOGE("not support disable sensorId: %{public}d", sensorId); return ERR_NO_INIT; @@ -116,7 +116,7 @@ int32_t HdiServiceImpl::DisableSensor(uint32_t sensorId) int32_t HdiServiceImpl::SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) { - SEN_HILOGI("in); + CALL_LOG_ENTER; if (samplingInterval < 0 || reportInterval < 0) { samplingInterval = SAMPLING_INTERVAL_NS; reportInterval = 0; -- Gitee From 72358a9bce7984bfacf536fe306c35808737f482 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 31 Mar 2022 17:48:24 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=95=B4=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- services/sensor/src/flush_info_record.cpp | 2 +- services/sensor/src/sensor_data_processer.cpp | 2 +- services/sensor/src/sensor_service.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/sensor/src/flush_info_record.cpp b/services/sensor/src/flush_info_record.cpp index 2f8bf68e..693dd726 100644 --- a/services/sensor/src/flush_info_record.cpp +++ b/services/sensor/src/flush_info_record.cpp @@ -75,7 +75,7 @@ bool FlushInfoRecord::IsFlushChannelValid(const std::vector(currChannelList.size())); for (const auto &channel : currChannelList) { SEN_HILOGD("channel : %{public}p, flushchannel : %{public}p", channel.GetRefPtr(), - flushChannel.GetRefPtr()); + flushChannel.GetRefPtr()); if (channel == flushChannel) { return true; } diff --git a/services/sensor/src/sensor_data_processer.cpp b/services/sensor/src/sensor_data_processer.cpp index 99836e91..0a543ffc 100644 --- a/services/sensor/src/sensor_data_processer.cpp +++ b/services/sensor/src/sensor_data_processer.cpp @@ -174,7 +174,7 @@ void SensorDataProcesser::SendFifoCacheData(std::unordered_map &channel, struct SensorEvent &event) { if (channel == nullptr) { - SEN_HILOGE("channel cannot be null", code); + SEN_HILOGE("channel cannot be null"); return; } uint32_t sensorId = static_cast(event.sensorTypeId); diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 602705b3..7fa89902 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -290,7 +290,7 @@ ErrCode SensorService::DisableSensor(uint32_t sensorId) std::lock_guard serviceLock(serviceLock_); const int32_t clientPid = this->GetCallingPid(); if (clientPid < 0) { - SEN_HILOGE("clientPid is invalid, clientPid : %{public}d"); + SEN_HILOGE("clientPid is invalid, clientPid : %{public}d", clientPid); return CLIENT_PID_INVALID_ERR; } if (!clientInfo_.GetSensorState(sensorId)) { -- Gitee From 4eda3ca165eb4c15f9ca7dd6879bfff58a9065c9 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Thu, 31 Mar 2022 18:23:18 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=95=B4=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- services/sensor/src/flush_info_record.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/sensor/src/flush_info_record.cpp b/services/sensor/src/flush_info_record.cpp index 693dd726..f76987ff 100644 --- a/services/sensor/src/flush_info_record.cpp +++ b/services/sensor/src/flush_info_record.cpp @@ -74,8 +74,7 @@ bool FlushInfoRecord::IsFlushChannelValid(const std::vector(currChannelList.size())); for (const auto &channel : currChannelList) { - SEN_HILOGD("channel : %{public}p, flushchannel : %{public}p", channel.GetRefPtr(), - flushChannel.GetRefPtr()); + SEN_HILOGD("channel : %{public}p, flushchannel : %{public}p", channel.GetRefPtr(), flushChannel.GetRefPtr()); if (channel == flushChannel) { return true; } -- Gitee From 5982737f1caa2ebd57d749a8d2984355e44fdc81 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Fri, 1 Apr 2022 09:12:34 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../adapter/src/compatible_connection.cpp | 4 ++-- .../hdi_connection/adapter/src/hdi_connection.cpp | 12 ++++++------ services/sensor/src/client_info.cpp | 4 ++-- services/sensor/src/sensor_manager.cpp | 10 +++++----- services/sensor/src/sensor_service.cpp | 14 +++++++------- services/sensor/src/sensor_suspend_policy.cpp | 12 ++++++------ 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp index 3fbbfb82..a0a9aa4b 100644 --- a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp @@ -161,7 +161,7 @@ int32_t CompatibleConnection::RegisteDataReport(ZReportDataCb cb, sptrDisable(sensorId); if (ret < 0) { - SEN_HILOGE("is failed"); + SEN_HILOGE("Disable is failed"); return ret; } deleteSensorBasicInfoState(sensorId); @@ -133,7 +133,7 @@ int32_t HdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int6 } int32_t ret = sensorInterface_->SetBatch(sensorId, samplingInterval, reportInterval); if (ret < 0) { - SEN_HILOGE("failed"); + SEN_HILOGE("SetBatch is failed"); return ret; } updateSensorBasicInfo(sensorId, samplingInterval, reportInterval); @@ -149,7 +149,7 @@ int32_t HdiConnection::SetMode(int32_t sensorId, int32_t mode) } int32_t ret = sensorInterface_->SetMode(sensorId, mode); if (ret < 0) { - SEN_HILOGE("is failed"); + SEN_HILOGE("SetMode is failed"); return ret; } return ERR_OK; @@ -164,7 +164,7 @@ int32_t HdiConnection::SetOption(int32_t sensorId, int32_t option) } int32_t ret = sensorInterface_->SetOption(sensorId, option); if (ret < 0) { - SEN_HILOGE("is failed"); + SEN_HILOGE("SetOption is failed"); return ret; } return ERR_OK; @@ -179,7 +179,7 @@ int32_t HdiConnection::RegisteDataReport(ZReportDataCb cb, sptrRegister(0, eventCallback_); if (ret < 0) { - SEN_HILOGE("failed"); + SEN_HILOGE("Register is failed"); return ret; } reportDataCb_ = cb; @@ -196,7 +196,7 @@ int32_t HdiConnection::DestroyHdiConnection() } int32_t ret = sensorInterface_->Unregister(0, eventCallback_); if (ret < 0) { - SEN_HILOGE("failed"); + SEN_HILOGE("Unregister is failed"); return ret; } eventCallback_ = nullptr; diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index 27db98b4..3576e3c6 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -463,12 +463,12 @@ void ClientInfo::StoreEvent(const struct SensorEvent &event) std::vector sensors; int32_t ret = sensorHdiConnection->GetSensorList(sensors); if (ret < 0) { - SEN_HILOGE("GetSensorList failed"); + SEN_HILOGE("GetSensorList is failed"); return; } errno_t retVal = memcpy_s(&storedEvent, sizeof(storedEvent), &event, sizeof(event)); if (retVal != EOK) { - SEN_HILOGE("memcpy_s failed"); + SEN_HILOGE("memcpy_s is failed"); return; } for (size_t i = 0; i < sensors.size(); i++) { diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index c6a167b6..777834a0 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -70,7 +70,7 @@ bool SensorManager::SetBestSensorParams(uint32_t sensorId, int64_t samplingPerio SEN_HILOGD("bestSamplingPeriodNs : %{public}d", int32_t { bestSamplingPeriodNs }); auto ret = sensorHdiConnection_.SetBatch(sensorId, bestSamplingPeriodNs, bestReportDelayNs); if (ret != ERR_OK) { - SEN_HILOGE("SetBatch failed"); + SEN_HILOGE("SetBatch is failed"); return false; } return true; @@ -87,7 +87,7 @@ bool SensorManager::ResetBestSensorParams(uint32_t sensorId) auto ret = sensorHdiConnection_.SetBatch(sensorId, sensorInfo.GetSamplingPeriodNs(), sensorInfo.GetMaxReportDelayNs()); if (ret != ERR_OK) { - SEN_HILOGE("SetBatch failed"); + SEN_HILOGE("SetBatch is failed"); return false; } return true; @@ -103,7 +103,7 @@ SensorBasicInfo SensorManager::GetSensorInfo(uint32_t sensorId, int64_t sampling sensorInfo.SetSamplingPeriodNs(samplingPeriodNs); sensorInfo.SetMaxReportDelayNs(maxReportDelayNs); sensorInfo.SetSensorState(true); - SEN_HILOGE("sensorId invalid"); + SEN_HILOGE("sensorId is invalid"); return sensorInfo; } int64_t curSamplingPeriodNs = @@ -131,7 +131,7 @@ ErrCode SensorManager::SaveSubscriber(uint32_t sensorId, uint32_t pid, int64_t s SensorBasicInfo sensorInfo = GetSensorInfo(sensorId, samplingPeriodNs, maxReportDelayNs); auto updateRet = clientInfo_.UpdateSensorInfo(sensorId, pid, sensorInfo); if (!updateRet) { - SEN_HILOGE("UpdateSensorInfo failed"); + SEN_HILOGE("UpdateSensorInfo is failed"); return UPDATE_SENSOR_INFO_ERR; } return ERR_OK; @@ -156,7 +156,7 @@ bool SensorManager::IsOtherClientUsingSensor(uint32_t sensorId, int32_t clientPi } clientInfo_.ClearCurPidSensorInfo(sensorId, clientPid); if (!ResetBestSensorParams(sensorId)) { - SEN_HILOGW("ResetBestSensorParams failed"); + SEN_HILOGW("ResetBestSensorParams is failed"); } SEN_HILOGD("other client is using this sensor"); return true; diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 7fa89902..333b008c 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -125,7 +125,7 @@ bool SensorService::InitSensorList() std::lock_guard sensorLock(sensorsMutex_); int32_t ret = sensorHdiConnection_.GetSensorList(sensors_); if (ret < 0) { - SEN_HILOGE("GetSensorList failed"); + SEN_HILOGE("GetSensorList is failed"); return false; } { @@ -302,7 +302,7 @@ ErrCode SensorService::DisableSensor(uint32_t sensorId) return ERR_OK; } if (sensorHdiConnection_.DisableSensor(sensorId) != ERR_OK) { - SEN_HILOGE("DisableSensor failed"); + SEN_HILOGE("DisableSensor is failed"); return DISABLE_SENSOR_ERR; } clientInfo_.DestroyCmd(this->GetCallingUid()); @@ -339,7 +339,7 @@ ErrCode SensorService::RunCommand(uint32_t sensorId, uint32_t cmdType, uint32_t return retFlush; } if (sensorHdiConnection_.RunCommand(sensorId, cmdType, params) != ERR_OK) { - SEN_HILOGE("RunCommand failed"); + SEN_HILOGE("RunCommand is failed"); return RUN_COMMAND_ERR; } auto uid = this->GetCallingUid(); @@ -352,7 +352,7 @@ std::vector SensorService::GetSensorList() std::lock_guard sensorLock(sensorsMutex_); int32_t ret = sensorHdiConnection_.GetSensorList(sensors_); if (ret < 0) { - SEN_HILOGE("GetSensorList failed"); + SEN_HILOGE("GetSensorList is failed"); return sensors_; } for (const auto &it : sensors_) { @@ -373,11 +373,11 @@ ErrCode SensorService::TransferDataChannel(const sptr &s auto uid = this->GetCallingUid(); auto callerToken = this->GetCallingTokenID(); if (!clientInfo_.UpdateAppThreadInfo(pid, uid, callerToken)) { - SEN_HILOGE("UpdateUid failed"); + SEN_HILOGE("UpdateUid is failed"); return UPDATE_UID_ERR; } if (!clientInfo_.UpdateSensorChannel(pid, sensorBasicDataChannel)) { - SEN_HILOGE("UpdateSensorChannel failed"); + SEN_HILOGE("UpdateSensorChannel is failed"); return UPDATE_SENSOR_CHANNEL_ERR; } sensorBasicDataChannel->SetSensorStatus(true); @@ -397,7 +397,7 @@ ErrCode SensorService::DestroySensorChannel(sptr sensorClient) std::lock_guard serviceLock(serviceLock_); bool destoryRet = clientInfo_.DestroySensorChannel(clientPid); if (!destoryRet) { - SEN_HILOGE("DestroySensorChannel failed"); + SEN_HILOGE("DestroySensorChannel is failed"); return DESTROY_SENSOR_CHANNEL_ERR; } clientInfo_.DestroyCmd(this->GetCallingUid()); diff --git a/services/sensor/src/sensor_suspend_policy.cpp b/services/sensor/src/sensor_suspend_policy.cpp index 8b32a2a5..4039b518 100755 --- a/services/sensor/src/sensor_suspend_policy.cpp +++ b/services/sensor/src/sensor_suspend_policy.cpp @@ -54,7 +54,7 @@ ErrCode SensorSuspendPolicy::DisableSensor(uint32_t sensorId, int32_t pid) return ERR_OK; } if (interface_.DisableSensor(sensorId) != ERR_OK) { - SEN_HILOGE("DisableSensor failed"); + SEN_HILOGE("DisableSensor is failed"); return DISABLE_SENSOR_ERR; } return sensorManager_.AfterDisableSensor(sensorId); @@ -87,12 +87,12 @@ ErrCode SensorSuspendPolicy::SaveSubscriber(uint32_t sensorId, int64_t samplingP { auto ret = sensorManager_.SaveSubscriber(sensorId, pid, samplingPeriodNs, maxReportDelayNs); if (ret != ERR_OK) { - SEN_HILOGE("SaveSubscriber failed"); + SEN_HILOGE("SaveSubscriber is failed"); return ret; } sensorManager_.StartDataReportThread(); if (!sensorManager_.SetBestSensorParams(sensorId, samplingPeriodNs, maxReportDelayNs)) { - SEN_HILOGE("SetBestSensorParams failed"); + SEN_HILOGE("SetBestSensorParams is failed"); clientInfo_.RemoveSubscriber(sensorId, pid); return ENABLE_SENSOR_ERR; } @@ -112,7 +112,7 @@ ErrCode SensorSuspendPolicy::EnableSensor(uint32_t sensorId, int32_t pid, int64_ SEN_HILOGW("sensor has been enabled already"); auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs, pid); if (ret != ERR_OK) { - SEN_HILOGE("SaveSubscriber failed"); + SEN_HILOGE("SaveSubscriber is failed"); return ret; } uint32_t flag = sensorManager_.GetSensorFlag(sensorId); @@ -124,12 +124,12 @@ ErrCode SensorSuspendPolicy::EnableSensor(uint32_t sensorId, int32_t pid, int64_ } auto ret = SaveSubscriber(sensorId, samplingPeriodNs, maxReportDelayNs, pid); if (ret != ERR_OK) { - SEN_HILOGE("SaveSubscriber failed"); + SEN_HILOGE("SaveSubscriber is failed"); return ret; } ret = interface_.EnableSensor(sensorId); if (ret != ERR_OK) { - SEN_HILOGE("EnableSensor failed"); + SEN_HILOGE("EnableSensor is failed"); clientInfo_.RemoveSubscriber(sensorId, pid); return ENABLE_SENSOR_ERR; } -- Gitee