From 4e5b485ca305571536eb891f2a6c50418419977b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E4=BC=A0=E5=86=9B?= <1224667075@qq.com> Date: Sat, 18 Jan 2025 08:14:21 +0000 Subject: [PATCH] Merge #1637 into sdk602patch0911 from refs/changes/1637/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit cat1电话使用蓝牙接听,修改为不允许中途直接操作蓝牙,仅控制SCO链路 * refs/changes/1637/head: (2 commits squashed) - cat1电话使用蓝牙接听,修改为不允许中途直接操作蓝牙,仅控制SCO链路 - cat耳机操作 增加语言区别 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: Caisking <3449750381@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1637 --- .../nativelauncher/src/NativeLauncher.cpp | 2 +- .../src/BluetoothCaseListAdapter.cpp | 21 ++-- .../src/BluetoothDeviceCaseListAdapter.cpp | 60 +++++++++-- .../bluetooth/src/BluetoothHeadsetEvent.cpp | 4 +- .../bluetooth/src/BluetoothItemView.cpp | 55 ++++++++-- .../nativeui/bluetooth/src/BluetoothModel.cpp | 3 + .../phoneservice/include/PhoneAGService.h | 2 + .../phoneservice/include/PhoneServiceC.h | 5 +- .../phoneservice/src/PhoneAGService.cpp | 102 +++++++++++++++--- .../msg_center/src/msg_center_customer.cpp | 48 +++++---- .../slip/cat1Service/cat1_server.cpp | 5 + .../peripheral/utils/custom_cmd_service.c | 9 +- .../drivers/peripheral/utils/custom_utils.h | 3 + 13 files changed, 245 insertions(+), 74 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 9659051af..f4a5b5470 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -549,7 +549,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLangues error"); } // 初始化所有预加载slice - InitBtHeadsetEvent(); // 蓝牙ct和tg适配初始化 + InitAllNativeSlices(); CallerLogModel::GetInstance()->InitPhoneService(); GoalModel::GetInstance().GoalModelInitdata();//活动数据初始化 diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp index 545186e66..b5acb85a3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp @@ -13,6 +13,9 @@ #include "UiConfig.h" #include "BluetoothModel.h" #include "bluetooth/include/MainBluetoothView.h" +#include "CallerLogModel.h" +#include "custom_utils.h" +#include "notification_manager.h" namespace OHOS { BluetoothCaseListAdapter::~BluetoothCaseListAdapter() @@ -42,7 +45,7 @@ public: } bool OnClick(UIView& view, const ClickEvent& event) override { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListListener"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListListener"); UNUSED(event); BluetoothItemView *itemView = static_cast(&view); // // 二次点击不做响应 @@ -101,16 +104,16 @@ public: if (!( lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0 ) && ret) { - BluetoothModel::GetInstance()->SetTagConnectNew(true); - errcode_t retVal = gap_disconnect_remote_device(lastAddr); + BluetoothModel::GetInstance()->SetTagConnectNew(true); + errcode_t retVal = gap_disconnect_remote_device(lastAddr); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal = %d %02X %02X %02X * * *", retVal, lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]); - } - else - { - mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); - errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret = %d", retVal); + } + else + { + mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); + errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret = %d", retVal); } // 跳转可选页 return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp index dfda43dda..c59fc5b05 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp @@ -12,6 +12,10 @@ #include "wearable_log.h" #include "UiConfig.h" #include "BluetoothPresenter.h" +#include "CallerLogModel.h" +#include "custom_utils.h" +#include "notification_manager.h" +#include "PhoneAGService.h" namespace OHOS { @@ -39,6 +43,7 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override { UNUSED(event); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListListener"); BluetoothItemView *itemView = static_cast(view.GetParent()); BluetoothCaseInfo *g_BluetoothCaseInfo = itemView->GetItemInfo(); SetItemInfo(g_BluetoothCaseInfo); // 保存点击的设备信息 @@ -71,20 +76,57 @@ namespace OHOS ret, lastAddr->addr[0], lastAddr->addr[1], lastAddr->addr[2]); // 地址不是全0并且ret为真 - if (!(lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && - lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0) && - ret) + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) { - BluetoothModel::GetInstance()->SetTagConnectNew(false); - errcode_t retVal = gap_disconnect_remote_device(lastAddr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[gap_disconnect_remote_device] retVal = %d", retVal); + if (!(lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && + lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0) && + ret) + { + if(headset_Is_connect()) + { + if(headset_SCO_Is_connect_extend(lastAddr)) + { + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_DIS_SCO_CONNECT, nullptr, 0); + } + else + { + uint8_t time=0; + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT, &time, sizeof(uint8_t)); + } + } + else + { + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0); + } + + } + else + { + mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); + errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnectRemoteDevice] retVal = %d", retVal); + } + } else { - mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); - errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnectRemoteDevice] retVal = %d", retVal); + if (!(lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && + lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0) && + ret) + { + BluetoothModel::GetInstance()->SetTagConnectNew(false); + errcode_t retVal = gap_disconnect_remote_device(lastAddr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[gap_disconnect_remote_device] retVal = %d", retVal); + } + else + { + mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW); + errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnectRemoteDevice] retVal = %d", retVal); + } } + } else if (view.GetViewType() == UIViewType::UI_IMAGE_VIEW) /*点击的是图片*/ { 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 d8f2355e9..2b10bff3d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp @@ -222,7 +222,7 @@ void MediaStatusCallback(bt_avrcp_tg_evt_status_param *eventStatusParam) void ConnCtStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct update conn stat:%u", state); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "avrcp ct update conn stat:%u", state); if (bdAddr == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bdaddr nullptr"); return; @@ -243,7 +243,7 @@ bd_addr_t *BtAvrcpSrvGetActiveAddr(void) void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp tg update conn stat:%u", state); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "avrcp tg update conn stat:%u", state); if (bdAddr == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bdaddr nullptr"); return; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothItemView.cpp index b0bddd3f2..d793d9898 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothItemView.cpp @@ -11,6 +11,13 @@ #include "player/include/PlayersView.h" #include "ui_resource_image.h" #include "ui_resource_string.h" +#include "CallerLogModel.h" +#include "custom_utils.h" +#include "notification_manager.h" +#include "PhoneAGService.h" +#include "ConfigModel.h" +#include "languagecode/LanguageInit.h" + namespace OHOS { constexpr uint16_t BUTTON_WIDTH = 351; @@ -154,18 +161,46 @@ namespace OHOS return; } /* ------------------------------ 检查ACL链路是否连接。 ------------------------------ */ - bool aclConnected = bt_is_acl_connected((const bd_addr_t *)&infoData.addr); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus aclConnected %d", aclConnected); - if (aclConnected) - { - connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - connectStateLabel.SetTextId(STR_CONNECTED); // 已连接 - } - else + { - connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - connectStateLabel.SetTextId(STR_DISCONNECTED); // 未连接 + bool aclConnected = bt_is_acl_connected((const bd_addr_t *)&infoData.addr); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus aclConnected %d", aclConnected); + if (aclConnected) + { + connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + connectStateLabel.SetTextId(STR_CONNECTED); // 已连接 + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) + { + bool SCOConnected = headset_SCO_Is_connect_extend( (bd_addr_t *)&infoData.addr); + if(SCOConnected) + { + std::string Text = connectStateLabel.GetText(); + + if(ConfigModel::GetInstance()->GetLanguage() == ZH_CN) + { + Text+=" 播放中"; + } + else + { + Text+=" In play"; + } + connectStateLabel.SetText(Text.c_str()); + } + + } + } + else + { + connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + connectStateLabel.SetTextId(STR_DISCONNECTED); // 未连接 + } + } + + + + connectStateLabel.ForceResetText(); connectStateLabel.Invalidate(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index 0bf9d3558..4bc004da7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -54,6 +54,8 @@ #include "ConfigModel.h" #include "PhoneAGService.h" #include "custom_save_runtime.h" +#include "BluetoothHeadsetEvent.h" + namespace OHOS { #define BT_SPP_TASK_STACK_SIZE 2048 @@ -176,6 +178,7 @@ static int bluetooth_init_all(void) uapi_pbap_pce_reg_callback(); BtA2dpInit(); PhoneServiceInit(); + InitBtHeadsetEvent(); // 蓝牙ct和tg适配初始化 if(uapi_dev_runtime_get_safemode_flag()) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneAGService.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneAGService.h index 8bb3cc168..5b6c4c512 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneAGService.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneAGService.h @@ -38,6 +38,8 @@ void cat1_set_headset_volume( unsigned char volume); int cat1_ag_send_call_event( uint32_t event_topic,const char* info); +bool headset_SCO_Is_connect_extend(bd_addr_t *bd_addr); + #endif // void bt_hfp_ag_service_sample_cmd(uint32_t cmd_id, const char **params, int32_t params_cnt); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h index 71a72f112..01ffbd79c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h @@ -30,11 +30,14 @@ int32_t PhoneAudioSetMicMuteCat1(bool isMute); void cat1_audio_stop(void); -void cat1_connect_sco_(void); +void cat1_connect_sco_(uint8_t); void cat1_disconn_sco_(void); void cat1_start_SCO_audio_(void); + +void hfp_ag_cmd_conn_last_hfp(void); + #ifdef __cplusplus } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp index 611788142..c48f912af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp @@ -33,6 +33,9 @@ #include "CallerLogModel.h" #include "custom_utils.h" #include "voice_call_volte_sample_wrapper.h" +#include "BluetoothModel.h" +#include "BluetoothDeviceListView.h" +#include "ui_list.h" #define SAMPLE_HFP_TASK_STACK_SIZE 0x1600 @@ -80,7 +83,7 @@ typedef struct { static hfp_cind_info_t g_sample_hfp_cind_info = {0}; -static const bd_addr_t AG_bd_addr={0}; +static bd_addr_t AG_bd_addr={0}; static void sample_hfp_ag_print_addr(const bd_addr_t *bd_addr) @@ -104,6 +107,9 @@ static int32_t g_hdl_up_modem = -1; static int32_t g_hdl_dn_modem = -1; +static int8_t AG_connect_state=0; + + #ifndef MEMORY_MINI static int32_t audio_stream_init(void) { @@ -221,6 +227,7 @@ static void sample_hfp_ag_set_spk_volume(uint8_t volume) } + static void sample_hfp_ag_conn_state_changed_callback(const bd_addr_t *bd_addr, profile_connect_state_t state) { sample_hfp_ag_print_addr(bd_addr); @@ -231,18 +238,23 @@ static void sample_hfp_ag_conn_state_changed_callback(const bd_addr_t *bd_addr, if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) { - cat1_connect_sco_(); + // cat1_connect_sco_(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"电话状态\n"); + uint8_t sleep_time=500; + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT, &sleep_time, sizeof(sleep_time)); } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"电话结束\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"未电话状态\n"); } } if(state==PROFILE_STATE_DISCONNECTED) { } - + AG_connect_state=state; + memcpy_s((void*)&AG_bd_addr,sizeof(bd_addr_t),bd_addr,sizeof(bd_addr_t)); + } @@ -266,6 +278,28 @@ static void PostGraphicEvent(void (*fun)(void)) } #endif +static void connectedHandle() +{ + OHOS::BluetoothModel::GetInstance()->SetTagDisconnectView(false); + OHOS::BluetoothDeviceListView *bluetoothDeviceListView =OHOS:: BluetoothDeviceListView::GetInstance(); + if (bluetoothDeviceListView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothDeviceListView == nullptr"); + return; + } + OHOS::UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList(); + if (deviceList == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisconnectedHandle deviceList nullptr"); + return; + } + deviceList->RefreshList(); + // BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance(); + // if (bluetoothOptionsView == nullptr) { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothOptionsView == nullptr"); + // return; + // } + // bluetoothOptionsView->RefreshText(); +} + void HFP_SCO_STATE_CONNECTEDPro(void) @@ -285,6 +319,7 @@ void HFP_SCO_STATE_CONNECTEDPro(void) } } + connectedHandle(); } @@ -303,6 +338,7 @@ void HFP_SCO_STATE_DISCONNECTEDPro(void) do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0); } + connectedHandle(); } @@ -357,6 +393,12 @@ static void sample_hfp_ag_codec_changed_callback(const bd_addr_t *bd_addr, hfp_a } +void hfp_ag_cmd_conn_last_hfp(void) +{ + bd_addr_t *lastAddr = OHOS::BluetoothModel::GetInstance()->GetLastConnedAddr(); + hfp_ag_cmd_conn_hfp(lastAddr); +} + static void sample_hfp_ag_volume_changed_callback(const bd_addr_t *bd_addr, hfp_volume_type_t type, uint8_t volume) { sample_hfp_ag_print_addr(bd_addr); @@ -503,7 +545,7 @@ errcode_t hfp_ag_cmd_disconn_hfp(const bd_addr_t *bd_addr) /* */ void hfp_ag_cmd_conn_sco(const bd_addr_t *bd_addr ) { - + // if(headset_Is_connect) errcode_t ret = (errcode_t)hfp_ag_audio_connect(bd_addr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u %02X %02X %02X %02X %02X %02X\n", ret,bd_addr->addr[5] ,bd_addr->addr[4],bd_addr->addr[3],bd_addr->addr[2],bd_addr->addr[1],bd_addr->addr[0]); @@ -879,13 +921,15 @@ static void sample_hfp_ag_cmd_send_indicator_val(const char **params, int32_t pa bool headset_Is_connect(void) { - int state = hfp_ag_get_device_connect_state(BtAvrcpSrvGetActiveAddr()); - if(state==PROFILE_STATE_CONNECTED) + // int state = hfp_ag_get_device_connect_state(&AG_bd_addr); + sample_hfp_ag_print_addr(&AG_bd_addr); + if(AG_connect_state==PROFILE_STATE_CONNECTED) { return true; } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"NO PROFILE_STATE_CONNECTED"); return false; } } @@ -893,7 +937,7 @@ bool headset_Is_connect(void) bool headset_SCO_Is_connect(void) { - int state = hfp_ag_get_sco_connect_state(BtAvrcpSrvGetActiveAddr()); + int state = hfp_ag_get_sco_connect_state(&AG_bd_addr); if(state==PROFILE_STATE_CONNECTED) { return true; @@ -905,12 +949,32 @@ bool headset_SCO_Is_connect(void) } +bool headset_SCO_Is_connect_extend(bd_addr_t *bd_addr) +{ + sample_hfp_ag_print_addr(bd_addr); + int sco_state = hfp_ag_get_sco_connect_state(bd_addr); + int ag_state= hfp_ag_get_device_connect_state(bd_addr); + bool ACL_state= bt_is_acl_connected(bd_addr); + if(sco_state==PROFILE_STATE_CONNECTED && ag_state==PROFILE_STATE_CONNECTED && ACL_state==true) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"PROFILE_STATE_CONNECTED"); + return true; + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"NO PROFILE_STATE_CONNECTED"); + return false; + } +} + -void cat1_connect_sco_(void) +void cat1_connect_sco_(uint8_t time) { //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE); #ifdef SUPPORT_CAT1_HFP_AG_SERV - hfp_ag_cmd_conn_sco(BtAvrcpSrvGetActiveAddr()); + if(time) + osal_msleep(time); + hfp_ag_cmd_conn_sco(&AG_bd_addr); #endif } @@ -920,7 +984,7 @@ void cat1_disconn_sco_(void) { //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE); #ifdef SUPPORT_CAT1_HFP_AG_SERV - hfp_ag_cmd_disconn_sco(BtAvrcpSrvGetActiveAddr()); + hfp_ag_cmd_disconn_sco(&AG_bd_addr); #endif } @@ -928,7 +992,7 @@ void cat1_disconn_sco_(void) void cat1_set_headset_volume( unsigned char volume) { //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE); - hfp_ag_set_volume(BtAvrcpSrvGetActiveAddr(),HFP_VOLUME_SPEAKER,volume); + hfp_ag_set_volume(&AG_bd_addr,HFP_VOLUME_SPEAKER,volume); } @@ -958,28 +1022,32 @@ int cat1_ag_send_call_event( uint32_t event_topic, const char* info) phone_info.service=4; phone_info.num_len=strlen(info); memcpy_s(phone_info.number,HFP_AG_PHONENUM_MAX_DIGITS,info,phone_info.num_len); + phone_info.name_len=strlen(info); phone_info.alpha_str[0]=0; } switch (event_topic) { case TOPIC_EVENT_CAT1_INCOMMING: - ret=hfp_ag_send_network_incoming_event(BtAvrcpSrvGetActiveAddr(),&phone_info); + ret=hfp_ag_send_network_incoming_event(&AG_bd_addr,&phone_info); break; case TOPIC_EVENT_CAT1_CALLCONNTED: - ret=hfp_ag_send_answer_call_event(BtAvrcpSrvGetActiveAddr()); + ret=hfp_ag_send_answer_call_event(&AG_bd_addr); break; case TOPIC_EVENT_CAT1_CALLENDED: - ret=hfp_ag_send_finish_call_event(BtAvrcpSrvGetActiveAddr(),HFP_AG_CANCELED_LASTCALL); + ret=hfp_ag_send_finish_call_event(&AG_bd_addr,HFP_AG_CANCELED_LASTCALL); break; case TOPIC_EVENT_CAT1_CALLDIAL: - ret=hfp_ag_send_originate_call_event(BtAvrcpSrvGetActiveAddr()); + ret=hfp_ag_send_originate_call_event(&AG_bd_addr); break; default: ret=ERRCODE_BT_FAIL; break; } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"hfp_ag_send_answer_call_event %d %d\n",event_topic,ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cat1_ag_send_call_event %X %X %X %X %d %X\n", + AG_bd_addr.addr[5],AG_bd_addr.addr[4], + AG_bd_addr.addr[3],AG_bd_addr.addr[2], + event_topic,ret); return ret; } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 2215bf573..33d656954 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -1084,10 +1084,6 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) //uapi_hfp_disconnect(); //来电 recover_call_state(); - #ifdef SUPPORT_CAT1_HFP_AG_SERV - if(headset_Is_connect()) - cat1_ag_send_call_event(TOPIC_EVENT_CAT1_INCOMMING,call_data); - #endif if(NotificationManager::GetInstance()->GetWatchCallStatus() && (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1)) @@ -1150,21 +1146,27 @@ void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req) } AlarmClockModel::GetInstance()->AlarmPlayerStop(); #ifdef SUPPORT_CAT1_HFP_AG_SERV - if(headset_Is_connect()) - { - cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLCONNTED,NULL); - - if(headset_SCO_Is_connect()==false) - { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT, nullptr, 0); - // cat1_connect_sco_(); + if(uapi_dev_runtime_get_earphone_connect_stat()) + { + + if(headset_Is_connect()) + { + if(headset_SCO_Is_connect()==false) + { + cat1_ag_send_call_event(TOPIC_EVENT_CAT1_INCOMMING,CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + } + else + { + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "headset_Is_connect is false"); + } + } else { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0); } - - + cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLCONNTED,NULL); } else #endif @@ -1219,18 +1221,20 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) #ifdef SUPPORT_CAT1_HFP_AG_SERV - if(headset_Is_connect()) + if(uapi_dev_runtime_get_earphone_connect_stat()) { - - cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLDIAL,NULL); - - if(headset_SCO_Is_connect()==false) + if(headset_Is_connect()) { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT, nullptr, 0); + cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLDIAL,NULL); + + if(headset_SCO_Is_connect()) + { + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0); + } } else { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0); } } else diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 7ee7bf7f6..de1b199c9 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -385,6 +385,11 @@ void udp_send_msg_toCat1(uint8_t cmd,char *content) // uart_port_register_irq(UART_BUS_0); osal_irq_enable(UART_1_IRQN); + if(UDP_CMD_DIAL_NUMB==cmd) + { + osal_msleep(50); + } + if (g_skip_cat1_service_udp_transfer == 1) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP," g_skip_cat1_service_udp_transfer \n"); diff --git a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c index c05eed6ba..4e75f92a3 100644 --- a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c @@ -323,17 +323,20 @@ static void custom_cmd_service_check_task(void const *arg) HandleUpdatelcdMode(4); break; case CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT: - cat1_connect_sco_(); + cat1_connect_sco_(mail.data[0]); break; case CUSTOM_CMD_MSG_CAT_HFP_DIS_SCO_CONNECT: cat1_disconn_sco_(); break; - case CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START: + case CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START: cat1_start_SCO_audio_(); break; - case CUSTOM_CMD_MSG_CAT_AUDIO_END: + case CUSTOM_CMD_MSG_CAT_AUDIO_END: cat1_audio_stop(); break; + case CUSTOM_CMD_MSG_CONNECT_AG: + hfp_ag_cmd_conn_last_hfp(); + break; default: diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index e62c688cf..eba7bcfb7 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -263,6 +263,9 @@ uint32_t uapi_calendar_store_date(void); #define CUSTOM_CMD_MSG_CAT_AUDIO_END 0x1A + +#define CUSTOM_CMD_MSG_CONNECT_AG 0x1B + typedef enum { BR_HFP_CONNECT=1, BR_HFP_DISCONNECT, -- 2.17.1