From 8f1e982c94018c11c18ff3c91c42e1c8e9a76561 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Wed, 25 Oct 2023 07:59:59 +0000 Subject: [PATCH 1/7] =?UTF-8?q?sensor=20CFI=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: I19a5748d560ce10fdf25b05b67021e385eba5700 --- frameworks/js/napi/BUILD.gn | 5 +++++ frameworks/native/BUILD.gn | 6 ++++++ services/BUILD.gn | 12 ++++++++++++ utils/common/BUILD.gn | 6 ++++++ utils/ipc/BUILD.gn | 6 ++++++ 5 files changed, 35 insertions(+) mode change 100755 => 100644 frameworks/native/BUILD.gn diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn index 26d9e80d..17402e2e 100644 --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -27,6 +27,11 @@ ohos_shared_library("libsensor") { "APP_LOG_TAG = \"sensorJs\"", "LOG_DOMAIN = 0xD002700", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } sources = [ "src/sensor_js.cpp", "src/sensor_napi_error.cpp", diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn old mode 100755 new mode 100644 index 7f1a8754..e886c68b --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -33,6 +33,12 @@ ohos_shared_library("libsensor_native") { "$SUBSYSTEM_DIR/utils/ipc/include", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + defines = sensor_default_defines deps = [ diff --git a/services/BUILD.gn b/services/BUILD.gn index 6513d2d9..c2dc6623 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -35,6 +35,12 @@ ohos_shared_library("libsensor_service") { "$SUBSYSTEM_DIR/utils/ipc/include", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + defines = sensor_default_defines deps = [ @@ -103,6 +109,12 @@ ohos_shared_library("libsensor_service_static") { "$SUBSYSTEM_DIR/utils/ipc/include", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + defines = sensor_default_defines deps = [ diff --git a/utils/common/BUILD.gn b/utils/common/BUILD.gn index 91777c23..72d72942 100644 --- a/utils/common/BUILD.gn +++ b/utils/common/BUILD.gn @@ -31,6 +31,12 @@ ohos_shared_library("libsensor_utils") { "$SUBSYSTEM_DIR/utils/common/include", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", diff --git a/utils/ipc/BUILD.gn b/utils/ipc/BUILD.gn index 327089e5..c948b9a3 100644 --- a/utils/ipc/BUILD.gn +++ b/utils/ipc/BUILD.gn @@ -28,6 +28,12 @@ ohos_shared_library("libsensor_ipc") { "$SUBSYSTEM_DIR/utils/ipc/include", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + defines = sensor_default_defines if (rust_socket_ipc) { -- Gitee From 9495b37310a5238d750dbc65193d08fdf9267c06 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Oct 2023 03:03:00 +0000 Subject: [PATCH 2/7] =?UTF-8?q?sensor=20CFI=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: I16996ca3f62092e917eacc3f47e7d21768d77188 --- services/src/sensor_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/sensor_service.cpp b/services/src/sensor_service.cpp index 6ada9b6f..f934a237 100644 --- a/services/src/sensor_service.cpp +++ b/services/src/sensor_service.cpp @@ -84,7 +84,7 @@ void SensorService::OnStart() if (!InitSensorPolicy()) { SEN_HILOGE("Init sensor policy error"); } - if (!SystemAbility::Publish(SensorDelayedSpSingleton::GetInstance())) { + if (!SystemAbility::Publish(this)) { SEN_HILOGE("Publish SensorService error"); return; } -- Gitee From 2c25cc159676e737908a53c3e7bb111dafcd48d2 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Oct 2023 06:01:40 +0000 Subject: [PATCH 3/7] =?UTF-8?q?sensor=20CFI=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: Ib2ea0b5cdfaec028d1bd6fd9b2fffa39a4341e80 --- frameworks/js/napi/BUILD.gn | 2 +- frameworks/native/BUILD.gn | 2 +- services/BUILD.gn | 4 ++-- services/src/sensor_service.cpp | 2 +- utils/common/BUILD.gn | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 100755 frameworks/js/napi/BUILD.gn mode change 100644 => 100755 frameworks/native/BUILD.gn mode change 100644 => 100755 services/BUILD.gn mode change 100644 => 100755 services/src/sensor_service.cpp mode change 100644 => 100755 utils/common/BUILD.gn diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn old mode 100644 new mode 100755 index 17402e2e..691f9ce5 --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -30,7 +30,7 @@ ohos_shared_library("libsensor") { sanitize = { cfi = true cfi_cross_dso = true - debug = false + debug = true } sources = [ "src/sensor_js.cpp", diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn old mode 100644 new mode 100755 index e886c68b..7aa8c64d --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -36,7 +36,7 @@ ohos_shared_library("libsensor_native") { sanitize = { cfi = true cfi_cross_dso = true - debug = false + debug = true } defines = sensor_default_defines diff --git a/services/BUILD.gn b/services/BUILD.gn old mode 100644 new mode 100755 index c2dc6623..e3140007 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -38,7 +38,7 @@ ohos_shared_library("libsensor_service") { sanitize = { cfi = true cfi_cross_dso = true - debug = false + debug = true } defines = sensor_default_defines @@ -112,7 +112,7 @@ ohos_shared_library("libsensor_service_static") { sanitize = { cfi = true cfi_cross_dso = true - debug = false + debug = true } defines = sensor_default_defines diff --git a/services/src/sensor_service.cpp b/services/src/sensor_service.cpp old mode 100644 new mode 100755 index f934a237..6ada9b6f --- a/services/src/sensor_service.cpp +++ b/services/src/sensor_service.cpp @@ -84,7 +84,7 @@ void SensorService::OnStart() if (!InitSensorPolicy()) { SEN_HILOGE("Init sensor policy error"); } - if (!SystemAbility::Publish(this)) { + if (!SystemAbility::Publish(SensorDelayedSpSingleton::GetInstance())) { SEN_HILOGE("Publish SensorService error"); return; } diff --git a/utils/common/BUILD.gn b/utils/common/BUILD.gn old mode 100644 new mode 100755 index 72d72942..8b2faee8 --- a/utils/common/BUILD.gn +++ b/utils/common/BUILD.gn @@ -34,7 +34,7 @@ ohos_shared_library("libsensor_utils") { sanitize = { cfi = true cfi_cross_dso = true - debug = false + debug = true } external_deps = [ -- Gitee From dd3f881bc9ead5cf3ad0774f697f96576fb344af Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Oct 2023 06:03:26 +0000 Subject: [PATCH 4/7] =?UTF-8?q?sensor=20CFI=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: Ibe237cb871153c484597f4e53bf4b47a6874fb7a --- utils/ipc/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 utils/ipc/BUILD.gn diff --git a/utils/ipc/BUILD.gn b/utils/ipc/BUILD.gn old mode 100644 new mode 100755 index c948b9a3..89be18ae --- a/utils/ipc/BUILD.gn +++ b/utils/ipc/BUILD.gn @@ -31,7 +31,7 @@ ohos_shared_library("libsensor_ipc") { sanitize = { cfi = true cfi_cross_dso = true - debug = false + debug = true } defines = sensor_default_defines -- Gitee From c77cea2a6a7bacb1f6f37c6f0f7cd7434d28f755 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Oct 2023 06:47:47 +0000 Subject: [PATCH 5/7] =?UTF-8?q?sensor=20CFI=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: I5fc4c407c34b164d26c08f6691b109d7f1a30bd4 --- frameworks/js/napi/BUILD.gn | 2 +- frameworks/native/BUILD.gn | 2 +- services/BUILD.gn | 4 ++-- utils/common/BUILD.gn | 2 +- utils/ipc/BUILD.gn | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) mode change 100755 => 100644 frameworks/js/napi/BUILD.gn mode change 100755 => 100644 frameworks/native/BUILD.gn mode change 100755 => 100644 services/BUILD.gn mode change 100755 => 100644 utils/common/BUILD.gn mode change 100755 => 100644 utils/ipc/BUILD.gn diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn old mode 100755 new mode 100644 index 691f9ce5..17402e2e --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -30,7 +30,7 @@ ohos_shared_library("libsensor") { sanitize = { cfi = true cfi_cross_dso = true - debug = true + debug = false } sources = [ "src/sensor_js.cpp", diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn old mode 100755 new mode 100644 index 7aa8c64d..e886c68b --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -36,7 +36,7 @@ ohos_shared_library("libsensor_native") { sanitize = { cfi = true cfi_cross_dso = true - debug = true + debug = false } defines = sensor_default_defines diff --git a/services/BUILD.gn b/services/BUILD.gn old mode 100755 new mode 100644 index e3140007..c2dc6623 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -38,7 +38,7 @@ ohos_shared_library("libsensor_service") { sanitize = { cfi = true cfi_cross_dso = true - debug = true + debug = false } defines = sensor_default_defines @@ -112,7 +112,7 @@ ohos_shared_library("libsensor_service_static") { sanitize = { cfi = true cfi_cross_dso = true - debug = true + debug = false } defines = sensor_default_defines diff --git a/utils/common/BUILD.gn b/utils/common/BUILD.gn old mode 100755 new mode 100644 index 8b2faee8..72d72942 --- a/utils/common/BUILD.gn +++ b/utils/common/BUILD.gn @@ -34,7 +34,7 @@ ohos_shared_library("libsensor_utils") { sanitize = { cfi = true cfi_cross_dso = true - debug = true + debug = false } external_deps = [ diff --git a/utils/ipc/BUILD.gn b/utils/ipc/BUILD.gn old mode 100755 new mode 100644 index 89be18ae..c948b9a3 --- a/utils/ipc/BUILD.gn +++ b/utils/ipc/BUILD.gn @@ -31,7 +31,7 @@ ohos_shared_library("libsensor_ipc") { sanitize = { cfi = true cfi_cross_dso = true - debug = true + debug = false } defines = sensor_default_defines -- Gitee From 65092e9e16f7efbea362b57958fc6fbae84d7262 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Oct 2023 08:34:35 +0000 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: I2cb7aa5499a0000855a4e85ab5c6e472513cc159 --- frameworks/js/napi/BUILD.gn | 5 --- frameworks/native/BUILD.gn | 6 ---- services/BUILD.gn | 14 +------- .../adapter/src/hdi_connection.cpp | 34 +++++++++---------- utils/common/BUILD.gn | 8 +---- utils/ipc/BUILD.gn | 6 ---- 6 files changed, 19 insertions(+), 54 deletions(-) mode change 100755 => 100644 services/hdi_connection/adapter/src/hdi_connection.cpp diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn index 17402e2e..26d9e80d 100644 --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -27,11 +27,6 @@ ohos_shared_library("libsensor") { "APP_LOG_TAG = \"sensorJs\"", "LOG_DOMAIN = 0xD002700", ] - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } sources = [ "src/sensor_js.cpp", "src/sensor_napi_error.cpp", diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn index e886c68b..7f1a8754 100644 --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -33,12 +33,6 @@ ohos_shared_library("libsensor_native") { "$SUBSYSTEM_DIR/utils/ipc/include", ] - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - defines = sensor_default_defines deps = [ diff --git a/services/BUILD.gn b/services/BUILD.gn index c2dc6623..f7b79a76 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -34,13 +34,7 @@ ohos_shared_library("libsensor_service") { "$SUBSYSTEM_DIR/utils/common/include", "$SUBSYSTEM_DIR/utils/ipc/include", ] - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - + defines = sensor_default_defines deps = [ @@ -109,12 +103,6 @@ ohos_shared_library("libsensor_service_static") { "$SUBSYSTEM_DIR/utils/ipc/include", ] - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - defines = sensor_default_defines deps = [ 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 46e77eaf..b0049805 --- 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 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() sensorInterface_ = ISensorInterface::Get(); if (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 = 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(sensorInterface_, ERR_NO_INIT); - int32_t ret = sensorInterface_->Unregister(0, eventCallback_); + int32_t ret = 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 = sensorInterface_->Register(0, eventCallback_); + ret = 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) { diff --git a/utils/common/BUILD.gn b/utils/common/BUILD.gn index 72d72942..a47f1b2c 100644 --- a/utils/common/BUILD.gn +++ b/utils/common/BUILD.gn @@ -30,13 +30,7 @@ ohos_shared_library("libsensor_utils") { "$SUBSYSTEM_DIR/frameworks/native/include", "$SUBSYSTEM_DIR/utils/common/include", ] - - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - + external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", diff --git a/utils/ipc/BUILD.gn b/utils/ipc/BUILD.gn index c948b9a3..327089e5 100644 --- a/utils/ipc/BUILD.gn +++ b/utils/ipc/BUILD.gn @@ -28,12 +28,6 @@ ohos_shared_library("libsensor_ipc") { "$SUBSYSTEM_DIR/utils/ipc/include", ] - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - defines = sensor_default_defines if (rust_socket_ipc) { -- Gitee From f5448325453888d896b24131768a9708b2ad202e Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Oct 2023 08:39:20 +0000 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite Change-Id: Ic62562cf276b848f267eab880c6f8bae3e6ad176 --- services/BUILD.gn | 2 +- utils/common/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index f7b79a76..6513d2d9 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -34,7 +34,7 @@ ohos_shared_library("libsensor_service") { "$SUBSYSTEM_DIR/utils/common/include", "$SUBSYSTEM_DIR/utils/ipc/include", ] - + defines = sensor_default_defines deps = [ diff --git a/utils/common/BUILD.gn b/utils/common/BUILD.gn index a47f1b2c..91777c23 100644 --- a/utils/common/BUILD.gn +++ b/utils/common/BUILD.gn @@ -30,7 +30,7 @@ ohos_shared_library("libsensor_utils") { "$SUBSYSTEM_DIR/frameworks/native/include", "$SUBSYSTEM_DIR/utils/common/include", ] - + external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", -- Gitee