From c367c75b8af6caaf0f66771b5a966f81168351c1 Mon Sep 17 00:00:00 2001 From: wangwei30043812 Date: Sat, 16 Aug 2025 19:49:55 +0800 Subject: [PATCH 1/3] fix: Vibrator problem Signed-off-by: wangwei30043812 --- services/audio/src/audio_control_manager.cpp | 11 ++++------- .../src/call_voice_assistant_manager.cpp | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/services/audio/src/audio_control_manager.cpp b/services/audio/src/audio_control_manager.cpp index 30c5a88d..9126739b 100644 --- a/services/audio/src/audio_control_manager.cpp +++ b/services/audio/src/audio_control_manager.cpp @@ -464,13 +464,10 @@ void AudioControlManager::ProcessAudioWhenCallActive(sptr &callObjectP auto callRunningState = callObjectPtr->GetCallRunningState(); if (callRunningState == CallRunningState::CALL_RUNNING_STATE_ACTIVE || callRunningState == CallRunningState::CALL_RUNNING_STATE_RINGING) { - if ((callObjectPtr->GetCrsType() == CRS_TYPE || !CallObjectManager::HasIncomingCallCrsType()) && - !CallObjectManager::HasIncomingCallVideoRingType()) { - if (isCrsVibrating_ || isVideoRingVibrating_) { - DelayedSingleton::GetInstance()->StopVibrator(); - isCrsVibrating_ = false; - isVideoRingVibrating_ = false; - } + if (isCrsVibrating_ || isVideoRingVibrating_) { + DelayedSingleton::GetInstance()->StopVibrator(); + isCrsVibrating_ = false; + isVideoRingVibrating_ = false; } ProcessSoundtone(callObjectPtr); UpdateDeviceTypeForVideoOrSatelliteCall(); diff --git a/services/call_voice_assistant/src/call_voice_assistant_manager.cpp b/services/call_voice_assistant/src/call_voice_assistant_manager.cpp index 617d1750..f8d85c39 100644 --- a/services/call_voice_assistant/src/call_voice_assistant_manager.cpp +++ b/services/call_voice_assistant/src/call_voice_assistant_manager.cpp @@ -717,9 +717,8 @@ void VoiceAssistantRingSubscriber::OnReceiveEvent(const EventFwk::CommonEventDat CallAttributeInfo info; incomingCall->GetCallAttributeBaseInfo(info); DelayedSingleton::GetInstance()->ReportCallStateInfo(info); - } else { - DelayedSingleton::GetInstance()->PlayRingtone(); } + DelayedSingleton::GetInstance()->PlayRingtone(); } }); }; -- Gitee From f93fe2c928290203c93388941d59830b1742cfe4 Mon Sep 17 00:00:00 2001 From: wangwei30043812 Date: Sat, 16 Aug 2025 19:59:40 +0800 Subject: [PATCH 2/3] fix: Vibrator problem Signed-off-by: wangwei30043812 --- services/audio/include/audio_proxy.h | 1 + services/audio/src/audio_proxy.cpp | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/services/audio/include/audio_proxy.h b/services/audio/include/audio_proxy.h index 3a13c041..90917ae9 100644 --- a/services/audio/include/audio_proxy.h +++ b/services/audio/include/audio_proxy.h @@ -105,6 +105,7 @@ private: std::shared_ptr preferredDeviceCallback_; std::shared_ptr audioMicStateChangeCallback_; bool isWiredHeadsetConnected_ = false; + bool loopFlag_ = false; }; } // namespace Telephony } // namespace OHOS diff --git a/services/audio/src/audio_proxy.cpp b/services/audio/src/audio_proxy.cpp index 60bcf7b1..78665f94 100644 --- a/services/audio/src/audio_proxy.cpp +++ b/services/audio/src/audio_proxy.cpp @@ -48,6 +48,7 @@ const std::unordered_map EFFECT_ID_MAP = { const int32_t NO_DEVICE_VALID = 0; const int32_t RENDERER_FLAG = 0; +constexpr uint64_t LOOP_DURATION_2S = 2000 * 1000; const std::string LOCAL_DEVICE = "LocalDevice"; AudioProxy::AudioProxy() @@ -132,22 +133,26 @@ int32_t AudioProxy::StartVibrator() int32_t result = TELEPHONY_SUCCESS; #ifdef SUPPORT_VIBRATOR bool setUsageRet = Sensors::SetUsage(VIBRATOR_USAGE_MAP.at(type)); - bool setLoopRet = Sensors::SetLoopCount(LOOP_COUNT_MAP.at(type)); result = Sensors::StartVibrator(EFFECT_ID_MAP.at(type).c_str()); - TELEPHONY_LOGE("StartVibrator: setUsageRet %{public}d, setLoopRet %{public}d, startRet %{public}d", - setUsageRet, setLoopRet, result); + TELEPHONY_LOGI("setUsageRet %{public}d, result %{public}d", setUsageRet, result); + if (result == TELEPHONY_SUCCESS) { + loopFlag_ = true; + ffrt::submit(type, this { + while (loopFlag_) { + usleep(LOOP_DURATION_2S); + TELEPHONY_LOGI("result %{public}d", Sensors::StartVibrator(EFFECT_ID_MAP.at(type).c_str())); + } + TELEPHONY_LOGI("cancel result: %{public}d", Sensors::Cancel()); + }); + } #endif return result; } int32_t AudioProxy::StopVibrator() { - int32_t result = TELEPHONY_SUCCESS; -#ifdef SUPPORT_VIBRATOR - result = Sensors::Cancel(); - TELEPHONY_LOGE("StopVibrator: %{public}d", result); -#endif - return result; + loopFlag_ = false; + return TELEPHONY_SUCCESS; } int32_t AudioProxy::GetVolume(AudioStandard::AudioVolumeType audioVolumeType) -- Gitee From d15095d0ed2a6bd56d92272696813537c395dec0 Mon Sep 17 00:00:00 2001 From: wangwei30043812 Date: Sat, 16 Aug 2025 20:06:39 +0800 Subject: [PATCH 3/3] fix: Vibrator problem Signed-off-by: wangwei30043812 --- services/audio/src/audio_proxy.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/audio/src/audio_proxy.cpp b/services/audio/src/audio_proxy.cpp index 78665f94..f0271478 100644 --- a/services/audio/src/audio_proxy.cpp +++ b/services/audio/src/audio_proxy.cpp @@ -129,7 +129,7 @@ bool AudioProxy::SetEarpieceDevActive() int32_t AudioProxy::StartVibrator() { VibrationType type = VibrationType::VIBRATION_RINGTONE; - TELEPHONY_LOGE("StartVibrator: for vibration type %{public}d", type); + TELEPHONY_LOGI("StartVibrator: for vibration type %{public}d", type); int32_t result = TELEPHONY_SUCCESS; #ifdef SUPPORT_VIBRATOR bool setUsageRet = Sensors::SetUsage(VIBRATOR_USAGE_MAP.at(type)); @@ -137,7 +137,7 @@ int32_t AudioProxy::StartVibrator() TELEPHONY_LOGI("setUsageRet %{public}d, result %{public}d", setUsageRet, result); if (result == TELEPHONY_SUCCESS) { loopFlag_ = true; - ffrt::submit(type, this { + ffrt::submit([type, this]() { while (loopFlag_) { usleep(LOOP_DURATION_2S); TELEPHONY_LOGI("result %{public}d", Sensors::StartVibrator(EFFECT_ID_MAP.at(type).c_str())); @@ -151,6 +151,7 @@ int32_t AudioProxy::StartVibrator() int32_t AudioProxy::StopVibrator() { + TELEPHONY_LOGI("stop virator."); loopFlag_ = false; return TELEPHONY_SUCCESS; } -- Gitee