#834,解决,手表与IOS APP绑定连接,手表端找手机,手机端只震动不响铃bug
authorluozheng <1732036298@qq.com>
Sat, 26 Oct 2024 08:39:06 +0000 (16:39 +0800)
committeraliyun:aliyun0384013184_1JeGs <3449750381@qq.com>
Sat, 26 Oct 2024 09:05:54 +0000 (09:05 +0000)
code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp

index 635b86a..9b11443 100644 (file)
@@ -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<FindPhoneView>::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<FindPhoneView>::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)