From ee6199dfebc84e2e5bfe3c0b8f6867d74d7d4e20 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 26 Aug 2024 19:30:12 +0800 Subject: [PATCH] =?utf8?q?ConfigModel=E4=B8=AD=E5=8F=96=E6=B6=88=E4=BF=9D?= =?utf8?q?=E5=AD=98=E7=B3=BB=E7=BB=9F=E9=9F=B3=E9=87=8F=E5=92=8C=E9=80=9A?= =?utf8?q?=E8=AF=9D=E9=9F=B3=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../main/src/VolumeSettingPresenter.cpp | 2 -- .../nativeui/player/src/PlayersPresenter.cpp | 3 +- .../include/SoundAndVibrationVolumeSettingC.h | 4 ++- .../soundandvibration/src/CallVolumeView.cpp | 3 +- ...oundAndVibrationVolumeSettingPresenter.cpp | 33 ++++++----------- .../src/SystemVolumeView.cpp | 9 ++--- .../service/ble_service/blemoder/bletest.cpp | 12 ++----- .../peripheral/config/include/ConfigModel.h | 10 ------ .../peripheral/config/include/ConfigModelC.h | 9 ++--- .../peripheral/config/src/ConfigModel.cpp | 35 ------------------- .../drivers/peripheral/utils/custom_utils.c | 20 ++++++----- .../drivers/peripheral/utils/custom_utils.h | 2 ++ 12 files changed, 40 insertions(+), 102 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp index 1e067daf5..da0b478e4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp @@ -120,12 +120,10 @@ void VolumeSliderEventListener::ChangeVolume(VolumeChangeStatus status) if (playerCoefficients == VOLUMEPLAYERS) { BtAndLocalVolumeSet(volumeSettingView->sounding); /*蓝牙耳机音乐调节*/ - ConfigModel::GetInstance()->SetSystemVolume(volumeSettingView->sounding);/*将设置的音量保存到系统音量*/ } if (playerCoefficients == VOLUMEPHONE || playerCoefficients == VOLUMEPHONENOTIFY) { unsigned char volumeValue = (unsigned char) ((double) (volumeSettingView->sounding * CALL_VOLUME_MAX) / (VOLUME_MAX - VOLUME_MIN)); // 音量转换 SetSpeakerVolume(volumeValue); - ConfigModel::GetInstance()->SetCallVolume(volumeSettingView->sounding);/*将设置的音量保存到通话音量*/ } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp index 27beed95a..dcc61f563 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -25,6 +25,7 @@ #include #include "ConfigModel.h" #include "ctype.h" +#include namespace OHOS { static PlayerOnDragListener *g_pPlayerOnDragListener = nullptr; static JumpView *g_pJumpView = nullptr; @@ -626,7 +627,7 @@ void ButtonOnClickListener::SoundButtonOnClick() return; } playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_VOLUME_CONTROL_VIEW); - int32_t volume = ConfigModel::GetInstance()->GetSystemVolume(); + int32_t volume = uapi_systemVolumeGet(); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "current volume = %d", volume); if( playersView->GetVolumeSettingView()->GetProgress()) { playersView->GetVolumeSettingView()->GetProgress()->SetValue(volume); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h index ec6f1b8a9..bc327dc2a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 18:59:49 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-22 18:35:35 + * @LastEditTime: 2024-08-26 18:27:45 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h */ #ifndef SOUND_AND_VIBRATION_VOLUME_SETTINGC_H @@ -18,7 +18,9 @@ extern "C" #include void SystemVolumeSet(int16_t sounding); + int SystemVolumeGet(void); void CallVolumeSet(int16_t sounding); + int CallVolumeGet(void); // void VibationModeSet(int value); void SilentModelSet(bool isopen); #ifdef __cplusplus diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp index d05d2edbf..a78d37d0c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp @@ -5,6 +5,7 @@ #include "phoneservice/include/PhoneAudio.h" #include "phoneservice/include/PhoneService.h" #include "ConfigModel.h" +#include namespace OHOS { @@ -122,7 +123,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); return false; } - int callVolume = ConfigModel::GetInstance()->GetCallVolume(); + int callVolume = uapi_callVolumeGet(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", callVolume); p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(callVolume); 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 690803820..f7e444ca3 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-08-01 09:55:37 + * @LastEditTime: 2024-08-26 18:54:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -123,19 +123,6 @@ namespace OHOS void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value) { FindAndApplyStrategy(status, value); - - SoundAndVibrationVolumeSettingView *view = SoundAndVibrationVolumeSettingView::GetInstance(); - if (view) - { - if (view->GetVolumeType() == SYSTEM_VOLUME) - { - ConfigModel::GetInstance()->SetSystemVolume(value); - } - else if (view->GetVolumeType() == CALL_VOLUME) - { - ConfigModel::GetInstance()->SetCallVolume(value); - } - } } // 滑块变化事件处理 @@ -231,24 +218,24 @@ extern "C" Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置 } + int SystemVolumeGet(void) + { + return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC); + } + /* * @brief 通话音量设置 */ void CallVolumeSet(int16_t sounding) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeSet %d", sounding); - // PhoneAudioSetVolume(sounding); // 通话音量音量设置 - // SetSpeakerVolume(sounding); Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 系统音量设置 } - // /* - // * @brief 震动模式设置 - // */ - // void VibationModeSet(int value) - // { - // custom_VibratorFunc_int(value); - // } + int CallVolumeGet(void) + { + return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO); + } /* * @brief 静音模式设置 diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp index 30db85266..398f61a1e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-23 16:58:58 + * @LastEditTime: 2024-08-26 18:56:26 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp */ #include "soundandvibration/include/SystemVolumeView.h" @@ -10,6 +10,7 @@ #include "wearable_log.h" #include #include "ConfigModel.h" +#include /* 系统音量: 通话,提醒,查找手表的音量 @@ -131,9 +132,9 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); return false; } - int systemVolume = ConfigModel::GetInstance()->GetSystemVolume(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", systemVolume); - p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(systemVolume); + int SystemVolume = uapi_systemVolumeGet(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", SystemVolume); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(SystemVolume); return true; } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 12a3cd923..f6f4e7589 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -1889,8 +1889,6 @@ int Get_RaiseToWake(void) //获取抬婉亮屏开关 } void Set_SystemVolume(int value) //设置系统音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - p_ConfigModel->SetSystemVolume(value); uapi_systemVolumeSet(value); #ifdef FD230 SendMsgToUIService(UI_UPDATE_SYSTEM_VOLUME,0,nullptr,0); @@ -1900,14 +1898,10 @@ void Set_SystemVolume(int value) //设置系统音量 int Get_SystemVolume(void) //获取系统音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - - return p_ConfigModel->GetSystemVolume(); + return uapi_systemVolumeGet(); } void Set_CallVolume(int value) //设置通话音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - p_ConfigModel->SetCallVolume(value); uapi_callVolumeSet(value); #ifdef FD230 SendMsgToUIService(UI_UPDATE_CALL_VOLUME,0,nullptr,0); @@ -1917,9 +1911,7 @@ void Set_CallVolume(int value) //设置通话音量 int Get_CallVolume(void) //获取通话音量 { - OHOS::ConfigModel *p_ConfigModel = OHOS::ConfigModel::GetInstance(); - - return p_ConfigModel->GetCallVolume(); + return uapi_callVolumeGet(); } uint8_t ble_is_ready(void) diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index 2527a92e7..1269bc13b 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -71,8 +71,6 @@ namespace OHOS CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 CONFIGMODEL_ITEM_DNOTDISTURB,//勿扰模式 CONFIGMODEL_ITEM_MESSAGE_UNREAD,//未读状态 - CONFIGMODEL_ITEM_SYSTEM_VOLUME,//系统音量 - CONFIGMODEL_ITEM_CALL_VOLUME,//通话音量 CONFIGMODEL_ITEM_VOLTE_CALL,//VoLTE通话 CONFIGMODEL_ITEM_MOTIONRECOGNITION,//运动识别 CONFIGMODEL_ITEM_HFP, //通话蓝牙开关 @@ -216,12 +214,6 @@ namespace OHOS /* ----------------------------- 声音与震动相关set与get ----------------------------- */ - void SetSystemVolume(int value); - int GetSystemVolume(void); - - void SetCallVolume(int value); - int GetCallVolume(void); - void SetDmpFactoryStatus(int state); int GetDmpFactoryStatus(void); @@ -325,8 +317,6 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "goal_distance", "8" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km) {ConfigDataType::DATATYPE_BOOL, "dnotdisturb", "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭 {ConfigDataType::DATATYPE_BOOL, "unread", "false"},//CONFIGMODEL_ITEM_MESSAGE_UNREAD//未读状态默认未读 - {ConfigDataType::DATATYPE_INT, "system_volume", "100" },// CONFIGMODEL_ITEM_SYSTEM_VOLUME // - {ConfigDataType::DATATYPE_INT, "call_volume", "100" },// CONFIGMODEL_ITEM_CALL_VOLUME // {ConfigDataType::DATATYPE_BOOL, "voltecall", "true" },// CONFIGMODEL_ITEM_VOLTE_CALL #默认是开启VOLTE {ConfigDataType::DATATYPE_BOOL, "motion_recognition", "false" },// CONFIGMODEL_ITEM_MOTIONRECOGNITION {ConfigDataType::DATATYPE_BOOL, "hfp", "true" },// CONFIGMODEL_ITEM_HFP diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index b0b962354..2b0ec7c83 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-08-19 10:16:53 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-26 19:20:26 * @FilePath: /FD230/code/sdk/drivers/peripheral/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -46,11 +46,6 @@ void cm_initializeScreenDuration(void); */ void cm_initializeRaiseToWake(void); -/* - * @brief 初始化系统音量和通话音量 - */ -void cm_initializeVolume(void); - /* * @brief 初始化震动模式 */ diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 16de7a0de..d6265f17d 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1123,32 +1123,6 @@ namespace OHOS return get_configData_int(CONFIGMODEL_ITEM_SCREEN_BRIGHTNESS_VALUE); } - //设置系统音量 - void ConfigModel::SetSystemVolume(int value) - { - set_condigData_Int(CONFIGMODEL_ITEM_SYSTEM_VOLUME,value); - //uapi_systemVolumeSet(value); - } - - //获取系统音量 - int ConfigModel::GetSystemVolume(void) - { - return get_configData_int(CONFIGMODEL_ITEM_SYSTEM_VOLUME); - } - - //设置通话音量 - void ConfigModel::SetCallVolume(int value) - { - set_condigData_Int(CONFIGMODEL_ITEM_CALL_VOLUME,value); - //uapi_callVolumeSet(value); - } - - //获取通话音量 - int ConfigModel::GetCallVolume(void) - { - return get_configData_int(CONFIGMODEL_ITEM_CALL_VOLUME); - } - //设置运动识别是否开启 void ConfigModel::SetMotionRecognition(bool state) { @@ -1367,15 +1341,6 @@ void cm_initializeRaiseToWake(void) } } -void cm_initializeVolume(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cm_initializeVolume"); - int systemVolume = OHOS::ConfigModel::GetInstance()->GetSystemVolume(); - int callVolume = OHOS::ConfigModel::GetInstance()->GetCallVolume(); - uapi_systemVolumeSet(systemVolume); - uapi_callVolumeSet(callVolume); -} - void cm_initializeVibrationModel(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cm_initializeVibrationModel"); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 2ace3f24a..df392e360 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -351,7 +351,6 @@ void startup_post_init_task(void) cm_initScreenBrightness(); cm_initializeScreenDuration(); cm_initializeRaiseToWake(); - cm_initializeVolume(); cm_initializeVibrationModel(); cm_initializeSilentModel(); // cm_initializeVoLTECall(); @@ -1132,6 +1131,12 @@ void uapi_systemVolumeSet(int16_t sounding) #endif } +/*系统声音获取*/ +int uapi_systemVolumeGet(void) +{ + return SystemVolumeGet(); +} + //通话音量设置 void uapi_callVolumeSet(int16_t sounding) { @@ -1140,13 +1145,12 @@ void uapi_callVolumeSet(int16_t sounding) #endif } -// //震动强度设置 -// void uapi_vibrationModeSet(int value) -// { -// #ifdef FD230 -// VibationModeSet(value); -// #endif -// } +//通话音量获取 +int uapi_callVolumeGet(void) +{ + return CallVolumeGet(); +} + //设置是否静音 void uapi_setSilentMode(bool isopen) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 66602c245..4a096c21a 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -114,7 +114,9 @@ void uapi_setScreenDuration(int32_t time); int32_t uapi_get_screen_state(void); void uapi_systemVolumeSet(int16_t sounding); +int uapi_systemVolumeGet(void); void uapi_callVolumeSet(int16_t sounding); +int uapi_callVolumeGet(void); // void uapi_vibrationModeSet(int value); void uapi_setSilentMode(bool isopen); void uapi_set4GCapability(bool isopen); -- 2.17.1