From dafc4021fcd7f4e222f1f13e71552dcdcd3f06a6 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 12 Aug 2024 16:21:15 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0CAT1=20=E8=BF=87=E7=A8=8B?= =?utf8?q?=E4=B8=AD=E5=B1=8F=E8=94=BD=20HFP=E7=94=B5=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../phoneservice/src/PhoneService.cpp | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index 83b146b67..c28d2f8e3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -27,6 +27,8 @@ #include "msg_center_msg.h" #include "cat1_server_hal.h" #include "BluetoothModel.h" +#include "notification_manager.h" +#include "CallerLogModel.h" #ifdef __cplusplus extern "C" { #endif @@ -632,6 +634,11 @@ static void ScoConnectPro(void) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[ScoConnectPro] CallNum:%d, ScoFlag:%d", g_currCallNum, g_scoFlag); // 通知sco建立连接(或通话转移:手机 -> 手表) + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) + { + return; + } ScoStatusCb(HFP_SCO_STATE_CONNECTED); if (g_currCallState == HFP_HF_CALL_STATE_ACTIVE && g_scoFlag == HFP_SCO_STATE_CONNECTED) { // The call is transferred from the phone to the watch. Need to show the call notification view. @@ -648,6 +655,12 @@ static void ScoDisconnectPro(void) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[ScoDisconnectPro] start CallState:%d", g_currCallState); + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) + { + return; + } + ScoStatusCb(HFP_SCO_STATE_DISCONNECTED); if (g_currCallState == HFP_HF_CALL_STATE_ACTIVE && g_scoFlag == HFP_SCO_STATE_DISCONNECTED) { // The call is transferred from the watch to the phone. Need to close the call notification view. @@ -1392,6 +1405,11 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "call is null or BT disconnected connStatus: 0x%X", g_btConnState); return; } + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) + { + return; + } SetCompleteCallFlag(call); CatCallStateChangedInfo(bdAddr, call); @@ -1878,9 +1896,11 @@ int TransCallToMobilePhone(void) int uapi_hfp_disconnect(void) { int ret; - ret = hfp_hf_disconnect(&g_bdAddr); + bd_addr_t bdaddr={0}; + get_phone_addr(&bdaddr); + ret = hfp_hf_disconnect(&bdaddr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: ****%02x %02x %02x %02x g_bdAddr.type: %x\n", - g_bdAddr.addr[3], g_bdAddr.addr[2], g_bdAddr.addr[1], g_bdAddr.addr[0], g_bdAddr.type); /* 3 2 1 0 idx */ + bdaddr.addr[3], bdaddr.addr[2], bdaddr.addr[1], bdaddr.addr[0], bdaddr.type); /* 3 2 1 0 idx */ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[hfp_disconnect] ret:%X", ret); return ret; @@ -1893,8 +1913,8 @@ int uapi_hfp_connect(void) get_phone_addr(&bdaddr); if(false==OHOS::uapi_get_acl_connect_state()) { - // ret= gap_connect_remote_device(&bdaddr); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[gap_connect_remote_device] ret:%X", ret); + // ret= gap_connect_remote_device(&bdaddr); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[gap_connect_remote_device] ret:%X", ret); // ret=OHOS::uapi_set_acl_connect_hfp(); ret=gap_reconnect_media_device(&bdaddr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[gap_connect_remote_device] ret:%X", ret); @@ -1909,7 +1929,7 @@ int uapi_hfp_connect(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: ****%02x %02x %02x %02x g_bdAddr.type: %x\n", - g_bdAddr.addr[3], g_bdAddr.addr[2], g_bdAddr.addr[1], g_bdAddr.addr[0], g_bdAddr.type); /* 3 2 1 0 idx */ + bdaddr.addr[3], bdaddr.addr[2], bdaddr.addr[1], bdaddr.addr[0], bdaddr.type); /* 3 2 1 0 idx */ return ret; } @@ -1917,7 +1937,9 @@ int uapi_hfp_connect(void) int uapi_hfp_connect_state(void) { int ret; - ret = hfp_hf_get_device_connect_state(&g_bdAddr); + bd_addr_t bdaddr={0}; + get_phone_addr(&bdaddr); + ret = hfp_hf_get_device_connect_state(&bdaddr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[hfp_connect_hfp] ret:%d", ret); if(PROFILE_STATE_CONNECTED==ret || PROFILE_STATE_CONNECTING ==ret) return 1; -- 2.17.1