* @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"
#include "bleEvent.h"
#include "findphone/include/FindPhoneModel.h"
#include "gfx_utils/mem_check.h"
+#include "bluetooth/include/BluetoothModel.h"
namespace OHOS
{
// 当前Presenter属性实例化的内存指针
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)
{
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)