From: luozheng <1732036298@qq.com> Date: Fri, 13 Sep 2024 10:33:58 +0000 (+0800) Subject: 通话音量修改为PhoneService中接口 X-Git-Tag: release_V1.2.70_20241020_135402~485^2^2~4 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e5a256a2dbed1f116ecd379b57dec049f7476f63;p=mirrors%2FFD230.git 通话音量修改为PhoneService中接口 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h index 61cd8539b..d5b7c5d60 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h @@ -278,6 +278,8 @@ void Cat1_CallStateChanged(const hfp_hf_calls_info_t *call); void PhoneServiceScreenCtr(bool turnOnFlag); +void set_speaker_volume(unsigned char hfpVolume,int type); + #ifdef __cplusplus } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index f707e0536..c0bdf7d77 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -1933,6 +1933,52 @@ void SetSpeakerVolume(unsigned char hfpVolume) return; } +void set_speaker_volume(unsigned char hfpVolume,int type) +{ + if(type != AUDIO_STREAM_VOICE_CALL_BT_SCO) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] start, CallSourceCat1:%d", hfpVolume); + int32_t minVolume = PhoneAudioGetCAT1MinVolume(); + int32_t maxVolume = PhoneAudioGetCAT1MAXVolume(); + int32_t volume = hfpVolume * (maxVolume - minVolume)/ CALL_VOLUME_MAX;// 转换 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] minVolume:%d, maxVolume:%d, volume:%d", + minVolume, maxVolume, volume); + + int32_t ret = PhoneCATAudioSetVolume(volume); + if (!ret) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] PhoneAudioSetVolume ret:%d", ret); + return; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] success!"); + } + else + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] start, hfpVolume:%d", hfpVolume); + int32_t minVolume = PhoneAudioGetMinVolume(); + int32_t maxVolume = PhoneAudioGetMaxVolume(); + int32_t volume = hfpVolume * (maxVolume - minVolume) / CALL_VOLUME_MAX; // 转换 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] minVolume:%d, maxVolume:%d, volume:%d", + minVolume, maxVolume, volume); + + int32_t ret = PhoneAudioSetVolume(volume); + if (!ret) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] PhoneAudioSetVolume ret:%d", ret); + return; + } + + ret = hfp_hf_set_volume(&g_bdAddr, HFP_VOLUME_SPEAKER, hfpVolume); + if (ret != ERRCODE_BT_SUCCESS) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] set_volume ret:%d, hfpVolume:%d", + ret, hfpVolume); + return; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[SetSpeakerVolume] success!"); + } + + + return; +} + // 设置通话speaker静音 bool SetSpeakerMute(bool isMute) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp index 0769e3fe5..8b6e66162 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:31 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-09 20:56:39 + * @LastEditTime: 2024-09-13 18:31:03 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -229,13 +229,16 @@ extern "C" void CallVolumeSet(int32_t sounding) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeSet %d", sounding); - Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 通话音量设置 - Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, sounding); // 通话音量设置 + // Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 通话音量设置 + // Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, sounding); // 通话音量设置 + set_speaker_volume(sounding,AUDIO_STREAM_VOICE_CALL_BT_SCO); + set_speaker_volume(sounding,AUDIO_STREAM_VOICE_CALL_VOLTE); } int CallVolumeGet(void) { - return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO); + // return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO); + return GetCallCurrVolume(); } /*