From 9a9fc9b2b1e5bbd43ed5a3b18b459bce0f3cd0a9 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Tue, 24 Sep 2024 17:07:41 +0800 Subject: [PATCH 1/3] Add miscdevice difference Signed-off-by: cff-gite Change-Id: If755793d8a295c36c629450522958e15da7c0382 --- .../js/napi/vibrator/src/vibrator_js.cpp | 1 - .../vibrator/src/vibrator_service_client.cpp | 2 +- services/miscdevice_service/BUILD.gn | 4 ++-- .../src/custom_vibration_matcher.cpp | 24 +++++++++---------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/frameworks/js/napi/vibrator/src/vibrator_js.cpp b/frameworks/js/napi/vibrator/src/vibrator_js.cpp index e1f76a3..829716b 100644 --- a/frameworks/js/napi/vibrator/src/vibrator_js.cpp +++ b/frameworks/js/napi/vibrator/src/vibrator_js.cpp @@ -262,7 +262,6 @@ static napi_value VibrateEffect(napi_env env, napi_value args[], size_t argc) static napi_value StartVibrate(napi_env env, napi_callback_info info) { - CALL_LOG_ENTER; CHKPP(env); CHKPP(info); size_t argc = 3; diff --git a/frameworks/native/vibrator/src/vibrator_service_client.cpp b/frameworks/native/vibrator/src/vibrator_service_client.cpp index b9e34a2..5694af5 100644 --- a/frameworks/native/vibrator/src/vibrator_service_client.cpp +++ b/frameworks/native/vibrator/src/vibrator_service_client.cpp @@ -231,7 +231,7 @@ bool VibratorServiceClient::IsHdHapticSupported() CALL_LOG_ENTER; int32_t ret = InitServiceClient(); if (ret != ERR_OK) { - MISC_HILOGD("InitServiceClient failed, ret:%{public}d", ret); + MISC_HILOGE("InitServiceClient failed, ret:%{public}d", ret); return MISC_NATIVE_GET_SERVICE_ERR; } return capacity_.isSupportHdHaptic; diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index 7d17385..e5c75c4 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -63,8 +63,8 @@ ohos_shared_library("libmiscdevice_service") { "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", - "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", + "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_core", "cJSON:cjson", "c_utils:utils", @@ -152,8 +152,8 @@ ohos_static_library("libmiscdevice_service_static") { "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", - "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", + "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_core", "cJSON:cjson", "c_utils:utils", diff --git a/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp b/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp index 5c3d631..897de60 100644 --- a/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp +++ b/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp @@ -57,9 +57,9 @@ CustomVibrationMatcher::CustomVibrationMatcher() return; } if (!hdfWaveInfos_.empty()) { - for (auto it = hdfWaveInfos_.begin(); it != hdfWaveInfos_.end(); ++it) { + for (const auto &info : hdfWaveInfos_) { MISC_HILOGI("waveId:%{public}d, intensity:%{public}f, frequency:%{public}f, duration:%{public}d", - it->waveId, it->intensity, it->frequency, it->duration); + info.waveId, info.intensity, info.frequency, info.duration); } NormalizedWaveInfo(); } @@ -72,10 +72,10 @@ void CustomVibrationMatcher::NormalizedWaveInfo() float maxIntensity = firstIt->intensity; float minFrequency = firstIt->frequency; float maxFrequency = firstIt->frequency; - for (auto it = hdfWaveInfos_.begin(); it != hdfWaveInfos_.end(); ++it) { - maxIntensity = (maxIntensity > it->intensity) ? maxIntensity : it->intensity; - minFrequency = (minFrequency < it->frequency) ? minFrequency : it->frequency; - maxFrequency = (maxFrequency > it->frequency) ? maxFrequency : it->frequency; + for (const auto &info : hdfWaveInfos_) { + maxIntensity = (maxIntensity > info.intensity) ? maxIntensity : info.intensity; + minFrequency = (minFrequency < info.frequency) ? minFrequency : info.frequency; + maxFrequency = (maxFrequency > info.frequency) ? maxFrequency : info.frequency; } float intensityEqualValue = maxIntensity / INTENSITY_MAX; @@ -84,16 +84,16 @@ void CustomVibrationMatcher::NormalizedWaveInfo() MISC_HILOGE("The equal value of intensity or frequency is zero"); return; } - for (auto it = hdfWaveInfos_.begin(); it != hdfWaveInfos_.end(); ++it) { + for (const auto &info : hdfWaveInfos_) { std::vector normalizedValue; - normalizedValue.push_back(static_cast(it->intensity / intensityEqualValue)); - normalizedValue.push_back(static_cast((it->frequency - minFrequency) / frequencyEqualValue)); - normalizedValue.push_back(it->duration); + normalizedValue.push_back(static_cast(info.intensity / intensityEqualValue)); + normalizedValue.push_back(static_cast((info.frequency - minFrequency) / frequencyEqualValue)); + normalizedValue.push_back(info.duration); waveInfos_[it->waveId] = normalizedValue; } - for (auto it = waveInfos_.begin(); it != waveInfos_.end(); ++it) { + for (const auto &info : hdfWaveInfos_) { MISC_HILOGI("waveId:%{public}d, intensity:%{public}d, frequency:%{public}d, duration:%{public}d", - it->first, it->second[0], it->second[1], it->second[WAVE_INFO_DIMENSION - 1]); + info.first, info.second[0], info.second[1], info.second[WAVE_INFO_DIMENSION - 1]); } } -- Gitee From 36effd6d3bba550857228dbd3d5e39d1798c2bc6 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 26 Sep 2024 14:59:01 +0800 Subject: [PATCH 2/3] Signed-off-by: cff-gite Change-Id: Id0531426032ca4563220c8bfbaf58f440d91542f --- services/miscdevice_service/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index e5c75c4..7d17385 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -63,8 +63,8 @@ ohos_shared_library("libmiscdevice_service") { "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", - "bundle_framework:appexecfwk_base", "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "cJSON:cjson", "c_utils:utils", @@ -152,8 +152,8 @@ ohos_static_library("libmiscdevice_service_static") { "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", - "bundle_framework:appexecfwk_base", "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "cJSON:cjson", "c_utils:utils", -- Gitee From 6538240ad9f3555e3d074b9c0ba51d94a6efc5b1 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sun, 29 Sep 2024 11:14:06 +0800 Subject: [PATCH 3/3] Add miscdevice difference Signed-off-by: cff-gite Change-Id: I2f46b2a8d160c1f0f8617cfd7edada18d782bd80 --- .../haptic_matcher/src/custom_vibration_matcher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp b/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp index 897de60..6b044bd 100644 --- a/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp +++ b/services/miscdevice_service/haptic_matcher/src/custom_vibration_matcher.cpp @@ -89,9 +89,9 @@ void CustomVibrationMatcher::NormalizedWaveInfo() normalizedValue.push_back(static_cast(info.intensity / intensityEqualValue)); normalizedValue.push_back(static_cast((info.frequency - minFrequency) / frequencyEqualValue)); normalizedValue.push_back(info.duration); - waveInfos_[it->waveId] = normalizedValue; + waveInfos_[info.waveId] = normalizedValue; } - for (const auto &info : hdfWaveInfos_) { + for (const auto &info : waveInfos_) { MISC_HILOGI("waveId:%{public}d, intensity:%{public}d, frequency:%{public}d, duration:%{public}d", info.first, info.second[0], info.second[1], info.second[WAVE_INFO_DIMENSION - 1]); } -- Gitee