From fb042fe78c79d2add5dd85a75b515ed1f2dc12fb Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 21 Mar 2022 17:39:01 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/native/src/geomagnetic_field.cpp | 5 +++++ .../hdi_connection/interface/src/sensor_hdi_connection.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/interfaces/native/src/geomagnetic_field.cpp b/interfaces/native/src/geomagnetic_field.cpp index 1b7c0f2d..2b4e2eaa 100644 --- a/interfaces/native/src/geomagnetic_field.cpp +++ b/interfaces/native/src/geomagnetic_field.cpp @@ -213,6 +213,11 @@ void GeomagneticField::CalibrateGeocentricCoordinates(float latitude, float long float latRad = static_cast(sqrt(a2 * clat * clat + b2 * slat * slat)); geocentricLatitude = static_cast(atan(tlat * (latRad * altitudeKm + b2) / (latRad * altitudeKm + a2))); + + if ( longitude > 180 || longitude < -180 ){ + //添加错误日志 + return; + } geocentricLongitude = static_cast(ToRadians(longitude)); float radSq = altitudeKm * altitudeKm + 2 * altitudeKm diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index 78e63162..12a0a7d9 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -30,6 +30,10 @@ constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "Sens int32_t SensorHdiConnection::ConnectHdi() { iSensorHdiConnection_ = std::make_unique(); + if (iSensorHdiConnection_ == nullptr) { + HiLog::Error(LABEL, "%{public}s failed, iSensorHdiConnection_ cannot be null", __func__); + return; + } int32_t ret = connectHdiService(); if (ret != ERR_OK) { HiLog::Error(LABEL, "%{public}s connect hdi service failed, try to connect compatible connection", -- Gitee From 4980e308bfaad4fa24535c7c7efb63cdabba2483 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Mon, 21 Mar 2022 17:59:09 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../hdi_connection/interface/src/sensor_hdi_connection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index 12a0a7d9..3d060603 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -32,7 +32,7 @@ int32_t SensorHdiConnection::ConnectHdi() iSensorHdiConnection_ = std::make_unique(); if (iSensorHdiConnection_ == nullptr) { HiLog::Error(LABEL, "%{public}s failed, iSensorHdiConnection_ cannot be null", __func__); - return; + return OHOS::Sensors::ERROR; } int32_t ret = connectHdiService(); if (ret != ERR_OK) { -- Gitee From cc2c32c7e63a49132f23e7cf0a742349bceb7eb5 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 09:25:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- interfaces/native/src/geomagnetic_field.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/interfaces/native/src/geomagnetic_field.cpp b/interfaces/native/src/geomagnetic_field.cpp index 2b4e2eaa..1b7c0f2d 100644 --- a/interfaces/native/src/geomagnetic_field.cpp +++ b/interfaces/native/src/geomagnetic_field.cpp @@ -213,11 +213,6 @@ void GeomagneticField::CalibrateGeocentricCoordinates(float latitude, float long float latRad = static_cast(sqrt(a2 * clat * clat + b2 * slat * slat)); geocentricLatitude = static_cast(atan(tlat * (latRad * altitudeKm + b2) / (latRad * altitudeKm + a2))); - - if ( longitude > 180 || longitude < -180 ){ - //添加错误日志 - return; - } geocentricLongitude = static_cast(ToRadians(longitude)); float radSq = altitudeKm * altitudeKm + 2 * altitudeKm -- Gitee From bb9f9fa9c3b5850acd37142ea266a549e79e3858 Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 10:34:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../hdi_connection/interface/src/sensor_hdi_connection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index 3d060603..35486c6e 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -32,7 +32,7 @@ int32_t SensorHdiConnection::ConnectHdi() iSensorHdiConnection_ = std::make_unique(); if (iSensorHdiConnection_ == nullptr) { HiLog::Error(LABEL, "%{public}s failed, iSensorHdiConnection_ cannot be null", __func__); - return OHOS::Sensors::ERROR; + return ERROR; } int32_t ret = connectHdiService(); if (ret != ERR_OK) { -- Gitee From 7130cb2f5b46ed4f1f50c5d574793b1629ee067e Mon Sep 17 00:00:00 2001 From: li-yaoyao777 Date: Tue, 22 Mar 2022 10:36:27 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-yaoyao777 --- .../hdi_connection/interface/src/sensor_hdi_connection.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index 35486c6e..0d5c04fd 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; - namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "SensorHdiConnection" }; } -- Gitee