From: 罗正 <1732036298@qq.com> Date: Sat, 21 Sep 2024 11:21:06 +0000 (+0000) Subject: Merge #1001 into sdk602patch0626 from refs/changes/1001/head X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=634f5e9c4ec9879e3113840bf353df4da37c67b2;p=mirrors%2FFD230.git Merge #1001 into sdk602patch0626 from refs/changes/1001/head Code review from 罗正 * refs/changes/1001/head: (30 commits squashed) - #524,解决:录音删除,删除后不是返回到录音列表界面,返回的是录音界面bug #658,解决,手表,录音频繁点击会有蓝色效果 - #656,解决,手表,闹钟偶现0000闹钟提醒bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 4G界面添加“注:启用4G,可能会加速消耗电量”提醒 - 运动识别界面添加提醒标签,#192,解决,运动识别界面单一bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 根据禅道上期望:APP查找手表和闹钟,勿扰睡眠静音模式下都有响铃和震动提醒 #421解决, 睡眠模式,闹钟无响铃震动bug - 解决静音模式错误开启后会全局静音bug,根据禅道期望“来电铃声、短信消息提醒,勿扰睡眠静音模式下只有亮屏提醒” - #717,解决,设置界面向上滑有黑色空白,需优化bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #716,解决,设置屏幕与亮度界面右滑返回上一级界面,有上下晃动,优化退出晃动bug - #720,解决,手表默认通话音量过小,手表是恢复出厂设置后查看的bug - 修复msg_senter关于喝水提醒被覆盖代码 - 1.添加APP在调节系统音量时候若当前界面在音乐的的声音调节视图则ui同步显示设置的音量值。 2.解决音乐从本地音乐切换到手机音乐在切换到本地音乐切换不回来bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 解决#748,关于手表界面,编码器旋转不起作用bug - 关机,恢复出厂增加震动效果,开机的震动还未加,震动强度会受设置中影响 - #176,解决,4G能力开关名称修改成4G网络,界面单一bug - 1.解决语言界面内存泄漏问题 2.解决.#741语言选择界面上滑时底部会有黑边,使用编码器时无此情况bug 3.解决系统界面的内存泄漏问题,并使用一个辅助组件解决系统视图最后一个按钮被则挡住bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #747,解决声音与震动,显示方式,系统界面 下拉后无法恢复到原位置,有向下偏移bug - 解决设置视图右滑难退出问题 - #575,解决,Al 安卓 文心一言 手表端不输出结果,手机输出结果bug,原因为文件路径不存在问题 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #217,解决,本地音乐选择手机音乐,手表在播放手机端的音乐时,调节手表端音量不起作用bug 取消秒表界面的长亮屏操作 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1001 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothHeadsetEvent.h b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothHeadsetEvent.h index 8e5341d74..2253e6d41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothHeadsetEvent.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothHeadsetEvent.h @@ -37,6 +37,7 @@ void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue); void ConnCtStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state); void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state); void InitBtHeadsetEvent(void); +void BtAvrcpVolumeChangedSyncMedia(uint8_t a2dp_volume); #ifdef __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp index 00057bc20..0ab8b0a74 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp @@ -98,8 +98,15 @@ void BtAvrcpTgNotifyVolumeChangedProc(uint8_t a2dp_volume) int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100; WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyVolume = %d", audio_volume); AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume); // 耳机连接手表场景调节手表音量 + /* ---------------------------- 若当前音乐播放器为手机音乐则同步更新音乐播放器的声音进度条 --------------------------- */ + if(PlayersModel::GetInstance()->GetMusicSource()) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PlayersModel::UpdateVolumeValue, OHOS::PlayersModel::GetInstance())); + } + /* -------------------------------------------------------------------------- */ } +//根据传入的按键操作类型和值,执行相应的操作并通知媒体状态变化 void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue) { bt_avrcp_tg_evt_status_param event; @@ -407,6 +414,7 @@ static void BtAvrcpCtHdlNotifyVolumeRspCbk(avrcp_ct_notification_value_cb_t *not BtAvrcpTgNotifyVolumeChangedProc((uint8_t)notification->volume); } +//收到来自TG返回的Notification时回调函数 static void BtAvrcpCtNotificationCallback( const bd_addr_t *bd_addr, avrcp_notify_event_t event_id, avrcp_ct_notification_value_cb_t *notification) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h index 5bdd51a5e..a63c46037 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:02 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-10 14:31:56 + * @LastEditTime: 2024-09-21 18:17:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingPresenter.h */ @@ -38,6 +38,7 @@ typedef enum : uint8_t { class VolumeSettingView; class VolumeSliderEventListener : public UISlider::UISliderEventListener, public UIView::OnClickListener, + public UIView::OnRotateListener, public UIView::OnDragListener { public: VolumeSliderEventListener(VolumeSettingView *volumeSetting); @@ -48,6 +49,7 @@ public: void ChangeVolume(VolumeChangeStatus status); bool OnClick(UIView& view, const ClickEvent& event) override; bool OnDrag(UIView& view, const DragEvent& event) override; + bool OnRotateEnd(UIView& view, const RotateEvent& event); void SetPlayerCoefficients(int16_t value); void BtAndLocalVolumeSet(int16_t sounding); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index ba20d7952..3469217d3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -376,6 +376,7 @@ namespace OHOS { return; } + if(PlayersModel::GetInstance()->GetMusicSource() == false) { int32_t playerState; PlayersModel::GetInstance()->GetPlayerCtr()->GetPlayerState(playerState); state_ = playersView->GetPlayerButtonState(); @@ -387,6 +388,7 @@ namespace OHOS { playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::SELECTED); } + } if (state_ == UICheckBox::UICheckBoxState::SELECTED) { PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime_); 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 da0b478e4..89b71bcc3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp @@ -135,6 +135,13 @@ void VolumeSliderEventListener::BtAndLocalVolumeSet(int16_t sounding) WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "avrcp volume = %d", volume); (void)avrcp_ct_set_absolute_volume(&(g_avrcp_srv_inf.bd_addr), volume); // 手表音量设置同步远端BT音量 } + /* -------------------------- 若ct或tg端是已连接状态且当前为手机音乐 ------------------------- */ + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && PlayersModel::GetInstance()->GetMusicSource()) + { + uint8_t volume = sounding * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / 100; // 100:本地音量最大值 + BtAvrcpVolumeChangedSyncMedia(volume);// 手表音量设置同步手机音量 + } + /* -------------------------------------------------------------------------- */ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audio volume = %d", sounding); AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 本地音量设置 } @@ -156,6 +163,21 @@ void VolumeSliderEventListener::OnChange(int32_t value) // ChangeVolume(VOLUMEDRAG); } +bool VolumeSliderEventListener::OnRotateEnd(UIView& view, const RotateEvent& event) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSliderEventListener::OnRotateEnd"); + UISlider *slider = dynamic_cast(&view); + UISlider *progress = volumeSettingView->GetProgress(); + if (slider != nullptr && progress != nullptr) + { + if (slider == progress) + { + ChangeVolume(VOLUMEDRAG); + } + } + return true; +} + bool VolumeSliderEventListener::OnDrag(UIView& view, const DragEvent& event) { if (strcmp(view.GetViewId(), VOLUME_VIEW) == 0) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp index 44dd657e5..cd07875bd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp @@ -32,6 +32,7 @@ VolumeSettingView::~VolumeSettingView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VolumeSettingView::~VolumeSettingView"); RemoveAll(); + FocusManager::GetInstance()->ClearFocus(); if (listener != nullptr) { delete listener; listener = nullptr; @@ -79,7 +80,8 @@ bool VolumeSettingView::SetUpVolume(void) progress->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); progress->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); progress->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); - progress->RequestFocus(); + FocusManager::GetInstance()->RequestFocus(progress); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_DOWN); progress->SetRotateFactor(1.0); VolumeVetor = new UIImageView(); @@ -102,6 +104,7 @@ bool VolumeSettingView::SetUpVolume(void) progress->SetSliderEventListener(listener); progress->SetOnClickListener(listener); progress->SetOnDragListener(listener); + progress->SetOnRotateListener(listener); progress->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); SetViewId(VOLUME_VIEW); SetOnDragListener(listener); diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h index 3e574f8f9..1e0da28c5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-29 18:33:50 + * @LastEditTime: 2024-09-21 17:01:40 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h */ @@ -105,6 +105,9 @@ public: void PlayerMusic_StopTimer(void); void SetCircleProgress(); void UpdatePlayerProcess(void); + void UpdateVolumeValue(void); + bool get_avrcp_ct_or_tg_is_connected(void); + void set_phone_music_play_state(avrcp_key_operation_t notify); private: bool musicSourceFlag{false};//音乐来源标志:false:默认为手表音乐,true:手机音乐 int64_t playerCurrentTime_{0}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp index 0cb06b536..825fd2a33 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp @@ -824,7 +824,7 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) if(type) { bool phonebluetoothcon = SettingModel::GetInstance().GetPhoneConnectStatus(); // 获取手机连接状态 bool a2dp = uapi_a2dp_snk_get_device_connect_state(); // 获取a2dp连接状态 - if(g_PlayerTimes < 2) /*3秒切换时间*/ + if(g_PlayerTimes < 3) /*3秒切换时间*/ { if (!phonebluetoothcon) { @@ -841,7 +841,7 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) } } else { - if(g_PlayerTimes < 2) /*3秒切换时间*/ + if(g_PlayerTimes < 3) /*3秒切换时间*/ { playersView->ChangeView(PlayersView::MUISC_CONNECTING, PlayersView::MUSIC_SOURCE_VIEW); } @@ -958,6 +958,68 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) } SetCircleProgress(); } + + void PlayersModel::UpdateVolumeValue(void) + { + if(PlayersView::GetInstance()) + { + PlayersView::GetInstance()->UpdateVolumeValue(); + } + } + + bool PlayersModel::get_avrcp_ct_or_tg_is_connected(void) + { + bd_addr_t bdAddr={0}; + uapi_get_br_address(&bdAddr); //获取手机蓝牙地址 + int32_t connCtState = avrcp_ct_get_device_connect_state(&bdAddr); + int32_t connTgState = avrcp_tg_get_device_connect_state(&bdAddr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtAndLocalVolumeSet addr: %02x%02x%02x%02x%02x%02x ", + bdAddr.addr[5], bdAddr.addr[4], bdAddr.addr[3], /* 5 4 3 idx */ + bdAddr.addr[2], bdAddr.addr[1], bdAddr.addr[0]); /* 2 1 0 idx */ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connCtState:%x", connCtState); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connTgState:%x", connTgState); + if (connCtState == PROFILE_STATE_CONNECTED || connTgState == PROFILE_STATE_CONNECTED) + { + return true; + } + return false; + } + + void PlayersModel::set_phone_music_play_state(avrcp_key_operation_t notify) + { + #if 0 + int ret; + int playerState; + bd_addr_t bdAddr={0}; + uapi_get_br_address(&bdAddr); //获取手机蓝牙地址 + int a2dp_play_stat = a2dp_src_get_playing_state(&bdAddr); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[a2dp_play_stat]%d", a2dp_play_stat); + switch(notify) + { + case AVRCP_KEY_PLAY://播放 + if(a2dp_play_stat == A2DP_IS_PLAYING) + return; + ret = a2dp_src_start_playing(&bdAddr);//设置手机音乐的状态为播放 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[a2dp_src_start_playing],ret:%x", ret); + playerState = AVRCP_PLAY_STATUS_PLAYING; + break; + case AVRCP_KEY_STOP: //停止 + ret = a2dp_src_stop_playing(&bdAddr);//设置手机的状态停止 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[a2dp_src_stop_playing],ret:%x", ret); + playerState = AVRCP_PLAY_STATUS_STOPPED; + break; + case AVRCP_KEY_PAUSE://暂停 + ret = a2dp_src_suspend_playing(&bdAddr);//设置手机的状态暂停 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[a2dp_src_suspend_playing],ret:%x", ret); + playerState = AVRCP_PLAY_STATUS_PAUSED; + break; + default: + playerState = AVRCP_PLAY_STATUS_STOPPED; + break; + } + avrcp_tg_notify_playback_status_changed((unsigned char)(playerState)); + #endif + } } #ifdef __cplusplus 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 3d5c1cb4d..a4b3cafa4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -580,13 +580,13 @@ void ButtonOnClickListener::PlayerButtonOnClick() return; } - if(PlayersListGroup::GetInstance()->GetCase().IsEmpty()) //若当前歌曲列表为空他跳转到音乐列表进行提示 + if(PlayersListGroup::GetInstance()->GetCase().IsEmpty() && !PlayersModel::GetInstance()->GetMusicSource()) //若当前歌曲列表为空且为本地音乐他跳转到音乐列表进行提示 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "current playersCaseList_ is empty!!"); playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED); playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW,PlayersView::MUSIC_LIST_VIEW); return; - } + } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "play_or_pause_Button OnClick"); uint8_t state = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; @@ -615,6 +615,19 @@ void ButtonOnClickListener::PlayerButtonOnClick() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[PlayerButtonOnClick] calling phone"); return; } + if(PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && PlayersModel::GetInstance()->GetMusicSource()) + { + if (state == UICheckBox::UICheckBoxState::SELECTED) + { + PlayersModel::GetInstance()->set_phone_music_play_state(AVRCP_KEY_PLAY); + } + else if (state == UICheckBox::UICheckBoxState::UNSELECTED) + { + PlayersModel::GetInstance()->set_phone_music_play_state(AVRCP_KEY_PAUSE); + } + return; + } + if (state == UICheckBox::UICheckBoxState::SELECTED) { /* start play */ PlayersModel::GetInstance()->ConnectBtAndLocalPlay(connCtState, connTgState, playerState); diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index f4e911078..b950eec17 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -38,7 +38,7 @@ namespace OHOS void MainStopWatchPresenter::OnStart() { Presenter::OnStart(); - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏 + // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏 } void MainStopWatchPresenter::OnPause(void) @@ -56,7 +56,7 @@ namespace OHOS void MainStopWatchPresenter::OnStop(void) { Presenter::OnStop(); - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 取消长亮屏 + // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 取消长亮屏 } /// @brief 设置复选框和按钮