diff --git a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp index 2b1db8cafe2f9d1e9ac24a327c968e461f70a267..06c444312a7e5853fa7199c062f7625424c9af2d 100644 --- a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp +++ b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp @@ -33,7 +33,7 @@ MyFileDescriptorListener::MyFileDescriptorListener() receiveDataBuff_ = new (std::nothrow) TransferSensorEvents[sizeof(struct TransferSensorEvents) * RECEIVE_DATA_SIZE]; if (receiveDataBuff_ == nullptr) { - HiLog::Error(LABEL, "%{public}s receiveDataBuff_ memory request failed", __func__); + SEN_HILOGE("receiveDataBuff_ memory request failed"); } } @@ -50,7 +50,7 @@ void MyFileDescriptorListener::OnReadable(int32_t fileDescriptor) { CALL_LOG_ENTER; if (fileDescriptor < 0) { - HiLog::Error(LABEL, "%{public}s fileDescriptor: %{public}d", __func__, fileDescriptor); + SEN_HILOGE("fileDescriptor: %{public}d", fileDescriptor); return; } @@ -89,8 +89,7 @@ void MyFileDescriptorListener::SetChannel(SensorDataChannel* channel) void MyFileDescriptorListener::OnShutdown(int32_t fileDescriptor) { if (fileDescriptor < 0) { - HiLog::Error(LABEL, "%{public}s param is error: %{public}d", __func__, fileDescriptor); - return; + SEN_HILOGE("param is error: %{public}d", fileDescriptor); } FileDescriptorListener::OnShutdown(fileDescriptor); @@ -103,7 +102,7 @@ void MyFileDescriptorListener::OnShutdown(int32_t fileDescriptor) void MyFileDescriptorListener::OnException(int32_t fileDescriptor) { if (fileDescriptor < 0) { - HiLog::Error(LABEL, "%{public}s param is error: %{public}d", __func__, fileDescriptor); + SEN_HILOGE("param is error: %{public}d", fileDescriptor); return; } diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index 5f941182b213a14713a9b202f4c4c73e7a49d1ad..afb5bafc1885793068caeb09221b4a2a9b5a6e3d 100644 --- a/frameworks/native/sensor/src/sensor_agent_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_agent_proxy.cpp @@ -81,10 +81,10 @@ SensorAgentProxy::SensorAgentProxy() const SensorAgentProxy *SensorAgentProxy::GetSensorsObj() { - HiLog::Debug(LABEL, "%{public}s", __func__); + CALL_LOG_ENTER; if (sensorObj_ == nullptr) { - HiLog::Debug(LABEL, "%{public}s sensorObj_ new object", __func__); + SEN_HILOGD("sensorObj_ new object"); sensorObj_ = new (std::nothrow) SensorAgentProxy(); } return sensorObj_; @@ -114,10 +114,10 @@ void SensorAgentProxy::HandleSensorData(struct SensorEvent *events, int32_t num, int32_t SensorAgentProxy::CreateSensorDataChannel() const { - HiLog::Debug(LABEL, "%{public}s", __func__); + CALL_LOG_ENTER; std::lock_guard chanelLock(chanelMutex_); if (g_isChannelCreated) { - HiLog::Info(LABEL, "%{public}s the channel has already been created", __func__); + SEN_HILOGI("the channel has already been created"); return ERR_OK; } CHKPR(dataChannel_, INVALID_POINTER); @@ -130,8 +130,7 @@ int32_t SensorAgentProxy::CreateSensorDataChannel() const ret = client.TransferDataChannel(dataChannel_); if (ret != ERR_OK) { auto destoryRet = dataChannel_->DestroySensorDataChannel(); - HiLog::Error(LABEL, "%{public}s transfer data channel failed, ret : %{public}d, destoryRet : %{public}d", - __func__, ret, destoryRet); + SEN_HILOGE("transfer data channel failed, ret : %{public}d, destoryRet : %{public}d", ret, destoryRet); return ret; } g_isChannelCreated = true; @@ -140,22 +139,22 @@ int32_t SensorAgentProxy::CreateSensorDataChannel() const int32_t SensorAgentProxy::DestroySensorDataChannel() const { - HiLog::Debug(LABEL, "%{public}s", __func__); + CALL_LOG_ENTER; std::lock_guard chanelLock(chanelMutex_); if (!g_isChannelCreated) { - HiLog::Info(LABEL, "%{public}s channel has been destroyed", __func__); + SEN_HILOGI("channel has been destroyed"); return ERR_OK; } CHKPR(dataChannel_, INVALID_POINTER); int32_t ret = dataChannel_->DestroySensorDataChannel(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s destory data channel failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("destory data channel failed, ret : %{public}d", ret); return ret; } SensorServiceClient &client = SensorServiceClient::GetInstance(); ret = client.DestroyDataChannel(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s destory service data channel fail, ret : %{public}d", __func__, ret); + SEN_HILOGE("destory service data channel fail, ret : %{public}d", ret); return ret; } g_isChannelCreated = false; @@ -165,16 +164,16 @@ int32_t SensorAgentProxy::DestroySensorDataChannel() const int32_t SensorAgentProxy::ActivateSensor(int32_t sensorId, const SensorUser *user) const { if (user == nullptr || sensorId < 0 || user->callback == nullptr) { - HiLog::Error(LABEL, "%{public}s user is null or sensorId is invalid", __func__); + SEN_HILOGE("user is null or sensorId is invalid"); return OHOS::Sensors::ERROR; } if (g_samplingInterval < 0 || g_reportInterval < 0) { - HiLog::Error(LABEL, "%{public}s samplingPeroid or g_reportInterval is invalid", __func__); + SEN_HILOGE("samplingPeroid or g_reportInterval is invalid"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); if ((g_subscribeMap.find(sensorId) == g_subscribeMap.end()) || (g_subscribeMap[sensorId] != user)) { - HiLog::Error(LABEL, "%{public}s subscribe sensorId first", __func__); + SEN_HILOGE("subscribe sensorId first"); return OHOS::Sensors::ERROR; } SensorServiceClient &client = SensorServiceClient::GetInstance(); @@ -182,7 +181,7 @@ int32_t SensorAgentProxy::ActivateSensor(int32_t sensorId, const SensorUser *use g_samplingInterval = -1; g_reportInterval = -1; if (ret != 0) { - HiLog::Error(LABEL, "%{public}s enable sensor failed, ret: %{public}d", __func__, ret); + SEN_HILOGE("enable sensor failed, ret: %{public}d", ret); g_subscribeMap.erase(sensorId); return OHOS::Sensors::ERROR; @@ -193,12 +192,12 @@ int32_t SensorAgentProxy::ActivateSensor(int32_t sensorId, const SensorUser *use int32_t SensorAgentProxy::DeactivateSensor(int32_t sensorId, const SensorUser *user) const { if (user == nullptr || sensorId < 0 || user->callback == nullptr) { - HiLog::Error(LABEL, "%{public}s user is null or sensorId is invalid", __func__); + SEN_HILOGE("user is null or sensorId is invalid"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); if ((g_subscribeMap.find(sensorId) == g_subscribeMap.end()) || (g_subscribeMap[sensorId] != user)) { - HiLog::Error(LABEL, "%{public}s subscribe sensorId first", __func__); + SEN_HILOGE("subscribe sensorId first"); return OHOS::Sensors::ERROR; } g_subscribeMap.erase(sensorId); @@ -206,7 +205,7 @@ int32_t SensorAgentProxy::DeactivateSensor(int32_t sensorId, const SensorUser *u SensorServiceClient &client = SensorServiceClient::GetInstance(); int32_t ret = client.DisableSensor(sensorId); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s disable sensor failed, ret: %{public}d", __func__, ret); + SEN_HILOGE("disable sensor failed, ret: %{public}d", ret); return OHOS::Sensors::ERROR; } return OHOS::Sensors::SUCCESS; @@ -216,16 +215,16 @@ int32_t SensorAgentProxy::SetBatch(int32_t sensorId, const SensorUser *user, int int64_t reportInterval) const { if (user == nullptr || sensorId < 0) { - HiLog::Error(LABEL, "%{public}s user is null or sensorId is invalid", __func__); + SEN_HILOGE("user is null or sensorId is invalid"); return OHOS::Sensors::ERROR; } if (samplingInterval < 0 || reportInterval < 0) { - HiLog::Error(LABEL, "%{public}s samplingInterval or reportInterval is invalid", __func__); + SEN_HILOGE("samplingInterval or reportInterval is invalid"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); if ((g_subscribeMap.find(sensorId) == g_subscribeMap.end()) || (g_subscribeMap.at(sensorId) != user)) { - HiLog::Error(LABEL, "%{public}s subscribe sensorId first", __func__); + SEN_HILOGE("subscribe sensorId first"); return OHOS::Sensors::ERROR; } g_samplingInterval = samplingInterval; @@ -235,14 +234,14 @@ int32_t SensorAgentProxy::SetBatch(int32_t sensorId, const SensorUser *user, int int32_t SensorAgentProxy::SubscribeSensor(int32_t sensorId, const SensorUser *user) const { - HiLog::Info(LABEL, "%{public}s in, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("in, sensorId: %{public}d", sensorId); if (user == nullptr || sensorId < 0 || user->callback == nullptr) { - HiLog::Error(LABEL, "%{public}s user or sensorId is invalid", __func__); + SEN_HILOGE("user or sensorId is invalid"); return OHOS::Sensors::ERROR; } int32_t ret = CreateSensorDataChannel(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s create sensor data chanel failed", __func__); + SEN_HILOGE("create sensor data chanel failed"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); @@ -252,20 +251,20 @@ int32_t SensorAgentProxy::SubscribeSensor(int32_t sensorId, const SensorUser *us int32_t SensorAgentProxy::UnsubscribeSensor(int32_t sensorId, const SensorUser *user) const { - HiLog::Info(LABEL, "%{public}s in, sensorId: %{public}d", __func__, sensorId); + SEN_HILOGI("in, sensorId: %{public}d", sensorId); if (user == nullptr || sensorId < 0 || user->callback == nullptr) { - HiLog::Error(LABEL, "%{public}s user is null or sensorId is invalid", __func__); + SEN_HILOGE("user is null or sensorId is invalid"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); if (g_unsubscribeMap.find(sensorId) == g_unsubscribeMap.end() || g_unsubscribeMap[sensorId] != user) { - HiLog::Error(LABEL, "%{public}s deactivate sensorId first", __func__); + SEN_HILOGE("deactivate sensorId first"); return OHOS::Sensors::ERROR; } if (g_subscribeMap.empty()) { int32_t ret = DestroySensorDataChannel(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s destory data channel fail, ret : %{public}d", __func__, ret); + SEN_HILOGE("destory data channel fail, ret : %{public}d", ret); return ret; } } @@ -276,12 +275,12 @@ int32_t SensorAgentProxy::UnsubscribeSensor(int32_t sensorId, const SensorUser * int32_t SensorAgentProxy::SetMode(int32_t sensorId, const SensorUser *user, int32_t mode) const { if (user == nullptr || sensorId < 0 || user->callback == nullptr) { - HiLog::Error(LABEL, "%{public}s user is null or sensorId is invalid", __func__); + SEN_HILOGE("user is null or sensorId is invalid"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); if ((g_subscribeMap.find(sensorId) == g_subscribeMap.end()) || (g_subscribeMap.at(sensorId) != user)) { - HiLog::Error(LABEL, "%{public}s subscribe sensorId first", __func__); + SEN_HILOGE("subscribe sensorId first"); return OHOS::Sensors::ERROR; } return OHOS::Sensors::SUCCESS; @@ -290,12 +289,12 @@ int32_t SensorAgentProxy::SetMode(int32_t sensorId, const SensorUser *user, int3 int32_t SensorAgentProxy::SetOption(int32_t sensorId, const SensorUser *user, int32_t option) const { if (user == nullptr || sensorId < 0 || user->callback == nullptr) { - HiLog::Error(LABEL, "%{public}s user is null or sensorId is invalid", __func__); + SEN_HILOGE("user is null or sensorId is invalid"); return OHOS::Sensors::ERROR; } std::lock_guard subscribeLock(subscribeMutex_); if ((g_subscribeMap.find(sensorId) == g_subscribeMap.end()) || (g_subscribeMap.at(sensorId) != user)) { - HiLog::Error(LABEL, "%{public}s subscribe sensorId first", __func__); + SEN_HILOGE("subscribe sensorId first"); return OHOS::Sensors::ERROR; } return OHOS::Sensors::SUCCESS; @@ -304,13 +303,13 @@ int32_t SensorAgentProxy::SetOption(int32_t sensorId, const SensorUser *user, in int32_t SensorAgentProxy::GetAllSensors(SensorInfo **sensorInfo, int32_t *count) const { if (sensorInfo == nullptr || count == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorInfo or count is null", __func__); + SEN_HILOGE("sensorInfo or count is null"); return OHOS::Sensors::ERROR; } SensorServiceClient &client = SensorServiceClient::GetInstance(); std::vector sensorList_ = client.GetSensorList(); if (sensorList_.empty()) { - HiLog::Error(LABEL, "%{public}s get sensor lists failed", __func__); + SEN_HILOGE("get sensor lists failed"); return OHOS::Sensors::ERROR; } *count = sensorList_.size(); @@ -320,25 +319,25 @@ int32_t SensorAgentProxy::GetAllSensors(SensorInfo **sensorInfo, int32_t *count) errno_t ret = strcpy_s((*sensorInfo + index)->sensorName, NAME_MAX_LEN, sensorList_[index].GetSensorName().c_str()); if (ret != EOK) { - HiLog::Error(LABEL, "%{public}s strcpy sensorName failed", __func__); + SEN_HILOGE("strcpy sensorName failed"); return OHOS::Sensors::ERROR; } ret = strcpy_s((*sensorInfo + index)->vendorName, NAME_MAX_LEN, sensorList_[index].GetVendorName().c_str()); if (ret != EOK) { - HiLog::Error(LABEL, "%{public}s strcpy vendorName failed", __func__); + SEN_HILOGE("strcpy vendorName failed"); return OHOS::Sensors::ERROR; } ret = strcpy_s((*sensorInfo + index)->hardwareVersion, VERSION_MAX_LEN, sensorList_[index].GetHardwareVersion().c_str()); if (ret != EOK) { - HiLog::Error(LABEL, "%{public}s strcpy hardwareVersion failed", __func__); + SEN_HILOGE("strcpy hardwareVersion failed"); return OHOS::Sensors::ERROR; } ret = strcpy_s((*sensorInfo + index)->firmwareVersion, VERSION_MAX_LEN, sensorList_[index].GetFirmwareVersion().c_str()); if (ret != EOK) { - HiLog::Error(LABEL, "%{public}s strcpy hardwareVersion failed", __func__); + SEN_HILOGE("strcpy hardwareVersion failed"); return OHOS::Sensors::ERROR; } (*sensorInfo + index)->sensorId = static_cast(sensorList_[index].GetSensorId()); diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index 8d4f8880102d8505a7dcf1000120badf3115847e..ccbd8bfc6f37a0978ba5a8efaa85daaf50cccc0e 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -46,7 +46,7 @@ constexpr uint32_t STOP_EVENT_ID = 0; int32_t SensorDataChannel::CreateSensorDataChannel(DataChannelCB callBack, void *data) { if (callBack == nullptr) { - HiLog::Error(LABEL, "%{public}s callBack cannot be null", __func__); + SEN_HILOGE("callBack cannot be null"); return SENSOR_NATIVE_REGSITER_CB_ERR; } dataCB_ = callBack; @@ -57,11 +57,11 @@ int32_t SensorDataChannel::CreateSensorDataChannel(DataChannelCB callBack, void int32_t SensorDataChannel::RestoreSensorDataChannel() { if (dataCB_ == nullptr) { - HiLog::Error(LABEL, "%{public}s dataCB_ cannot be null", __func__); + SEN_HILOGE("dataCB_ cannot be null"); return SENSOR_CHANNEL_RESTORE_CB_ERR; } if (GetReceiveDataFd() != -1) { - HiLog::Error(LABEL, "%{public}s fd not close", __func__); + SEN_HILOGE("fd not close"); return SENSOR_CHANNEL_RESTORE_FD_ERR; } return InnerSensorDataChannel(); @@ -73,25 +73,25 @@ int32_t SensorDataChannel::InnerSensorDataChannel() // create basic data channel int32_t ret = CreateSensorBasicChannel(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s create basic channel failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("create basic channel failed, ret : %{public}d", ret); return ret; } auto listener = std::make_shared(); listener->SetChannel(this); auto myRunner = AppExecFwk::EventRunner::Create(true); if (myRunner == nullptr) { - HiLog::Error(LABEL, "%{public}s myRunner is null", __func__); + SEN_HILOGE("myRunner is null"); return ERROR; } auto handler = std::make_shared(myRunner); if (handler == nullptr) { - HiLog::Error(LABEL, "%{public}s handler is null", __func__); + SEN_HILOGE("handler is null"); return ERROR; } int32_t receiveFd = GetReceiveDataFd(); auto inResult = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); if (inResult != 0) { - HiLog::Error(LABEL, "%{public}s AddFileDescriptorListener fail", __func__); + SEN_HILOGE("AddFileDescriptorListener fail"); return ERROR; } eventHandler_ = handler; @@ -100,12 +100,12 @@ int32_t SensorDataChannel::InnerSensorDataChannel() int64_t param = 0; bool sendEventResult = eventHandler_->SendEvent(STOP_EVENT_ID, param, delayTime); if (!sendEventResult) { - HiLog::Error(LABEL, "%{public}s EventHandler SendEvent fail", __func__); + SEN_HILOGE("EventHandler SendEvent fail"); return ERROR; } int32_t runResult = eventRunner_->Run(); if (!runResult) { - HiLog::Error(LABEL, "%{public}s EventRunner run fail", __func__); + SEN_HILOGE("EventRunner run fail"); return ERROR; } return ERR_OK; @@ -115,7 +115,7 @@ int32_t SensorDataChannel::DestroySensorDataChannel() { std::lock_guard eventRunnerLock(eventRunnerMutex_); if (eventHandler_ == nullptr || eventRunner_ == nullptr) { - HiLog::Error(LABEL, "%{public}s handler or eventRunner is null", __func__); + SEN_HILOGE("handler or eventRunner is null"); return ERROR; } int32_t receiveFd = GetReceiveDataFd(); diff --git a/frameworks/native/sensor/src/sensor_service_client.cpp b/frameworks/native/sensor/src/sensor_service_client.cpp index fcd4a75f9b438e259e099126d2379722cffebf26..dbc904604c349c33f3616a599f723ca55d086585 100755 --- a/frameworks/native/sensor/src/sensor_service_client.cpp +++ b/frameworks/native/sensor/src/sensor_service_client.cpp @@ -43,7 +43,7 @@ int32_t SensorServiceClient::InitServiceClient() CALL_LOG_ENTER; std::lock_guard clientLock(clientMutex_); if (sensorServer_ != nullptr) { - HiLog::Debug(LABEL, "%{public}s already init", __func__); + SEN_HILOGD("already init"); return ERR_OK; } if (sensorClientStub_ == nullptr) { @@ -51,14 +51,14 @@ int32_t SensorServiceClient::InitServiceClient() } auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (systemAbilityManager == nullptr) { - HiLog::Error(LABEL, "%{public}s systemAbilityManager cannot be null", __func__); + SEN_HILOGE("systemAbilityManager cannot be null"); return SENSOR_NATIVE_SAM_ERR; } int32_t retry = 0; while (retry < GET_SERVICE_MAX_COUNT) { sensorServer_ = iface_cast(systemAbilityManager->GetSystemAbility(SENSOR_SERVICE_ABILITY_ID)); if (sensorServer_ != nullptr) { - HiLog::Debug(LABEL, "%{public}s get service success, retry : %{public}d", __func__, retry); + SEN_HILOGD("get service success, retry : %{public}d", retry); serviceDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); if (serviceDeathObserver_ != nullptr) { sensorServer_->AsObject()->AddDeathRecipient(serviceDeathObserver_); @@ -66,19 +66,19 @@ int32_t SensorServiceClient::InitServiceClient() sensorList_ = sensorServer_->GetSensorList(); return ERR_OK; } - HiLog::Warn(LABEL, "%{public}s get service failed, retry : %{public}d", __func__, retry); + SEN_HILOGW("get service failed, retry : %{public}d", retry); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); retry++; } DmdReport::ReportException(SENSOR_SERVICE_EXCEPTION, "InitServiceClient", SENSOR_NATIVE_GET_SERVICE_ERR); - HiLog::Error(LABEL, "%{public}s get service failed", __func__); + SEN_HILOGE("get service failed"); return SENSOR_NATIVE_GET_SERVICE_ERR; } bool SensorServiceClient::IsValidSensorId(uint32_t sensorId) { if (sensorList_.empty()) { - HiLog::Error(LABEL, "%{public}s sensorList_ cannot be empty", __func__); + SEN_HILOGE("sensorList_ cannot be empty"); return false; } for (auto &sensor : sensorList_) { @@ -93,12 +93,12 @@ int32_t SensorServiceClient::EnableSensor(uint32_t sensorId, int64_t samplingPer { CALL_LOG_ENTER; if (!IsValidSensorId(sensorId)) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return SENSOR_NATIVE_SAM_ERR; } int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); return ret; } ret = sensorServer_->EnableSensor(sensorId, samplingPeriod, maxReportDelay); @@ -112,12 +112,12 @@ int32_t SensorServiceClient::DisableSensor(uint32_t sensorId) { CALL_LOG_ENTER; if (!IsValidSensorId(sensorId)) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return SENSOR_NATIVE_SAM_ERR; } int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); return ret; } ret = sensorServer_->DisableSensor(sensorId); @@ -131,17 +131,17 @@ int32_t SensorServiceClient::RunCommand(uint32_t sensorId, int32_t cmdType, int3 { CALL_LOG_ENTER; if (!IsValidSensorId(sensorId)) { - HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); + SEN_HILOGE("sensorId is invalid"); return SENSOR_NATIVE_SAM_ERR; } int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); return ret; } ret = sensorServer_->RunCommand(sensorId, cmdType, params); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s RunCommand failed", __func__); + SEN_HILOGE("RunCommand failed"); return ret; } return ret; @@ -152,11 +152,11 @@ std::vector SensorServiceClient::GetSensorList() CALL_LOG_ENTER; int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); return {}; } if (sensorList_.empty()) { - HiLog::Error(LABEL, "%{public}s sensorList_ cannot be empty", __func__); + SEN_HILOGE("sensorList_ cannot be empty"); } return sensorList_; } @@ -167,7 +167,7 @@ int32_t SensorServiceClient::TransferDataChannel(sptr sensorD dataChannel_ = sensorDataChannel; int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); return ret; } return sensorServer_->TransferDataChannel(sensorDataChannel, sensorClientStub_); @@ -178,7 +178,7 @@ int32_t SensorServiceClient::DestroyDataChannel() CALL_LOG_ENTER; int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); return ret; } return sensorServer_->DestroySensorChannel(sensorClientStub_); @@ -189,7 +189,7 @@ void SensorServiceClient::ProcessDeathObserver(const wptr &object CALL_LOG_ENTER; (void)object; if (dataChannel_ == nullptr) { - HiLog::Error(LABEL, "%{public}s dataChannel_ cannot be null", __func__); + SEN_HILOGE("dataChannel_ cannot be null"); return; } // STEP1 : Destroy revious data channel @@ -205,7 +205,7 @@ void SensorServiceClient::ProcessDeathObserver(const wptr &object // STEP4 : ReGet sensors 3601 service int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - HiLog::Error(LABEL, "%{public}s InitServiceClient failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("InitServiceClient failed, ret : %{public}d", ret); dataChannel_->DestroySensorDataChannel(); return; } diff --git a/frameworks/native/sensor/src/sensor_service_proxy.cpp b/frameworks/native/sensor/src/sensor_service_proxy.cpp index 6e3a51c9e18cb6b4806ba6df4eb01fd1483857b3..b6dad630defa3093858d87a735413413e7259231 100755 --- a/frameworks/native/sensor/src/sensor_service_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_service_proxy.cpp @@ -46,25 +46,25 @@ ErrCode SensorServiceProxy::EnableSensor(uint32_t sensorId, int64_t samplingPeri MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return WRITE_MSG_ERR; } if (!data.WriteUint32(sensorId)) { - HiLog::Error(LABEL, "%{public}s write sensorId failed", __func__); + SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } if (!data.WriteInt64(samplingPeriodNs)) { - HiLog::Error(LABEL, "%{public}s write samplingPeriodNs failed", __func__); + SEN_HILOGE("write samplingPeriodNs failed"); return WRITE_MSG_ERR; } if (!data.WriteInt64(maxReportDelayNs)) { - HiLog::Error(LABEL, "%{public}s write maxReportDelayNs failed", __func__); + SEN_HILOGE("write maxReportDelayNs failed"); return WRITE_MSG_ERR; } int32_t ret = Remote()->SendRequest(ISensorService::ENABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "EnableSensor", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); } return static_cast(ret); } @@ -75,17 +75,17 @@ ErrCode SensorServiceProxy::DisableSensor(uint32_t sensorId) MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return WRITE_MSG_ERR; } if (!data.WriteUint32(sensorId)) { - HiLog::Error(LABEL, "%{public}s write sensorId failed", __func__); + SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } int32_t ret = Remote()->SendRequest(ISensorService::DISABLE_SENSOR, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "DisableSensor", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); } return static_cast(ret); } @@ -96,17 +96,17 @@ int32_t SensorServiceProxy::GetSensorState(uint32_t sensorId) MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return WRITE_MSG_ERR; } if (!data.WriteUint32(sensorId)) { - HiLog::Error(LABEL, "%{public}s write sensorId failed", __func__); + SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } int32_t ret = Remote()->SendRequest(ISensorService::GET_SENSOR_STATE, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "GetSensorState", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); } return static_cast(ret); } @@ -114,32 +114,32 @@ int32_t SensorServiceProxy::GetSensorState(uint32_t sensorId) ErrCode SensorServiceProxy::RunCommand(uint32_t sensorId, uint32_t cmdType, uint32_t params) { if (cmdType > RESERVED) { - HiLog::Error(LABEL, "%{public}s failed, cmdType : %{public}u", __func__, cmdType); + SEN_HILOGE("failed, cmdType : %{public}u", cmdType); return CMD_TYPE_ERR; } MessageParcel data; MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return WRITE_MSG_ERR; } if (!data.WriteUint32(sensorId)) { - HiLog::Error(LABEL, "%{public}s write sensorId failed", __func__); + SEN_HILOGE("write sensorId failed"); return WRITE_MSG_ERR; } if (!data.WriteUint32(cmdType)) { - HiLog::Error(LABEL, "%{public}s write cmdType failed", __func__); + SEN_HILOGE("write cmdType failed"); return WRITE_MSG_ERR; } if (!data.WriteUint32(params)) { - HiLog::Error(LABEL, "%{public}s write params failed", __func__); + SEN_HILOGE("write params failed"); return WRITE_MSG_ERR; } int32_t ret = Remote()->SendRequest(ISensorService::RUN_COMMAND, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "RunCommand", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); } return static_cast(ret); } @@ -151,18 +151,18 @@ std::vector SensorServiceProxy::GetSensorList() MessageOption option; std::vector sensors; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return sensors; } int32_t ret = Remote()->SendRequest(ISensorService::GET_SENSOR_LIST, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "GetSensorList", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); return sensors; } int32_t sensorCount = reply.ReadInt32(); - HiLog::Debug(LABEL, "%{public}s sensorCount : %{public}d", __func__, sensorCount); + SEN_HILOGD("sensorCount : %{public}d", sensorCount); if (sensorCount > MAX_SENSOR_COUNT) { sensorCount = MAX_SENSOR_COUNT; } @@ -181,25 +181,25 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptr &sensorClient) { if (sensorBasicDataChannel == nullptr || sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorBasicDataChannel or sensorClient cannot be null", __func__); + SEN_HILOGE("sensorBasicDataChannel or sensorClient cannot be null"); return OBJECT_NULL; } MessageParcel data; MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return WRITE_MSG_ERR; } sensorBasicDataChannel->SendToBinder(data); if (!data.WriteRemoteObject(sensorClient)) { - HiLog::Error(LABEL, "%{public}s write sensorClient failed", __func__); + SEN_HILOGE("sensorClient failed"); return WRITE_MSG_ERR; } int32_t ret = Remote()->SendRequest(ISensorService::TRANSFER_DATA_CHANNEL, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "TransferDataChannel", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); } sensorBasicDataChannel->CloseSendFd(); return static_cast(ret); @@ -208,24 +208,24 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptr sensorClient) { if (sensorClient == nullptr) { - HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); + SEN_HILOGE("sensorClient cannot be null"); return OBJECT_NULL; } MessageParcel data; MessageParcel reply; MessageOption option; if (!data.WriteInterfaceToken(SensorServiceProxy::GetDescriptor())) { - HiLog::Error(LABEL, "%{public}s write descriptor failed", __func__); + SEN_HILOGE("write descriptor failed"); return WRITE_MSG_ERR; } if (!data.WriteRemoteObject(sensorClient)) { - HiLog::Error(LABEL, "%{public}s write sensorClient failed", __func__); + SEN_HILOGE("write sensorClient failed"); return WRITE_MSG_ERR; } int32_t ret = Remote()->SendRequest(ISensorService::DESTROY_SENSOR_CHANNEL, data, reply, option); if (ret != NO_ERROR) { DmdReport::ReportException(SENSOR_SERVICE_IPC_EXCEPTION, "DestroySensorChannel", ret); - HiLog::Error(LABEL, "%{public}s failed, ret : %{public}d", __func__, ret); + SEN_HILOGE("failed, ret : %{public}d", ret); } return static_cast(ret); }