From 39907f3034a94ee21cfc3d93b1a68ad4992841e3 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Mon, 6 Nov 2023 09:20:07 +0000 Subject: [PATCH 1/5] update Signed-off-by: hellohyh001 --- frameworks/native/src/sensor_data_channel.cpp | 3 ++- services/src/sensor_data_processer.cpp | 3 +++ utils/common/include/sensor_utils.h | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frameworks/native/src/sensor_data_channel.cpp b/frameworks/native/src/sensor_data_channel.cpp index dbbe7d8f..14af190e 100644 --- a/frameworks/native/src/sensor_data_channel.cpp +++ b/frameworks/native/src/sensor_data_channel.cpp @@ -27,6 +27,7 @@ using namespace OHOS::HiviewDFX; using namespace OHOS::AppExecFwk; namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "SensorDataChannel" }; +const std::string LISTENER_THREAD_NAME = "OS_SensorListenerThread"; } // namespace int32_t SensorDataChannel::CreateSensorDataChannel(DataChannelCB callBack, void *data) @@ -59,7 +60,7 @@ int32_t SensorDataChannel::InnerSensorDataChannel() auto listener = std::make_shared(); listener->SetChannel(this); if (eventHandler_ == nullptr) { - auto myRunner = AppExecFwk::EventRunner::Create(true); + auto myRunner = AppExecFwk::EventRunner::Create(LISTENER_THREAD_NAME); CHKPR(myRunner, ERROR); eventHandler_ = std::make_shared(myRunner); } diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp index 48258d4e..2204ea1e 100644 --- a/services/src/sensor_data_processer.cpp +++ b/services/src/sensor_data_processer.cpp @@ -23,6 +23,7 @@ #include "securec.h" #include "sensor_basic_data_channel.h" #include "sensor_errors.h" +#include "sensor_utils.h" #include "system_ability_definition.h" namespace OHOS { @@ -31,6 +32,7 @@ using namespace OHOS::HiviewDFX; namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "SensorDataProcesser" }; +const std::string SENSOR_REPORT_THREAD_NAME = "OS_SensorReportThread"; } // namespace SensorDataProcesser::SensorDataProcesser(const std::unordered_map &sensorMap) @@ -291,6 +293,7 @@ int32_t SensorDataProcesser::SendEvents(sptr &channel, S int32_t SensorDataProcesser::DataThread(sptr dataProcesser, sptr dataCallback) { CALL_LOG_ENTER; + SetThreadName(SENSOR_REPORT_THREAD_NAME); do { if (dataProcesser->ProcessEvents(dataCallback) == INVALID_POINTER) { SEN_HILOGE("Callback cannot be null"); diff --git a/utils/common/include/sensor_utils.h b/utils/common/include/sensor_utils.h index c37d2ca1..6614c4f2 100644 --- a/utils/common/include/sensor_utils.h +++ b/utils/common/include/sensor_utils.h @@ -16,6 +16,8 @@ #ifndef SENSOR_UTILS_H #define SENSOR_UTILS_H +#include + namespace OHOS { namespace Sensors { @@ -25,6 +27,10 @@ bool IsEqual(const T &left, const T &right) return std::abs(left - right) <= std::numeric_limits::epsilon(); } +void SetThreadName(const std::string &name) +{ + prctl(PR_SET_NAME, name.c_str()); +} } // namespace Sensors } // namespace OHOS #endif // SENSOR_UTILS_H -- Gitee From 9440808eb4f0321e6675d3660c04e79e2969ea52 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Mon, 6 Nov 2023 09:22:51 +0000 Subject: [PATCH 2/5] update Signed-off-by: hellohyh001 --- frameworks/native/src/sensor_data_channel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/src/sensor_data_channel.cpp b/frameworks/native/src/sensor_data_channel.cpp index 14af190e..1331daf5 100644 --- a/frameworks/native/src/sensor_data_channel.cpp +++ b/frameworks/native/src/sensor_data_channel.cpp @@ -96,7 +96,7 @@ int32_t SensorDataChannel::AddFdListener(int32_t fd, ReceiveMessageFun receiveMe disconnect_ = disconnect; std::lock_guard eventRunnerLock(eventRunnerMutex_); if (eventHandler_ == nullptr) { - auto myRunner = AppExecFwk::EventRunner::Create(true); + auto myRunner = AppExecFwk::EventRunner::Create(LISTENER_THREAD_NAME); CHKPR(myRunner, ERROR); eventHandler_ = std::make_shared(myRunner); } -- Gitee From e557b794e0058c5fb590192c93bf7219a30300fb Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 7 Nov 2023 06:46:06 +0000 Subject: [PATCH 3/5] update Signed-off-by: hellohyh001 --- frameworks/native/src/sensor_data_channel.cpp | 2 +- services/src/sensor_data_processer.cpp | 5 +++-- utils/common/include/sensor_utils.h | 8 -------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/frameworks/native/src/sensor_data_channel.cpp b/frameworks/native/src/sensor_data_channel.cpp index 1331daf5..76588289 100644 --- a/frameworks/native/src/sensor_data_channel.cpp +++ b/frameworks/native/src/sensor_data_channel.cpp @@ -27,7 +27,7 @@ using namespace OHOS::HiviewDFX; using namespace OHOS::AppExecFwk; namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "SensorDataChannel" }; -const std::string LISTENER_THREAD_NAME = "OS_SensorListenerThread"; +const std::string LISTENER_THREAD_NAME = "OS_SenConsumer"; } // namespace int32_t SensorDataChannel::CreateSensorDataChannel(DataChannelCB callBack, void *data) diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp index 2204ea1e..dc3502eb 100644 --- a/services/src/sensor_data_processer.cpp +++ b/services/src/sensor_data_processer.cpp @@ -15,6 +15,7 @@ #include "sensor_data_processer.h" +#include #include #include @@ -32,7 +33,7 @@ using namespace OHOS::HiviewDFX; namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "SensorDataProcesser" }; -const std::string SENSOR_REPORT_THREAD_NAME = "OS_SensorReportThread"; +const std::string SENSOR_REPORT_THREAD_NAME = "OS_SenProducer"; } // namespace SensorDataProcesser::SensorDataProcesser(const std::unordered_map &sensorMap) @@ -293,7 +294,7 @@ int32_t SensorDataProcesser::SendEvents(sptr &channel, S int32_t SensorDataProcesser::DataThread(sptr dataProcesser, sptr dataCallback) { CALL_LOG_ENTER; - SetThreadName(SENSOR_REPORT_THREAD_NAME); + prctl(PR_SET_NAME, SENSOR_REPORT_THREAD_NAME.c_str()); do { if (dataProcesser->ProcessEvents(dataCallback) == INVALID_POINTER) { SEN_HILOGE("Callback cannot be null"); diff --git a/utils/common/include/sensor_utils.h b/utils/common/include/sensor_utils.h index 6614c4f2..3d59a1ed 100644 --- a/utils/common/include/sensor_utils.h +++ b/utils/common/include/sensor_utils.h @@ -15,9 +15,6 @@ #ifndef SENSOR_UTILS_H #define SENSOR_UTILS_H - -#include - namespace OHOS { namespace Sensors { @@ -26,11 +23,6 @@ bool IsEqual(const T &left, const T &right) { return std::abs(left - right) <= std::numeric_limits::epsilon(); } - -void SetThreadName(const std::string &name) -{ - prctl(PR_SET_NAME, name.c_str()); -} } // namespace Sensors } // namespace OHOS #endif // SENSOR_UTILS_H -- Gitee From 40385f89fec647826ade6127ba8d09fc474fab4a Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 7 Nov 2023 06:47:59 +0000 Subject: [PATCH 4/5] update Signed-off-by: hellohyh001 --- services/src/sensor_data_processer.cpp | 1 - utils/common/include/sensor_utils.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp index dc3502eb..34486f01 100644 --- a/services/src/sensor_data_processer.cpp +++ b/services/src/sensor_data_processer.cpp @@ -24,7 +24,6 @@ #include "securec.h" #include "sensor_basic_data_channel.h" #include "sensor_errors.h" -#include "sensor_utils.h" #include "system_ability_definition.h" namespace OHOS { diff --git a/utils/common/include/sensor_utils.h b/utils/common/include/sensor_utils.h index 3d59a1ed..c37d2ca1 100644 --- a/utils/common/include/sensor_utils.h +++ b/utils/common/include/sensor_utils.h @@ -15,6 +15,7 @@ #ifndef SENSOR_UTILS_H #define SENSOR_UTILS_H + namespace OHOS { namespace Sensors { @@ -23,6 +24,7 @@ bool IsEqual(const T &left, const T &right) { return std::abs(left - right) <= std::numeric_limits::epsilon(); } + } // namespace Sensors } // namespace OHOS #endif // SENSOR_UTILS_H -- Gitee From ab65bfe285e68935ae50459896fb75dec51e159f Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 7 Nov 2023 07:09:57 +0000 Subject: [PATCH 5/5] update Signed-off-by: hellohyh001 --- services/hdi_connection/hardware/src/hdi_service_impl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/hdi_connection/hardware/src/hdi_service_impl.cpp b/services/hdi_connection/hardware/src/hdi_service_impl.cpp index e3eb8e45..79f0f33b 100644 --- a/services/hdi_connection/hardware/src/hdi_service_impl.cpp +++ b/services/hdi_connection/hardware/src/hdi_service_impl.cpp @@ -16,12 +16,11 @@ #include #include +#include #include - #include #include "sensor_errors.h" - namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; @@ -31,6 +30,7 @@ constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "HdiServiceImpl" }; constexpr int64_t SAMPLING_INTERVAL_NS = 200000000; constexpr float TARGET_SUM = 9.8F * 9.8F; constexpr float MAX_RANGE = 9999.0F; +const std::string SENSOR_PRODUCE_THREAD_NAME = "OS_SenMock"; std::vector g_sensorInfos = { {"sensor_test", "default", "1.0.0", "1.0.0", 1, 1, 9999.0, 0.000001, 23.0, 100000000, 1000000000}, }; @@ -169,6 +169,7 @@ int32_t HdiServiceImpl::GetSensorList(std::vector &sensorList) void HdiServiceImpl::DataReportThread() { CALL_LOG_ENTER; + prctl(PR_SET_NAME, SENSOR_PRODUCE_THREAD_NAME.c_str()); while (true) { GenerateEvent(); std::this_thread::sleep_for(std::chrono::nanoseconds(samplingInterval_)); -- Gitee