From: luozheng <1732036298@qq.com> Date: Mon, 22 Apr 2024 02:09:24 +0000 (+0800) Subject: 将用户设置系统音量和通话音量保存在ConfigModel中 X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~87 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=988e507411e90360ef4edbb579d61607d9aa705a;p=mirrors%2FFD230.git 将用户设置系统音量和通话音量保存在ConfigModel中 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index d5e5f1fd0..b96626f04 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -65,6 +65,8 @@ namespace OHOS CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 CONFIGMODEL_ITEM_DNOTDISTURB,//勿扰模式 CONFIGMODEL_ITEM_TRANING_FREQ,//训练实时数据上传频率 + CONFIGMODEL_ITEM_SYSTEM_VOLUME,//系统音量 + CONFIGMODEL_ITEM_CALL_VOLUME,//通话音量 CONFIGMODEL_ITEM_MAX, } ; @@ -142,6 +144,13 @@ namespace OHOS void SetRaiseToWake(bool value); bool GetRaiseToWake(void); + /* ----------------------------- 声音与震动相关set与get ----------------------------- */ + + void SetSystemVolume(int value); + int GetSystemVolume(void); + + void SetCallVolume(int value); + int GetCallVolume(void); /* --------------------------------- 用户配置信息 --------------------------------- */ void SetUserAge(int age); int GetUserAge(); @@ -180,6 +189,8 @@ namespace OHOS {ConfigDataType::DATATYPE_DOUBLE, "GoalDistance", "8.0" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km) {ConfigDataType::DATATYPE_BOOL, "Dnotdisturb", "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭 {ConfigDataType::DATATYPE_INT, "traningfreq", "10" },// CONFIGMODEL_ITEM_TRANING_FREQ //训练实时数据上传频率//单位秒 + {ConfigDataType::DATATYPE_INT, "SystemVolume", "100" },// CONFIGMODEL_ITEM_SYSTEM_VOLUME // + {ConfigDataType::DATATYPE_INT, "CallVolume", "100" },// CONFIGMODEL_ITEM_CALL_VOLUME // }; ConfigModel(); // 私有构造函数,确保无法在外部实例化 ConfigModel(const ConfigModel &) = delete; // 禁止拷贝构造 diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h index dbabfb475..25e7e3d52 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 15:44:00 + * @LastEditTime: 2024-04-22 09:48:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -45,6 +45,11 @@ void initializeScreenDuration(void); * @brief 初始化抬腕亮屏 */ void initializeRaiseToWake(void); + +/* + * @brief 初始化系统音量和通话音量 + */ +void initializeVolume(void); #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 51186fd94..dfcfd6baf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -646,6 +646,30 @@ namespace OHOS { return get_configData_int(CONFIGMODEL_ITEM_SCREEN_BRIGHTNESS_VALUE); } + + //设置系统音量 + void ConfigModel::SetSystemVolume(int value) + { + set_condigData_Int(CONFIGMODEL_ITEM_SYSTEM_VOLUME,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); + } + + //获取通话音量 + int ConfigModel::GetCallVolume(void) + { + return get_configData_int(CONFIGMODEL_ITEM_CALL_VOLUME); + } /* -------------------------------------------------------------------------- */ /*设置用户年龄[后续使用结构体统一配置]*/ void ConfigModel::SetUserAge(int age) @@ -780,6 +804,16 @@ void initializeRaiseToWake(void) // uapi_take_to_wake(0); } } + +void initializeVolume(void) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "initializeVolume"); + int systemVolume = OHOS::ConfigModel::GetInstance()->GetSystemVolume(); + int callVolume = OHOS::ConfigModel::GetInstance()->GetCallVolume(); + uapi_systemVolumeSet(systemVolume); + uapi_callVolumeSet(callVolume); +} + #ifdef __cplusplus #if __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 1f3221933..ac099d05c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp @@ -4,7 +4,7 @@ #include #include "phoneservice/include/PhoneAudio.h" #include "phoneservice/include/PhoneService.h" - +#include "config/include/ConfigModel.h" namespace OHOS { @@ -67,8 +67,12 @@ namespace OHOS // p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(PhoneAudioGetVolume()); // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", PhoneAudioGetVolume()); - p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(GetCallCurrVolume()); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", GetCallCurrVolume()); + // p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(GetCallCurrVolume()); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", GetCallCurrVolume()); + + int callVolume = ConfigModel::GetInstance()->GetCallVolume(); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(callVolume); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", callVolume); initViewStatus = true; return CallVolumeScrollView; 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 0d193731b..7a240c89d 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-04-19 19:01:17 + * @LastEditTime: 2024-04-22 09:35:44 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -29,11 +29,11 @@ namespace OHOS } if (view->GetVolumeType() == SYSTEM_VOLUME) { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(value), sizeof(value)); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value)); } else if (view->GetVolumeType() == CALL_VOLUME) { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(value), sizeof(value)); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(&value), sizeof(value)); } slider->SetValue(newVolumeValue); } @@ -51,11 +51,11 @@ namespace OHOS } if (view->GetVolumeType() == SYSTEM_VOLUME) { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(value), sizeof(value)); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value)); } else if (view->GetVolumeType() == CALL_VOLUME) { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(value), sizeof(value)); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(&value), sizeof(value)); } slider->SetValue(newVolumeValue); } @@ -118,13 +118,13 @@ namespace OHOS void VoumeProcessSliderEventListener::OnChange(int32_t value) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnChange %d", value); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value); ChangeVolumeValue(OTHER, value); } void VoumeProcessSliderEventListener::OnRelease(int32_t value) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value); ChangeVolumeValue(OTHER, value); } @@ -154,7 +154,7 @@ extern "C" */ void SystemVolumeSet(int16_t sounding) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding); Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置 } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp index 4b99b238a..9336438e5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp @@ -1,7 +1,7 @@ #include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" #include "wearable_log.h" - +#include "config/include/ConfigModel.h" namespace OHOS { static SoundAndVibrationVolumeSettingView *g_pSoundAndVibrationVolumeSettingView{nullptr}; @@ -31,6 +31,16 @@ namespace OHOS { ScrollView->RemoveAll(); + int volume = VolumeProcess->GetValue(); + if (m_VolumeType == SYSTEM_VOLUME) + { + ConfigModel::GetInstance()->SetSystemVolume(volume); + } + else if (m_VolumeType == CALL_VOLUME) + { + ConfigModel::GetInstance()->SetCallVolume(volume); + } + delete VolumeProcess; VolumeProcess = nullptr; 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 038860f4d..5b1a02fcf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -2,6 +2,7 @@ #include "soundandvibration/include/SystemVolumePresenter.h" #include "wearable_log.h" #include +#include "config/include/ConfigModel.h" /* 系统音量: 通话,提醒,查找手表的音量 @@ -67,8 +68,12 @@ namespace OHOS return nullptr; } - p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); + // p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); + + int systemVolume = ConfigModel::GetInstance()->GetSystemVolume(); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(systemVolume); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", systemVolume); initViewStatus = true; return SystemVolumeScrollView;