From f92038b3a3ee9fd3f1e4f938f8b341f5dd5d4b60 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 26 Oct 2024 16:39:06 +0800 Subject: [PATCH] =?utf8?q?#834,=E8=A7=A3=E5=86=B3=EF=BC=8C=E6=89=8B?= =?utf8?q?=E8=A1=A8=E4=B8=8EIOS=20APP=E7=BB=91=E5=AE=9A=E8=BF=9E=E6=8E=A5?= =?utf8?q?=EF=BC=8C=E6=89=8B=E8=A1=A8=E7=AB=AF=E6=89=BE=E6=89=8B=E6=9C=BA?= =?utf8?q?=EF=BC=8C=E6=89=8B=E6=9C=BA=E7=AB=AF=E5=8F=AA=E9=9C=87=E5=8A=A8?= =?utf8?q?=E4=B8=8D=E5=93=8D=E9=93=83bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/findphone/src/FindPhonePresenter.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp index 635b86ad3..9b114434b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 10:47:40 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-30 11:13:11 + * @LastEditTime: 2024-10-26 16:32:24 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp */ #include "AppViewIDs.h" @@ -16,6 +16,7 @@ #include "bleEvent.h" #include "findphone/include/FindPhoneModel.h" #include "gfx_utils/mem_check.h" +#include "bluetooth/include/BluetoothModel.h" namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -45,6 +46,12 @@ namespace OHOS void FindPhonePresenter::OnStart() { Presenter::OnStart(); + if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() && + uapi_a2dp_snk_get_device_connect_state()) // 判断与手机蓝牙是否连接和判断a2dp是否是已连接状态 + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "FindPhonePresenter::OnStart a2dp is connected"); + uapi_a2dp_snk_disconnect(); // 先断开a2dp + } } void FindPhonePresenter::OnPause(void) @@ -61,6 +68,12 @@ namespace OHOS { Presenter::OnStop(); FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_STOP); // 发送指令停止震动 + if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() && + !uapi_a2dp_snk_get_device_connect_state()) // 判断与手机蓝牙是否连接和判断a2dp是为连接状态 + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "FindPhonePresenter::OnStop a2dp is not connected"); + uapi_a2dp_snk_connect(); // 主动连接a2dp + } } bool FindPhonePresenter::OnClick(UIView &view, const ClickEvent &event) -- 2.17.1