优化声音调节do_custom_cmd_service_check_msg传入参数为int32_t与Audio::AudioManager::SetVolume...
authorluozheng <1732036298@qq.com>
Fri, 6 Sep 2024 07:38:50 +0000 (15:38 +0800)
committerluozheng <1732036298@qq.com>
Fri, 6 Sep 2024 07:38:50 +0000 (15:38 +0800)
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
code/sdk/drivers/peripheral/utils/custom_cmd_service.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index bc327dc..ecb05a3 100644 (file)
@@ -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 <stdint.h>
 #include <stdbool.h>
 
-    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);
index f3f398e..954a2b7 100644 (file)
@@ -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<uint8_t, std::shared_ptr<VolumeChangeStrategy>> strategyMap;
+        std::map<int32_t, std::shared_ptr<VolumeChangeStrategy>> strategyMap;
         bool isOnClickSlider{true};
         bool isDragSlider{false};
         bool isRotateSlider{false};
index f7e444c..ce41565 100644 (file)
@@ -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); // 系统音量设置
index 8e57eef..4081cd7 100644 (file)
@@ -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:
index 149e063..ab5be31 100644 (file)
@@ -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);
index 8672f87..943d4b6 100644 (file)
@@ -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);