#include "soundandvibration/include/SoundAndVibrationView.h"
#include "soundandvibration/include/SystemVolumePresenter.h"
#include "soundandvibration/include/SystemVolumeView.h"
+#include "soundandvibration/include/CallVolumePresenter.h"
+#include "soundandvibration/include/CallVolumeView.h"
#include "displaybrightness/include/DisplayBrightnessPresenter.h"
#include "displaybrightness/include/DisplayBrightnessView.h"
{VIEW_SYSTEM, &NativeLauncher::InitSystemSlice}, // 系统实例化地址
{VIEW_SOUND_VIBRATION, &NativeLauncher::InitSoundAndVibrationSlice}, // 声音与震动实例化地址
{VIEW_SYSTEM_VOLUME, &NativeLauncher::InitSystemVolumeSlice}, // 系统音量
+ {VIEW_CALL_VOLUME, &NativeLauncher::InitCallVolumeSlice}, // 系统音量
{VIEW_CLASSIC_BLUETOOTH, &NativeLauncher::InitClassicBluetoothSlice}, // 经典蓝牙slice
{VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址
{VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction},
NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_VOLUME, systemvolume);
}
+ void NativeLauncher::InitCallVolumeSlice(void) // 系统音量
+ {
+ SliceProxy *callVolume = new AbilitySliceProxy<CallVolumeView, CallVolumePresenter>;
+ if (callVolume == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "callVolume");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_CALL_VOLUME, callVolume);
+ }
+
// DisplayBrightness的实例化
void NativeLauncher::InitDisplayBrightnessSlice(void)
{
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-01-29 16:24:23\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-04-19 09:48:42\r
+ * @LastEditTime: 2024-04-19 15:17:28\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/CallVolumePresenter.h\r
*/\r
#ifndef CALL_VOLUME_PRESENTER_H\r
// 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
bool OnClick(UIView &view, const ClickEvent &event) override;\r
bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ bool OnDragEnd(UIView &view, const DragEvent &event);\r
bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
};\r
} // namespace OHOS\r
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-01-29 15:37:44\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-04-19 09:41:56\r
+ * @LastEditTime: 2024-04-19 15:11:50\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/CallVolumeView.h\r
*/\r
-#ifndef SYSTEM_VOLUME_VIEW_H\r
-#define SYSTEM_VOLUME_VIEW_H\r
+#ifndef CALL_VOLUME_VIEW_H\r
+#define CALL_VOLUME_VIEW_H\r
\r
#include "BaseView.h"\r
#include "View.h"\r
#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"\r
namespace OHOS\r
{\r
- static const char *SYSTEM_VOLUME_SLIDER = "CallVolumeSlider";\r
\r
class SoundAndVibrationVolumeSettingView;\r
class CallVolumePresenter;\r
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-19 18:59:49
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-19 19:08:01
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h
+ */
+#ifndef SOUND_AND_VIBRATION_VOLUME_SETTINGC_H
+#define SOUND_AND_VIBRATION_VOLUME_SETTINGC_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif
+#endif
+#include <stdint.h>
+
+ void SystemVolumeSet(int16_t sounding);
+ void CallVolumeSet(int16_t sounding);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+#endif
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-19 10:08:21
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-19 10:22:53
+ * @LastEditTime: 2024-04-19 19:01:46
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h
*/
#ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H
#define SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H
#include <cstdint>
#include "components/ui_slider.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+#include "map"
+#include "memory"
namespace OHOS
{
typedef enum : uint8_t
OTHER = 2, // 其他
} VolumeStatusChange;
+ // 步骤 1: 定义策略接口.定义一个策略接口,所有的声音调整策略都需要实现这个接口
+ class SoundAndVibrationVolumeSettingView;
+ class VolumeChangeStrategy
+ {
+ public:
+ virtual void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) = 0;
+ virtual ~VolumeChangeStrategy() = default;
+ };
+
/*
* @brief 声音进度条的事件监听类
*/
~VoumeProcessSliderEventListener();
static VoumeProcessSliderEventListener *GetInstance(void);
void ChangeVolumeValue(uint8_t status, uint8_t value);
- void LocalVolumeSet(int16_t sounding);
void OnChange(int32_t value) override;
void OnRelease(int32_t value) override;
bool OnClick(UIView &view, const ClickEvent &event) override;
bool OnDrag(UIView &view, const DragEvent &event) override;
private:
- int32_t VolumeValue; // 声音值
- uint8_t m_VolumeType;
+ std::map<uint8_t, std::shared_ptr<VolumeChangeStrategy>> strategyMap;
};
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-01-29 15:41:49
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-19 10:40:30
+ * @LastEditTime: 2024-04-19 15:22:04
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h
*/
#ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_H
UIScrollView *SetUpVolumeProcess(void);
void ClearAll(void);
UISlider *GetVolumeProcess(void);
+ int GetVolumeType(void);
int CurrentVolumeValue{0};
private:
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-01-29 15:37:44\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-04-19 10:17:28\r
+ * @LastEditTime: 2024-04-19 15:11:54\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h\r
*/\r
#ifndef SYSTEM_VOLUME_VIEW_H\r
#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"\r
namespace OHOS\r
{\r
- static const char *SYSTEM_VOLUME_SLIDER = "SystemVolumeSlider";\r
\r
class SoundAndVibrationVolumeSettingView;\r
class SystemVolumePresenter;\r
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-03-30 09:14:38\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-04-19 10:24:13\r
+ * @LastEditTime: 2024-04-19 15:17:16\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumePresenter.cpp\r
*/\r
#include "AppViewIDs.h"\r
bool CallVolumePresenter::OnDrag(UIView &view, const DragEvent &event)\r
{\r
UNUSED(view);\r
+ UNUSED(event);\r
if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
(event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
{\r
return true;\r
}\r
\r
+ bool CallVolumePresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnDragEnd");\r
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ }\r
+ return true;\r
+ }\r
+\r
bool CallVolumePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件\r
{\r
UNUSED(view);\r
#include "soundandvibration/include/CallVolumePresenter.h"\r
#include "wearable_log.h"\r
#include <audio_manager.h>\r
+#include "phoneservice/include/PhoneAudio.h"\r
+#include "phoneservice/include/PhoneService.h"\r
\r
namespace OHOS\r
{\r
return nullptr;\r
}\r
\r
- p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC));\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC) = %d",Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC));\r
+ // p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(PhoneAudioGetVolume());\r
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", PhoneAudioGetVolume());\r
+ p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(GetCallCurrVolume());\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", GetCallCurrVolume());\r
\r
initViewStatus = true;\r
return CallVolumeScrollView;\r
void CallVolumeView::OnStart()\r
{\r
View<CallVolumePresenter>::OnStart();\r
- \r
+\r
CallVolumeViewInit();\r
\r
RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::CallVolumePresenter::GetInstance();\r
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-02-19 10:39:11\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-04-19 14:53:16\r
+ * @LastEditTime: 2024-04-19 15:10:49\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp\r
*/\r
\r
}\r
else if (strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0)\r
{\r
- NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_VOLUME);\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_CALL_VOLUME);\r
}\r
else if (strcmp(view.GetViewId(), VIBRATION_REMINDER_BUTTON) == 0)\r
{\r
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-19 10:08:31
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-19 10:14:03
+ * @LastEditTime: 2024-04-19 19:01:17
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
*/
#include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h"
-#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h"
#include "wearable_log.h"
#include <audio_manager.h>
+#include <custom_utils.h>
+#include "phoneservice/include/PhoneAudio.h"
+#include "phoneservice/include/PhoneService.h"
namespace OHOS
{
- /* --------------------- VoumeProcessSliderEventListener -------------------- */
- constexpr int16_t VOLUMEVALUE_CHANGE = 10;
+ static constexpr int16_t VOLUMEVALUE_CHANGE = 10;
+ // 步骤 2: 实现具体的策略
+ class LowerVolumeStrategy : public VolumeChangeStrategy
+ {
+ public:
+ void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) override
+ {
+ uint16_t newVolumeValue = slider->GetValue() - VOLUMEVALUE_CHANGE;
+ if (newVolumeValue < VOLUME_MIN)
+ {
+ newVolumeValue = VOLUME_MIN;
+ }
+ if (view->GetVolumeType() == SYSTEM_VOLUME)
+ {
+ 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));
+ }
+ slider->SetValue(newVolumeValue);
+ }
+ };
+
+ class ElevateVolumeStrategy : public VolumeChangeStrategy
+ {
+ public:
+ void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) override
+ {
+ uint16_t newVolumeValue = slider->GetValue() + VOLUMEVALUE_CHANGE;
+ if (newVolumeValue > VOLUME_MAX)
+ {
+ newVolumeValue = VOLUME_MAX;
+ }
+ if (view->GetVolumeType() == SYSTEM_VOLUME)
+ {
+ 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));
+ }
+ slider->SetValue(newVolumeValue);
+ }
+ };
+ class DragVolumeStrategy : public VolumeChangeStrategy
+ {
+ public:
+ void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, uint8_t value) override
+ {
+ if (view->GetVolumeType() == SYSTEM_VOLUME)
+ {
+ 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));
+ }
+ slider->SetValue(value);
+ }
+ };
+
+ /* --------------------- VoumeProcessSliderEventListener -------------------- */
static VoumeProcessSliderEventListener *g_pVoumeProcessSliderEventListener{nullptr};
VoumeProcessSliderEventListener::VoumeProcessSliderEventListener()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::VoumeProcessSliderEventListener");
+ // 步骤 3: 创建一个映射表将状态映射到策略
+ strategyMap[VOLUMEREDUCE] = std::make_shared<LowerVolumeStrategy>();
+ strategyMap[VOLUMEADD] = std::make_shared<ElevateVolumeStrategy>();
+ strategyMap[OTHER] = std::make_shared<DragVolumeStrategy>();
g_pVoumeProcessSliderEventListener = this;
}
void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value)
{
-
- SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance();
- if (p_SoundAndVibrationVolumeSettingView == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView GetInstance fail!!");
- return;
- }
- UISlider *progress = p_SoundAndVibrationVolumeSettingView->GetVolumeProcess();
- if (progress == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_SoundAndVibrationVolumeSettingView->GetVolumeProcess() fail");
- return;
- }
-
- VolumeValue = p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue;
-
- switch (status)
+ auto it = strategyMap.find(status);
+ if (it != strategyMap.end())
{
- case VOLUMEREDUCE:
- /* code */
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = progress->GetValue() - VOLUMEVALUE_CHANGE;
- if (p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue < VOLUME_MIN)
+ SoundAndVibrationVolumeSettingView *view = SoundAndVibrationVolumeSettingView::GetInstance();
+ UISlider *slider = view ? view->GetVolumeProcess() : nullptr;
+ if (view && slider)
{
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = VOLUME_MIN;
+ it->second->ApplyChange(view, slider, value);
}
- break;
- case VOLUMEADD:
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = progress->GetValue() + VOLUMEVALUE_CHANGE;
- if (p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue > VOLUME_MAX)
- {
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = VOLUME_MAX;
- }
- break;
- case OTHER:
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = value;
- if (p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue < VOLUME_MIN)
- {
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = VOLUME_MIN;
- }
- else if (p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue > VOLUME_MAX)
- {
- p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue = VOLUME_MAX;
- }
- break;
- default:
- break;
}
-
- progress->SetValue(p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue);
- LocalVolumeSet(p_SoundAndVibrationVolumeSettingView->CurrentVolumeValue);
- }
-
- /*
- * @brief 本地音量设置
- */
- void VoumeProcessSliderEventListener::LocalVolumeSet(int16_t sounding)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LocalVolumeSet %d", sounding);
- Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 本地音量设置
}
void VoumeProcessSliderEventListener::OnChange(int32_t value)
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);
ChangeVolumeValue(OTHER, value);
}
UNUSED(view);
return true;
}
+}
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+ /*
+ * @brief 系统音量设置
+ */
+ void SystemVolumeSet(int16_t sounding)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding);
+ Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置
+ }
+
+ /*
+ * @brief 通话音量设置
+ */
+ void CallVolumeSet(int16_t sounding)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeSet %d", sounding);
+ // PhoneAudioSetVolume(sounding); // 通话音量音量设置
+ SetSpeakerVolume(sounding);
+ }
-}
\ No newline at end of file
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
\ No newline at end of file
SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView(uint8_t VolumeType)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d",VolumeType);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d", VolumeType);
m_VolumeType = VolumeType;
g_pSoundAndVibrationVolumeSettingView = this;
}
return VolumeProcess;
}
+ /*
+ * @brief 获取声音类型
+ * @return 返回 0 系统音量,返回 1 通话音量
+ */
+ int SoundAndVibrationVolumeSettingView::GetVolumeType(void)
+ {
+ return m_VolumeType;
+ }
+
UIScrollView *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void)
{
ScrollView = new UIScrollView();
}\r
\r
p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC));\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC) = %d", Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); \r
- \r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC));\r
+\r
initViewStatus = true;\r
return SystemVolumeScrollView;\r
}\r
{
WEARABLE_LOGW(WEARABLE_LOG_MODULE_MAIN_SERVICE,"cat1_ring_isr_callback %d 0x%X\n",pin,param);
uapi_cat1_add_cat1_vote();
- do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE);
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE,NULL,0);
}
void uapi_cat1_wakeup_cat1(uint8_t wakeup)
typedef struct
{
uint8_t cmd;
- // uint8_t data[2];
+ uint8_t data[50];
} custom_cmd_cmd_t;
/***
* 其他cmd在Header里定义,对外开放
static bool g_bat_timer_is_running = false;
static unsigned long g_custom_cmd_queue;
-
-
static bool custom_cmd_service_running_stat = false;
-void do_custom_cmd_service_check_msg(int cmd)
+void do_custom_cmd_service_check_msg(int cmd, void *params, int paramlen)
{
int ret;
+ // 检查参数长度是否合法
+ if (paramlen > sizeof(custom_cmd_cmd_t) - sizeof(uint8_t))
+ {
+ PRINT("Error: 参数长度超过最大限制! \r\n");
+ return;
+ }
+
custom_cmd_cmd_t mail = {0};
- mail.cmd = cmd;
- // mail.data[0] = data[0];
- // mail.data[1] = data[1];
+ mail.cmd = (uint8_t)cmd;
+
+ // 将参数数据复制到结构体中
+ if (params && paramlen > 0)
+ {
+ memcpy(mail.data, params, paramlen);
+ }
+
ret = osal_msg_queue_write_copy(g_custom_cmd_queue, (void *)&mail, sizeof(custom_cmd_cmd_t), 0);
if (ret != OSAL_SUCCESS)
{
static void custom_cmd_service_check_task(void const *arg)
{
- unused(arg);
+
int32_t ret;
custom_cmd_cmd_t mail;
uint32_t msgsize = (uint32_t)sizeof(custom_cmd_cmd_t);
custom_cmd_service_running_stat = true;
-
+
while (1)
{
ret = osal_msg_queue_read_copy(g_custom_cmd_queue, (void *)&mail, &msgsize,
continue;
}
- if (mail.cmd == CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE)
+ // 根据邮件中的命令进行相应的处理
+ switch (mail.cmd)
{
+ case CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE:
restart_sleep_cat1_timer();
+ break;
+ case CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME:
+ //printf("mail.data: %d\n", *mail.data);
+ uapi_systemVolumeSet(mail.data);
+ break;
+ case CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME:
+ //printf("mail.data: %d\n", *mail.data);
+ uapi_callVolumeSet(mail.data);
+ break;
+ default:
+ PRINT("Unknown CUSTOM_CMD_MSG cmd 0x%02X \r\n", mail.cmd);
+ break;
}
- else
- {
- PRINT("unknown CUSTOM_CMD_MSG cmd 0x%2X \r\n",mail.cmd);
- }
}
}
#define CUSTOM_CMD_APP_BOARD_MSG_COUNT 10
#include "errcode.h"
#include "power_display_service.h"
#include "config/include/ConfigModelC.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h"
#define SUPPORT_NV
return display_api->get_screen_state();
}
+/*系统声音设置*/
+void uapi_systemVolumeSet(int16_t sounding)
+{
+ SystemVolumeSet(sounding);
+}
+
+//通话音量设置
+void uapi_callVolumeSet(int16_t sounding)
+{
+ CallVolumeSet(sounding);
+}
+
#include "bts_le_gap.h"
int32_t uapi_get_screen_state(void);
+void uapi_systemVolumeSet(int16_t sounding);
+void uapi_callVolumeSet(int16_t sounding);
+
errcode_t uapi_get_btaddr(uint8_t *buf_btaddr, uint32_t *len_btaddr);
errcode_t uapi_get_btname(uint8_t *buf_btname, uint32_t *len_btname);
errcode_t uapi_get_nv_btaddr(uint8_t *buf_btaddr, uint32_t *len_btaddr);
#define CUSTOM_CMD_MSG_TYPE_REMOVE_CAT1VOTE 0x01
+#define CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME 0x02
+#define CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME 0x03
errcode_t uapi_custom_cmd_service_init(void);
-void do_custom_cmd_service_check_msg(int cmd);
+void do_custom_cmd_service_check_msg(int cmd, void *params, int paramlen);
#ifdef __cplusplus
}