From: luozheng <1732036298@qq.com> Date: Fri, 6 Sep 2024 07:38:50 +0000 (+0800) Subject: 优化声音调节do_custom_cmd_service_check_msg传入参数为int32_t与Audio::AudioManager::SetVolume... X-Git-Tag: release_V1.2.70_20241020_135402~529^2~3 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=bbeaf753a31940b2183a48cfd044dee336809293;p=mirrors%2FFD230.git 优化声音调节do_custom_cmd_service_check_msg传入参数为int32_t与Audio::AudioManager::SetVolume(AudioStreamType streamType, int32_t 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 bc327dc2a..ecb05a39d 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-08-26 18:27:45 + * @LastEditTime: 2024-09-06 14:43:29 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h */ #ifndef SOUND_AND_VIBRATION_VOLUME_SETTINGC_H @@ -17,9 +17,9 @@ extern "C" #include #include - void SystemVolumeSet(int16_t sounding); + void SystemVolumeSet(int32_t sounding); int SystemVolumeGet(void); - void CallVolumeSet(int16_t sounding); + void CallVolumeSet(int32_t sounding); int CallVolumeGet(void); // void VibationModeSet(int value); void SilentModelSet(bool isopen); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h index f3f398e0f..954a2b737 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:21 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-24 16:35:52 + * @LastEditTime: 2024-09-06 14:11:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h */ #ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H @@ -26,7 +26,7 @@ namespace OHOS class VolumeChangeStrategy { public: - virtual void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) = 0; + virtual void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) = 0; virtual ~VolumeChangeStrategy() = default; }; @@ -42,8 +42,8 @@ namespace OHOS VoumeProcessSliderEventListener(); ~VoumeProcessSliderEventListener(); static VoumeProcessSliderEventListener *GetInstance(void); - void FindAndApplyStrategy(uint8_t status, uint8_t value); - void ChangeVolumeValue(uint8_t status, uint8_t value); + void FindAndApplyStrategy(uint8_t status, int32_t value); + void ChangeVolumeValue(uint8_t status, int32_t value); void OnChange(int32_t value) override; void OnRelease(int32_t value) override; bool OnClick(UIView &view, const ClickEvent &event) override; @@ -51,7 +51,7 @@ namespace OHOS bool OnRotateEnd(UIView& view, const RotateEvent& event); private: - std::map> strategyMap; + std::map> strategyMap; bool isOnClickSlider{true}; bool isDragSlider{false}; bool isRotateSlider{false}; 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 f7e444ca3..ce41565ad 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-26 18:54:00 + * @LastEditTime: 2024-09-06 15:29:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -24,7 +24,7 @@ namespace OHOS class LowerVolumeStrategy : public VolumeChangeStrategy { public: - void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) override + void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) override { uint16_t newVolumeValue = slider->GetValue() - VOLUMEVALUE_CHANGE; if (newVolumeValue < VOLUME_MIN) @@ -46,7 +46,7 @@ namespace OHOS class ElevateVolumeStrategy : public VolumeChangeStrategy { public: - void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) override + void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) override { uint16_t newVolumeValue = slider->GetValue() + VOLUMEVALUE_CHANGE; if (newVolumeValue > VOLUME_MAX) @@ -68,7 +68,7 @@ namespace OHOS class DragVolumeStrategy : public VolumeChangeStrategy { public: - void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) override + void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) override { if (view->GetVolumeType() == SYSTEM_VOLUME) { @@ -106,7 +106,7 @@ namespace OHOS return g_pVoumeProcessSliderEventListener; } - void VoumeProcessSliderEventListener::FindAndApplyStrategy(uint8_t status, uint8_t value) + void VoumeProcessSliderEventListener::FindAndApplyStrategy(uint8_t status, int32_t value) { auto it = strategyMap.find(status); if (it != strategyMap.end()) @@ -120,7 +120,7 @@ namespace OHOS } } - void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value) + void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, int32_t value) { FindAndApplyStrategy(status, value); } @@ -212,7 +212,7 @@ extern "C" /* * @brief 系统音量设置 */ - void SystemVolumeSet(int16_t sounding) + void SystemVolumeSet(int32_t sounding) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding); Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置 @@ -226,7 +226,7 @@ extern "C" /* * @brief 通话音量设置 */ - void CallVolumeSet(int16_t sounding) + 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); // 系统音量设置 diff --git a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c index 8e57eef1d..4081cd793 100644 --- a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c @@ -116,16 +116,26 @@ static void custom_cmd_service_check_task(void const *arg) break; case CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME: { - // printf("mail.data: %d\n", *mail.data); - int16_t value = mail.data[0]; - uapi_systemVolumeSet(value); + int32_t value = 0; + int i; + for (i = 0; i < sizeof(int) && i < sizeof(mail.data); i++) + { + value |= (mail.data[i] << (i * 8)); + } + printf("uapi_systemVolumeSet: %d\n", value); + uapi_systemVolumeSet(value); } break; case CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME: { - // printf("mail.data: %d\n", *mail.data); - int16_t value = mail.data[0]; - uapi_callVolumeSet(value); + int32_t value = 0; + int i; + for (i = 0; i < sizeof(int) && i < sizeof(mail.data); i++) + { + value |= (mail.data[i] << (i * 8)); + } + printf("uapi_callVolumeSet: %d\n", value); + uapi_callVolumeSet(value); } break; case CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING: diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 149e063ca..ab5be3153 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1135,7 +1135,7 @@ void uapi_set_screen_on_api(void) } /*系统声音设置*/ -void uapi_systemVolumeSet(int16_t sounding) +void uapi_systemVolumeSet(int32_t sounding) { #ifdef FD230 SystemVolumeSet(sounding); @@ -1149,7 +1149,7 @@ int uapi_systemVolumeGet(void) } //通话音量设置 -void uapi_callVolumeSet(int16_t sounding) +void uapi_callVolumeSet(int32_t sounding) { #ifdef FD230 CallVolumeSet(sounding); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 8672f8729..943d4b683 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -113,9 +113,9 @@ void uapi_setScreenDuration(int32_t time); int32_t uapi_get_screen_state(void); -void uapi_systemVolumeSet(int16_t sounding); +void uapi_systemVolumeSet(int32_t sounding); int uapi_systemVolumeGet(void); -void uapi_callVolumeSet(int16_t sounding); +void uapi_callVolumeSet(int32_t sounding); int uapi_callVolumeGet(void); // void uapi_vibrationModeSet(int value); void uapi_setSilentMode(bool isopen);