From 65416eb9576d57a5aeed70e3e694bd84d41ee149 Mon Sep 17 00:00:00 2001 From: maan4 Date: Wed, 20 Aug 2025 12:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=BC=80=E5=85=B3=E5=85=B3?= =?UTF-8?q?=E9=97=ADmotion=E7=99=BD=E5=90=8D=E5=8D=95=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maan4 --- services/include/sensor_service.h | 1 + services/src/sensor_service.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/services/include/sensor_service.h b/services/include/sensor_service.h index 2252cb27..f3f3220e 100644 --- a/services/include/sensor_service.h +++ b/services/include/sensor_service.h @@ -100,6 +100,7 @@ private: bool IsSystemCalling(); bool IsNeedLoadMotionLib(); void SetCritical(); + void LoadMotionTransform(int32_t systemAbilityId); SensorServiceState state_; std::mutex serviceLock_; std::mutex sensorsMutex_; diff --git a/services/src/sensor_service.cpp b/services/src/sensor_service.cpp index 3cf324c4..8cff4272 100644 --- a/services/src/sensor_service.cpp +++ b/services/src/sensor_service.cpp @@ -82,6 +82,18 @@ std::string GetDmsDeviceStatus() return OHOS::system::GetParameter("persist.dms.device.status", "0"); } +bool IsCameraCorrectionEnable() +{ + std::string isEnable = OHOS::system::GetParameter("const.system.sensor_correction_enable", "0"); + int32_t correctionEnable = 0; + auto res = std::from_chars(isEnable.data(), isEnable.data() + isEnable.size(), correctionEnable); + if (res.ec != std::errc()) { + SEN_HILOGE("Failed to convert string %{public}s to number", isEnable.c_str()); + return false; + } + return correctionEnable != 0; +} + bool SensorService::IsNeedLoadMotionLib() { std::string supportDevice = OHOS::system::GetParameter("const.window.foldscreen.type", DEFAULTS_FOLD_TYPE); @@ -123,6 +135,15 @@ void SensorService::OnAddSystemAbility(int32_t systemAbilityId, const std::strin isAccessTokenServiceActive_ = true; } #endif // ACCESS_TOKEN_ENABLE + /* When sensor_correction_enable is true, the motion whitelist logic is not executed */ + if (!IsCameraCorrectionEnable()) { + LoadMotionTransform(systemAbilityId); + } +} + +void SensorService::LoadMotionTransform(int32_t systemAbilityId) +{ + SEN_HILOGI("LoadMotionTransform systemAbilityId:%{public}d", systemAbilityId); #ifdef MSDP_MOTION_ENABLE if (systemAbilityId == MSDP_MOTION_SERVICE_ID) { if (!IsNeedLoadMotionLib()) { -- Gitee