From b75d5db5502c5707816ffa4c1ded1fad39afbd1c Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 15:10:10 +0800 Subject: [PATCH 1/7] process simple trace print Signed-off-by: li-yaoyao777 --- .vscode/settings.json | 52 +++++++++++++++++++ .../src/my_file_descriptor_listener.cpp | 4 +- services/sensor/src/client_info.cpp | 14 ++--- services/sensor/src/flush_info_record.cpp | 4 +- services/sensor/src/sensor_data_processer.cpp | 4 +- services/sensor/src/sensor_manager.cpp | 6 +-- services/sensor/src/sensor_service.cpp | 8 +-- services/sensor/src/sensor_suspend_policy.cpp | 8 ++- utils/src/dmd_report.cpp | 3 +- utils/src/sensor_basic_data_channel.cpp | 2 +- 10 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..ab739ee8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,52 @@ +{ + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "map": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "optional": "cpp", + "ratio": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeinfo": "cpp" + } +} \ No newline at end of file diff --git a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp index a562164c..fe08c098 100644 --- a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp +++ b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp @@ -38,7 +38,7 @@ MyFileDescriptorListener::MyFileDescriptorListener() MyFileDescriptorListener::~MyFileDescriptorListener() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (receiveDataBuff_ != nullptr) { delete[] receiveDataBuff_; receiveDataBuff_ = nullptr; @@ -47,7 +47,7 @@ MyFileDescriptorListener::~MyFileDescriptorListener() void MyFileDescriptorListener::OnReadable(int32_t fileDescriptor) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (fileDescriptor < 0) { HiLog::Error(LABEL, "%{public}s fileDescriptor: %{public}d", __func__, fileDescriptor); return; diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index c39ee3e0..b59f9bd2 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -495,7 +495,7 @@ void ClientInfo::StoreEvent(const struct SensorEvent &event) bool ClientInfo::SaveClientPid(const sptr &sensorClient, int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorClient == nullptr) { HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); return false; @@ -514,7 +514,7 @@ bool ClientInfo::SaveClientPid(const sptr &sensorClient, int32_t int32_t ClientInfo::FindClientPid(const sptr &sensorClient) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorClient == nullptr) { HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); return INVALID_PID; @@ -531,7 +531,7 @@ int32_t ClientInfo::FindClientPid(const sptr &sensorClient) void ClientInfo::DestroyClientPid(const sptr &sensorClient) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorClient == nullptr) { HiLog::Error(LABEL, "%{public}s sensorClient cannot be null", __func__); return; @@ -554,7 +554,7 @@ void ClientInfo::ClearEvent() std::vector ClientInfo::GetSensorIdByPid(int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; std::vector sensorIdVec; std::lock_guard clientLock(clientMutex_); for (const auto &itClientMap : clientMap_) { @@ -568,7 +568,7 @@ std::vector ClientInfo::GetSensorIdByPid(int32_t pid) AppThreadInfo ClientInfo::GetAppInfoByChannel(const sptr &channel) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; AppThreadInfo appThreadInfo; { std::lock_guard channelLock(channelMutex_); @@ -591,7 +591,7 @@ AppThreadInfo ClientInfo::GetAppInfoByChannel(const sptr void ClientInfo::GetSensorChannelInfo(std::vector &channelInfo) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; std::lock_guard clientLock(clientMutex_); for (const auto &sensorIt : clientMap_) { for (const auto &pidIt : sensorIt.second) { @@ -671,7 +671,7 @@ std::vector ClientInfo::GetCmdList(uint32_t sensorId, int32_t uid) void ClientInfo::UpdateDataQueue(int32_t sensorId, struct SensorEvent &event) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorId == HEART_RATE_SENSOR_ID) { return; } diff --git a/services/sensor/src/flush_info_record.cpp b/services/sensor/src/flush_info_record.cpp index 9f349918..3e714118 100644 --- a/services/sensor/src/flush_info_record.cpp +++ b/services/sensor/src/flush_info_record.cpp @@ -34,7 +34,7 @@ enum { std::unordered_map> FlushInfoRecord::GetFlushInfo() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; std::lock_guard flushLock(flushInfoMutex_); return flushInfo_; } @@ -87,7 +87,7 @@ bool FlushInfoRecord::IsFlushChannelValid(const std::vector &flushInfoList, const sptr &channel) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; for (size_t i = 0; i < flushInfoList.size(); i++) { if (flushInfoList[i].flushChannel == channel) { return i; diff --git a/services/sensor/src/sensor_data_processer.cpp b/services/sensor/src/sensor_data_processer.cpp index c5cb6646..e645ed21 100644 --- a/services/sensor/src/sensor_data_processer.cpp +++ b/services/sensor/src/sensor_data_processer.cpp @@ -307,7 +307,7 @@ int32_t SensorDataProcesser::CacheSensorEvent(const struct SensorEvent &event, s void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; uint32_t realSensorId = 0; uint32_t sensorId = static_cast(eventsBuf.circularBuf[eventsBuf.readPosition].sensorTypeId); std::vector> channelList; @@ -399,7 +399,7 @@ int32_t SensorDataProcesser::SendEvents(sptr &channel, s int32_t SensorDataProcesser::DataThread(sptr dataProcesser, sptr dataCallback) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; do { if (dataProcesser->ProcessEvents(dataCallback) == INVALID_POINTER) { HiLog::Error(LABEL, "%{public}s callback cannot be null", __func__); diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 1476c1af..8a9f2442 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -143,7 +143,7 @@ ErrCode SensorManager::SaveSubscriber(uint32_t sensorId, uint32_t pid, int64_t s void SensorManager::StartDataReportThread() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (!dataThread_.joinable()) { HiLog::Warn(LABEL, "%{public}s dataThread_ started", __func__); std::thread senocdDataThread(SensorDataProcesser::DataThread, sensorDataProcesser_, reportDataCallback_); @@ -169,7 +169,7 @@ bool SensorManager::IsOtherClientUsingSensor(uint32_t sensorId, int32_t clientPi ErrCode SensorManager::AfterDisableSensor(uint32_t sensorId) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (!clientInfo_.ClearSensorInfo(sensorId)) { HiLog::Error(LABEL, "%{public}s ClearSensorInfo failed", __func__); return CLEAR_SENSOR_INFO_ERR; @@ -189,7 +189,7 @@ ErrCode SensorManager::AfterDisableSensor(uint32_t sensorId) void SensorManager::GetPackageNameFromUid(int32_t uid, std::string &packageName) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; } } // namespace Sensors } // namespace OHOS diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 5a753265..f08d21c9 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -60,7 +60,7 @@ void SensorService::OnDump() void SensorService::OnStart() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (state_ == SensorServiceState::STATE_RUNNING) { HiLog::Warn(LABEL, "%{public}s SensorService has already started", __func__); return; @@ -144,7 +144,7 @@ bool SensorService::InitSensorPolicy() void SensorService::OnStop() { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (state_ == SensorServiceState::STATE_STOPPED) { HiLog::Warn(LABEL, "%{public}s already stopped", __func__); return; @@ -280,7 +280,7 @@ ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, ErrCode SensorService::DisableSensor(uint32_t sensorId) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); return ERR_NO_INIT; @@ -321,7 +321,7 @@ int32_t SensorService::GetSensorState(uint32_t sensorId) ErrCode SensorService::RunCommand(uint32_t sensorId, uint32_t cmdType, uint32_t params) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID || ((cmdType != FLUSH) && (cmdType != SET_MODE))) { HiLog::Error(LABEL, "%{public}s sensorId or cmd is invalid", __func__); return ERR_NO_INIT; diff --git a/services/sensor/src/sensor_suspend_policy.cpp b/services/sensor/src/sensor_suspend_policy.cpp index 0553b8d1..744d866a 100755 --- a/services/sensor/src/sensor_suspend_policy.cpp +++ b/services/sensor/src/sensor_suspend_policy.cpp @@ -44,7 +44,7 @@ bool SensorSuspendPolicy::CheckFreezingSensor(uint32_t sensorId) ErrCode SensorSuspendPolicy::DisableSensor(uint32_t sensorId, int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); return ERR_NO_INIT; @@ -62,7 +62,7 @@ ErrCode SensorSuspendPolicy::DisableSensor(uint32_t sensorId, int32_t pid) void SensorSuspendPolicy::DoSuspend(const std::shared_ptr &info) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; std::lock_guard suspendLock(suspendMutex_); auto &list = info->GetAppIPCInfoList(); for (const auto &appInfo : list) { @@ -80,7 +80,6 @@ void SensorSuspendPolicy::DoSuspend(const std::shared_ptr SensorSuspendPolicy::GetSensorIdByPid(int32_t pid) void SensorSuspendPolicy::DoActive(const std::shared_ptr &info) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; int64_t samplePeriod = DEFAULT_SAMPLEING_RATE; int64_t maxReportDelay = DEFAULT_REPORT_DELAY; std::vector sensorIdList; @@ -178,7 +177,6 @@ void SensorSuspendPolicy::DoActive(const std::shared_ptr eventLock(eventMutex_); auto eventIt = eventMap_.find(eventId); if (eventIt == eventMap_.end()) { @@ -87,7 +87,6 @@ void DmdReport::ReportException(int32_t eventId, const std::string &interfaceNam HiviewDFX::HiSysEvent::Write(HiviewDFX::HiSysEvent::Domain::SENSORS, GetEventName(eventId), HiviewDFX::HiSysEvent::EventType::FAULT, interfaceName, error); eventMap_[eventId] = curTime; - HiLog::Debug(LABEL, "%{public}s end", __func__); return; } HiLog::Warn(LABEL, "%{public}s eventId is reported every half an hour", __func__); diff --git a/utils/src/sensor_basic_data_channel.cpp b/utils/src/sensor_basic_data_channel.cpp index 3ae2fc33..13730d9f 100755 --- a/utils/src/sensor_basic_data_channel.cpp +++ b/utils/src/sensor_basic_data_channel.cpp @@ -87,7 +87,7 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel(size_t sendSize, size_t int32_t SensorBasicDataChannel::CreateSensorBasicChannel(MessageParcel &data) { - HiLog::Debug(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; if ((sendFd_ != INVALID_FD) || (receiveFd_ != INVALID_FD)) { HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); return ERR_OK; -- Gitee From aa0930274bc0b2ca353b40d69dbf2ff4d0a50534 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 15:12:49 +0800 Subject: [PATCH 2/7] process simple trace print Signed-off-by: li-yaoyao777 --- .vscode/settings.json | 52 ------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index ab739ee8..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "atomic": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "map": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "optional": "cpp", - "ratio": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "typeinfo": "cpp" - } -} \ No newline at end of file -- Gitee From 5f89a7ef6d48e52747317dc8e0c859c862ba850f Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 15:28:05 +0800 Subject: [PATCH 3/7] process simple trace print Signed-off-by: li-yaoyao777 --- services/sensor/src/sensor_manager.cpp | 14 ++++---------- services/sensor/src/sensor_service.cpp | 5 ----- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/services/sensor/src/sensor_manager.cpp b/services/sensor/src/sensor_manager.cpp index 8a9f2442..dfba119f 100644 --- a/services/sensor/src/sensor_manager.cpp +++ b/services/sensor/src/sensor_manager.cpp @@ -53,8 +53,7 @@ uint32_t SensorManager::GetSensorFlag(uint32_t sensorId) bool SensorManager::SetBestSensorParams(uint32_t sensorId, int64_t samplingPeriodNs, int64_t maxReportDelayNs) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u, samplingPeriodNs : %{public}d", __func__, sensorId, - int32_t { samplingPeriodNs }); + CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); return false; @@ -74,13 +73,12 @@ bool SensorManager::SetBestSensorParams(uint32_t sensorId, int64_t samplingPerio HiLog::Error(LABEL, "%{public}s SetBatch failed", __func__); return false; } - HiLog::Debug(LABEL, "%{public}s end", __func__); return true; } bool SensorManager::ResetBestSensorParams(uint32_t sensorId) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u", __func__, sensorId); + CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); return false; @@ -92,13 +90,12 @@ bool SensorManager::ResetBestSensorParams(uint32_t sensorId) HiLog::Error(LABEL, "%{public}s SetBatch failed", __func__); return false; } - HiLog::Debug(LABEL, "%{public}s end", __func__); return true; } SensorBasicInfo SensorManager::GetSensorInfo(uint32_t sensorId, int64_t samplingPeriodNs, int64_t maxReportDelayNs) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u", __func__, sensorId); + CALL_LOG_ENTER; SensorBasicInfo sensorInfo; std::lock_guard sensorMapLock(sensorMapMutex_); auto it = sensorMap_.find(sensorId); @@ -125,7 +122,6 @@ SensorBasicInfo SensorManager::GetSensorInfo(uint32_t sensorId, int64_t sampling sensorInfo.SetSamplingPeriodNs(curSamplingPeriodNs); sensorInfo.SetMaxReportDelayNs(curReportDelayNs); sensorInfo.SetSensorState(SENSOR_ENABLED); - HiLog::Debug(LABEL, "%{public}s end", __func__); return sensorInfo; } @@ -149,12 +145,11 @@ void SensorManager::StartDataReportThread() std::thread senocdDataThread(SensorDataProcesser::DataThread, sensorDataProcesser_, reportDataCallback_); dataThread_ = std::move(senocdDataThread); } - HiLog::Debug(LABEL, "%{public}s end", __func__); } bool SensorManager::IsOtherClientUsingSensor(uint32_t sensorId, int32_t clientPid) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u", __func__, sensorId); + CALL_LOG_ENTER; if (clientInfo_.OnlyCurPidSensorEnabled(sensorId, clientPid)) { HiLog::Warn(LABEL, "%{public}s Only current client using this sensor", __func__); return false; @@ -183,7 +178,6 @@ ErrCode SensorManager::AfterDisableSensor(uint32_t sensorId) clientInfo_.StoreEvent(event); } } - HiLog::Debug(LABEL, "%{public}s end", __func__); return ERR_OK; } diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index f08d21c9..b9eb2438 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -400,7 +400,6 @@ ErrCode SensorService::DestroySensorChannel(sptr sensorClient) } clientInfo_.DestroyCmd(this->GetCallingUid()); UnregisterClientDeathRecipient(sensorClient); - HiLog::Info(LABEL, "%{public}s end", __func__); return ERR_OK; } @@ -421,7 +420,6 @@ void SensorService::ProcessDeathObserver(const wptr &object) clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); clientInfo_.DestroyCmd(this->GetCallingUid()); - HiLog::Info(LABEL, "%{public}s end", __func__); } void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid) @@ -435,7 +433,6 @@ void SensorService::RegisterClientDeathRecipient(sptr sensorClien } client->AsObject()->AddDeathRecipient(clientDeathObserver_); clientInfo_.SaveClientPid(sensorClient, pid); - HiLog::Info(LABEL, "%{public}s end", __func__); } void SensorService::UnregisterClientDeathRecipient(sptr sensorClient) @@ -449,7 +446,6 @@ void SensorService::UnregisterClientDeathRecipient(sptr sensorCli } client->AsObject()->RemoveDeathRecipient(clientDeathObserver_); clientInfo_.DestroyClientPid(sensorClient); - HiLog::Info(LABEL, "%{public}s end", __func__); } int32_t SensorService::Dump(int32_t fd, const std::vector &args) @@ -473,7 +469,6 @@ int32_t SensorService::Dump(int32_t fd, const std::vector &args) sensorDump.DumpHelp(fd); return DUMP_PARAM_ERR; } - HiLog::Info(LABEL, "%{public}s end", __func__); return ERR_OK; } } // namespace Sensors -- Gitee From f5d8eafc116d5262bc171da12fab409fc5092b51 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 15:40:50 +0800 Subject: [PATCH 4/7] process simple trace print Signed-off-by: li-yaoyao777 --- frameworks/native/sensor/src/my_file_descriptor_listener.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp index fe08c098..2b1db8ca 100644 --- a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp +++ b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp @@ -14,6 +14,7 @@ */ #include "my_file_descriptor_listener.h" +#include "sensors_errors.h" #include "sensors_log_domain.h" namespace OHOS { -- Gitee From 7766e20a2346d2673a95e41adb3fe8ec907d65ac Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 15:44:14 +0800 Subject: [PATCH 5/7] process simple trace print Signed-off-by: li-yaoyao777 --- services/sensor/src/client_info.cpp | 1 - services/sensor/src/sensor_data_processer.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index b59f9bd2..fae7cc8c 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -508,7 +508,6 @@ bool ClientInfo::SaveClientPid(const sptr &sensorClient, int32_t return true; } clientPidMap_.insert(std::make_pair(sensorClient, pid)); - HiLog::Debug(LABEL, "%{public}s end", __func__); return true; } diff --git a/services/sensor/src/sensor_data_processer.cpp b/services/sensor/src/sensor_data_processer.cpp index e645ed21..012ff58e 100644 --- a/services/sensor/src/sensor_data_processer.cpp +++ b/services/sensor/src/sensor_data_processer.cpp @@ -307,7 +307,6 @@ int32_t SensorDataProcesser::CacheSensorEvent(const struct SensorEvent &event, s void SensorDataProcesser::EventFilter(struct CircularEventBuf &eventsBuf) { - CALL_LOG_ENTER; uint32_t realSensorId = 0; uint32_t sensorId = static_cast(eventsBuf.circularBuf[eventsBuf.readPosition].sensorTypeId); std::vector> channelList; -- Gitee From 0cf78060cdb1b32d3091eda62a9cd1603b97af98 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 15:45:05 +0800 Subject: [PATCH 6/7] process simple trace print Signed-off-by: li-yaoyao777 --- frameworks/native/sensor/src/my_file_descriptor_listener.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp index 2b1db8ca..9b8c02e4 100644 --- a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp +++ b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp @@ -48,7 +48,6 @@ MyFileDescriptorListener::~MyFileDescriptorListener() void MyFileDescriptorListener::OnReadable(int32_t fileDescriptor) { - CALL_LOG_ENTER; if (fileDescriptor < 0) { HiLog::Error(LABEL, "%{public}s fileDescriptor: %{public}d", __func__, fileDescriptor); return; -- Gitee From 883dace481bf84bb087104d4493ec86d2f6f8a71 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 16:15:06 +0800 Subject: [PATCH 7/7] process simple trace print Signed-off-by: li-yaoyao777 --- .../src/my_file_descriptor_listener.cpp | 1 + services/sensor/src/client_info.cpp | 34 +++++++------------ services/sensor/src/sensor_service.cpp | 13 ++++--- services/sensor/src/sensor_suspend_policy.cpp | 3 +- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp index 9b8c02e4..2b1db8ca 100644 --- a/frameworks/native/sensor/src/my_file_descriptor_listener.cpp +++ b/frameworks/native/sensor/src/my_file_descriptor_listener.cpp @@ -48,6 +48,7 @@ MyFileDescriptorListener::~MyFileDescriptorListener() void MyFileDescriptorListener::OnReadable(int32_t fileDescriptor) { + CALL_LOG_ENTER; if (fileDescriptor < 0) { HiLog::Error(LABEL, "%{public}s fileDescriptor: %{public}d", __func__, fileDescriptor); return; diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index fae7cc8c..cbbc0fb9 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -42,7 +42,7 @@ constexpr uint32_t HEART_RATE_SENSOR_ID = 83886336; SensorState ClientInfo::GetSensorState(uint32_t sensorId) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u", __func__, sensorId); + CALL_LOG_ENTER; if (sensorId == INVALID_SENSOR_ID) { HiLog::Error(LABEL, "%{public}s sensorId is invalid", __func__); return SENSOR_DISABLED; @@ -65,7 +65,7 @@ SensorState ClientInfo::GetSensorState(uint32_t sensorId) SensorBasicInfo ClientInfo::GetBestSensorInfo(uint32_t sensorId) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u", __func__, sensorId); + CALL_LOG_ENTER; int64_t minSamplingPeriodNs = LLONG_MAX; int64_t minReportDelayNs = LLONG_MAX; SensorBasicInfo sensorInfo; @@ -96,7 +96,7 @@ SensorBasicInfo ClientInfo::GetBestSensorInfo(uint32_t sensorId) bool ClientInfo::OnlyCurPidSensorEnabled(uint32_t sensorId, int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u, pid : %{public}d", __func__, sensorId, pid); + CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || (pid <= INVALID_PID)) { HiLog::Error(LABEL, "%{public}s sensorId or pid is invalid", __func__); return false; @@ -118,13 +118,12 @@ bool ClientInfo::OnlyCurPidSensorEnabled(uint32_t sensorId, int32_t pid) } ret = true; } - HiLog::Debug(LABEL, "%{public}s end", __func__); return ret; } bool ClientInfo::UpdateAppThreadInfo(int32_t pid, int32_t uid, AccessTokenID callerToken) { - HiLog::Debug(LABEL, "%{public}s begin, pid : %{public}d, uid : %{public}d", __func__, pid, uid); + CALL_LOG_ENTER; if ((uid == INVALID_UID) || (pid <= INVALID_PID)) { HiLog::Error(LABEL, "%{public}s uid or pid is invalid", __func__); return false; @@ -141,13 +140,12 @@ bool ClientInfo::UpdateAppThreadInfo(int32_t pid, int32_t uid, AccessTokenID cal return ret.second; } appThreadInfoMap_[pid] = appThreadInfo; - HiLog::Debug(LABEL, "%{public}s end", __func__); return true; } void ClientInfo::DestroyAppThreadInfo(int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin, pid : %{public}d", __func__, pid); + CALL_LOG_ENTER; if (pid == INVALID_PID) { HiLog::Error(LABEL, "%{public}s pid is invalid", __func__); return; @@ -163,7 +161,7 @@ void ClientInfo::DestroyAppThreadInfo(int32_t pid) std::vector> ClientInfo::GetSensorChannelByUid(int32_t uid) { - HiLog::Debug(LABEL, "%{public}s begin, uid : %{public}d", __func__, uid); + CALL_LOG_ENTER; if (uid == INVALID_UID) { HiLog::Error(LABEL, "%{public}s uid is invalid", __func__); return {}; @@ -181,13 +179,12 @@ std::vector> ClientInfo::GetSensorChannelByUid(int3 } sensorChannel.push_back(channelIt->second); } - HiLog::Debug(LABEL, "%{public}s end", __func__); return sensorChannel; } sptr ClientInfo::GetSensorChannelByPid(int32_t pid) { - HiLog::Debug(LABEL, "%{public}s begin, pid : %{public}d", __func__, pid); + CALL_LOG_ENTER; if (pid == INVALID_PID) { HiLog::Error(LABEL, "%{public}s pid is invalid", __func__); return nullptr; @@ -198,7 +195,6 @@ sptr ClientInfo::GetSensorChannelByPid(int32_t pid) HiLog::Error(LABEL, "%{public}s there is no channel belong to the pid", __func__); return nullptr; } - HiLog::Debug(LABEL, "%{public}s end", __func__); return channelIt->second; } @@ -229,7 +225,7 @@ std::vector> ClientInfo::GetSensorChannel(uint32_t bool ClientInfo::UpdateSensorInfo(uint32_t sensorId, int32_t pid, const SensorBasicInfo &sensorInfo) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u, pid : %{public}d", __func__, sensorId, pid); + CALL_LOG_ENTER; if ((sensorId == INVALID_SENSOR_ID) || (pid <= INVALID_PID) || (sensorInfo.GetSensorState() != SENSOR_ENABLED)) { HiLog::Error(LABEL, "%{public}s params are invalid", __func__); return false; @@ -267,7 +263,7 @@ void ClientInfo::RemoveSubscriber(uint32_t sensorId, uint32_t pid) bool ClientInfo::UpdateSensorChannel(int32_t pid, const sptr &channel) { - HiLog::Debug(LABEL, "%{public}s begin, pid : %{public}d", __func__, pid); + CALL_LOG_ENTER; if (pid <= INVALID_PID || channel == nullptr) { HiLog::Error(LABEL, "%{public}s pid or channel is invalid or channel cannot be null", __func__); return false; @@ -284,13 +280,12 @@ bool ClientInfo::UpdateSensorChannel(int32_t pid, const sptrsecond.GetSamplingPeriodNs()); sensorInfo.SetMaxReportDelayNs(pidIt->second.GetMaxReportDelayNs()); - HiLog::Debug(LABEL, "%{public}s end", __func__); return sensorInfo; } @@ -504,7 +497,6 @@ bool ClientInfo::SaveClientPid(const sptr &sensorClient, int32_t auto it = clientPidMap_.find(sensorClient); if (it == clientPidMap_.end()) { clientPidMap_.insert(std::make_pair(sensorClient, pid)); - HiLog::Debug(LABEL, "%{public}s end", __func__); return true; } clientPidMap_.insert(std::make_pair(sensorClient, pid)); @@ -524,7 +516,6 @@ int32_t ClientInfo::FindClientPid(const sptr &sensorClient) HiLog::Error(LABEL, "%{public}s cannot find client pid", __func__); return INVALID_PID; } - HiLog::Debug(LABEL, "%{public}s end, pid : %{public}d", __func__, it->second); return it->second; } @@ -541,7 +532,6 @@ void ClientInfo::DestroyClientPid(const sptr &sensorClient) HiLog::Error(LABEL, "%{public}s cannot find client pid", __func__); return; } - HiLog::Debug(LABEL, "%{public}s end, pid : %{public}d", __func__, it->second); clientPidMap_.erase(it); } diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index b9eb2438..682e74da 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -236,8 +236,7 @@ ErrCode SensorService::SaveSubscriber(uint32_t sensorId, int64_t samplingPeriodN ErrCode SensorService::EnableSensor(uint32_t sensorId, int64_t samplingPeriodNs, int64_t maxReportDelayNs) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u, samplingPeriodNs : %{public}" - PRId64, __func__, sensorId, 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__); @@ -386,7 +385,7 @@ ErrCode SensorService::TransferDataChannel(const sptr &s ErrCode SensorService::DestroySensorChannel(sptr sensorClient) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + 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); @@ -405,7 +404,7 @@ ErrCode SensorService::DestroySensorChannel(sptr sensorClient) void SensorService::ProcessDeathObserver(const wptr &object) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; sptr client = object.promote(); if (client == nullptr) { HiLog::Error(LABEL, "%{public}s client cannot be null", __func__); @@ -424,7 +423,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; sptr client = iface_cast(sensorClient); clientDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); if (clientDeathObserver_ == nullptr) { @@ -437,7 +436,7 @@ void SensorService::RegisterClientDeathRecipient(sptr sensorClien void SensorService::UnregisterClientDeathRecipient(sptr sensorClient) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + CALL_LOG_ENTER; sptr client = iface_cast(sensorClient); clientDeathObserver_ = new (std::nothrow) DeathRecipientTemplate(*const_cast(this)); if (clientDeathObserver_ == nullptr) { @@ -450,7 +449,7 @@ void SensorService::UnregisterClientDeathRecipient(sptr sensorCli int32_t SensorService::Dump(int32_t fd, const std::vector &args) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + 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__); diff --git a/services/sensor/src/sensor_suspend_policy.cpp b/services/sensor/src/sensor_suspend_policy.cpp index 744d866a..a1c8dec1 100755 --- a/services/sensor/src/sensor_suspend_policy.cpp +++ b/services/sensor/src/sensor_suspend_policy.cpp @@ -102,8 +102,7 @@ ErrCode SensorSuspendPolicy::SaveSubscriber(uint32_t sensorId, int64_t samplingP ErrCode SensorSuspendPolicy::EnableSensor(uint32_t sensorId, int32_t pid, int64_t samplingPeriodNs, int64_t maxReportDelayNs) { - HiLog::Debug(LABEL, "%{public}s begin, sensorId : %{public}u, samplingPeriodNs : %{public}d", __func__, sensorId, - int32_t { samplingPeriodNs }); + 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__); -- Gitee