diff --git a/frameworks/native/src/sensor_data_channel.cpp b/frameworks/native/src/sensor_data_channel.cpp index dbbe7d8fa211d9dd582f38614976221a7719037e..765882893bcf1991aad6dd3ec5ab89d2a5d8ee77 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_SenConsumer"; } // 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); } @@ -95,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); } diff --git a/services/hdi_connection/hardware/src/hdi_service_impl.cpp b/services/hdi_connection/hardware/src/hdi_service_impl.cpp index e3eb8e451b657aee73abea18748ee0d751447694..79f0f33be83077973a98898e2837ffc21556e38a 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_)); diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp index 48258d4ef715eb04ef5d3f68af93a6a8396bc3a6..34486f01db146cfb5ecc6e81dee5848ba0e88722 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 @@ -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_SenProducer"; } // 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; + prctl(PR_SET_NAME, SENSOR_REPORT_THREAD_NAME.c_str()); do { if (dataProcesser->ProcessEvents(dataCallback) == INVALID_POINTER) { SEN_HILOGE("Callback cannot be null");