diff --git a/services/hdi_connection/adapter/src/hdi_connection.cpp b/services/hdi_connection/adapter/src/hdi_connection.cpp old mode 100755 new mode 100644 index c5573b9c11c311901ebb7b0ede4cc25aa83014be..f6cd5ed9613f3f0acb1db0c78bbc2d332798a434 --- a/services/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/hdi_connection/adapter/src/hdi_connection.cpp @@ -33,8 +33,8 @@ using OHOS::HDI::Sensor::V1_1::HdfSensorInformation; namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SENSOR_LOG_DOMAIN, "HdiConnection" }; sptr g_sensorInterface = nullptr; -sptr eventCallback_ = nullptr; -std::map sensorBasicInfoMap_; +sptr g_eventCallback = nullptr; +std::map g_sensorBasicInfoMap; std::mutex g_sensorBasicInfoMutex; constexpr int32_t GET_HDI_SERVICE_COUNT = 5; constexpr uint32_t WAIT_MS = 200; @@ -51,8 +51,8 @@ int32_t HdiConnection::ConnectHdi() g_sensorInterface = ISensorInterface::Get(); if (g_sensorInterface != nullptr) { SEN_HILOGI("Connect v1_1 hdi success"); - eventCallback_ = new (std::nothrow) SensorEventCallback(); - CHKPR(eventCallback_, ERR_NO_INIT); + g_eventCallback = new (std::nothrow) SensorEventCallback(); + CHKPR(g_eventCallback, ERR_NO_INIT); RegisterHdiDeathRecipient(); return ERR_OK; } @@ -162,7 +162,7 @@ int32_t HdiConnection::RegisterDataReport(ReportDataCb cb, sptrRegister(0, eventCallback_); + int32_t ret = g_sensorInterface->Register(0, g_eventCallback); if (ret != 0) { HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "RegisterDataReport", "ERROR_CODE", ret); @@ -178,14 +178,14 @@ int32_t HdiConnection::DestroyHdiConnection() { CALL_LOG_ENTER; CHKPR(g_sensorInterface, ERR_NO_INIT); - int32_t ret = g_sensorInterface->Unregister(0, eventCallback_); + int32_t ret = g_sensorInterface->Unregister(0, g_eventCallback); if (ret != 0) { HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DestroyHdiConnection", "ERROR_CODE", ret); SEN_HILOGE("Unregister is failed"); return ret; } - eventCallback_ = nullptr; + g_eventCallback = nullptr; UnregisterHdiDeathRecipient(); return ERR_OK; } @@ -212,26 +212,26 @@ void HdiConnection::UpdateSensorBasicInfo(int32_t sensorId, int64_t samplingPeri SensorBasicInfo sensorBasicInfo; sensorBasicInfo.SetSamplingPeriodNs(samplingPeriodNs); sensorBasicInfo.SetMaxReportDelayNs(maxReportDelayNs); - sensorBasicInfoMap_[sensorId] = sensorBasicInfo; + g_sensorBasicInfoMap[sensorId] = sensorBasicInfo; } void HdiConnection::SetSensorBasicInfoState(int32_t sensorId, bool state) { std::lock_guard sensorInfoLock(g_sensorBasicInfoMutex); - auto it = sensorBasicInfoMap_.find(sensorId); - if (it == sensorBasicInfoMap_.end()) { + auto it = g_sensorBasicInfoMap.find(sensorId); + if (it == g_sensorBasicInfoMap.end()) { SEN_HILOGW("Should set batch first"); return; } - sensorBasicInfoMap_[sensorId].SetSensorState(state); + g_sensorBasicInfoMap[sensorId].SetSensorState(state); } void HdiConnection::DeleteSensorBasicInfoState(int32_t sensorId) { std::lock_guard sensorInfoLock(g_sensorBasicInfoMutex); - auto it = sensorBasicInfoMap_.find(sensorId); - if (it != sensorBasicInfoMap_.end()) { - sensorBasicInfoMap_.erase(sensorId); + auto it = g_sensorBasicInfoMap.find(sensorId); + if (it != g_sensorBasicInfoMap.end()) { + g_sensorBasicInfoMap.erase(sensorId); } } @@ -261,7 +261,7 @@ void HdiConnection::ProcessDeathObserver(const wptr &object) CHKPV(hdiService); CHKPV(hdiDeathObserver_); hdiService->RemoveDeathRecipient(hdiDeathObserver_); - eventCallback_ = nullptr; + g_eventCallback = nullptr; Reconnect(); } @@ -273,7 +273,7 @@ void HdiConnection::Reconnect() SEN_HILOGE("Failed to get an instance of hdi service"); return; } - ret = g_sensorInterface->Register(0, eventCallback_); + ret = g_sensorInterface->Register(0, g_eventCallback); if (ret != 0) { SEN_HILOGE("Register callback fail"); return; @@ -285,7 +285,7 @@ void HdiConnection::Reconnect() return; } std::lock_guard sensorInfoLock(g_sensorBasicInfoMutex); - for (const auto &sensorInfo: sensorBasicInfoMap_) { + for (const auto &sensorInfo: g_sensorBasicInfoMap) { int32_t sensorTypeId = sensorInfo.first; SensorBasicInfo info = sensorInfo.second; if (info.GetSensorState() != true) {