From 2d304af32ae4d3489175966e3431bcd481ff51c1 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Wed, 9 Oct 2024 11:49:05 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9=E8=93=9D=E7=89=99=E8=B0=83?= =?utf8?q?=E8=AF=95=E7=AA=97=E5=8F=A3=20=E4=BF=AE=E6=94=B9=E6=94=AF?= =?utf8?q?=E4=BB=98=E5=AE=9D=E5=B9=BF=E6=92=AD=E5=BC=80=E5=90=AF=E4=BD=8D?= =?utf8?q?=E7=BD=AE=20=E4=BF=AE=E6=94=B9=E7=9B=AE=E6=A0=87=E8=BE=BE?= =?utf8?q?=E6=88=90=E7=95=8C=E9=9D=A2=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/alipay/src/AlipayMainView.cpp | 6 ++++ .../nativeui/alipay/src/AlipayPresenter.cpp | 3 +- .../nativeui/bluetooth/src/BluetoothModel.cpp | 18 +++++++--- .../ble_service/bleservice/bleService.c | 19 ++++++++++- .../ble_service/bleservice/bleService.h | 2 ++ .../debug_output_notification.cpp | 33 ++++++++++++------- .../src/notify/goal_notification.cpp | 10 ++++-- 7 files changed, 70 insertions(+), 21 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayMainView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayMainView.cpp index db33303b4..5f07ed6aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayMainView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayMainView.cpp @@ -8,6 +8,7 @@ #include "AlipayMainView.h" #include "UiConfig.h" #include "alipay_feature.h" +#include "custom_utils.h" namespace OHOS { #define ALIPAY_BIND_SUCCESS_RES_TIMER_LENGTH 3000 @@ -468,6 +469,11 @@ bool AlipayMainView::ChangeBindView(int16 thisView) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlipayMainView::ChangeBindView"); AlipayModel::GetInstance()->AlipayStartBind(); + + /**启动alipay蓝牙服务*/ + + start_alipay_ble_service(); + if (container[thisView] == nullptr) { alipayBind = new AlipayBind(presenter_); if (alipayBind == nullptr) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp index cc5a9536d..aade43587 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alipay/src/AlipayPresenter.cpp @@ -60,8 +60,7 @@ void AlipayPresenter::OnStart() return; Presenter::OnStart(); - /**启动alipay蓝牙服务*/ - start_alipay_ble_service(); + /* -------------------------------- 设置支付宝界面常亮 ------------------------------- */ alipayMode_->AlipayScreenControl(true); /* -------------------------------------------------------------------------- */ 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 ae376d014..0a9b3c13c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -1143,6 +1143,7 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_CONNECTED); GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr)); SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0); + uapi_dev_runtime_set_earphone_connect_stat(1); } if (connState == PROFILE_STATE_DISCONNECTED) { @@ -1154,7 +1155,9 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) if (!ret) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "a2dp disc: gap_br_set_bt_scan_mode ret = 0x%x", ret); } + uapi_dev_runtime_set_earphone_connect_stat(0); } + } static void A2dpSrcPlayingStateChanged(bd_addr_t *bdAddr, int playState) @@ -1208,8 +1211,9 @@ static void BleAdvStopCallback(uint8_t advId, adv_status_t status) static void BleAdvTerminateCallback(uint8_t advId, adv_status_t status) { if (g_sample_adv_id == advId) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvTerminateCallback advId: %d, status:%d\n", advId, status); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "?????????? BleAdvTerminateCallback advId: %d, status:%d\n", advId, status); BluetoothModel::GetInstance()->SetAdvStartState(false); + // 此处开广播是为了实验室测试需要,客户需要自己修改 BleAdvStart(); } @@ -1844,10 +1848,16 @@ int uapi_disconnect_remote_device() int uapi_get_acl_connect_state() { - if( ALC_State_flag==GAP_ACL_STATE_CONNECTED )//|| ALC_State_flag ==GAP_ACL_STATE_LE_DISCONNECTED) - return 1; + bd_addr_t bdaddr={0}; + uapi_get_br_address(&bdaddr); + if (bt_is_acl_connected(&bdaddr)) + { + return 1; + } else - return 0; + { + return 0; + } } int uapi_set_acl_connect_hfp() diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index bbb73ee17..de9ba2a2c 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -230,7 +230,21 @@ void br_adv_stop(void) { gap_br_set_bt_scan_mode(GAP_SCAN_MODE_NONE, 0); } +//留档保存,方便后面查看此数据是否正确 +static uint8_t save_adv_data[BLE_ADV_DATA_MAX_LENGTH] = {0}; +void get_adv_data(char *data) +{ + uint32_t data_len=0; + for(int i=0;i BLE_SCAN_DATA_LENTH){ scan_data_len = BLE_SCAN_DATA_LENTH; } + // + memcpy_s(save_adv_data,BLE_ADV_DATA_MAX_LENGTH,adv_data,BLE_ADV_DATA_MAX_LENGTH); + adv_data_info.scan_rsp_data = scan_data;//扫描数据 adv_data_info.scan_rsp_length = scan_data_len;//扫描长度 adv_data_info.adv_data = adv_data;//广播数据 adv_data_info.adv_length = adv_data_len;//广播长度 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "adv_data_info.adv_length:%u. scan_data_len:%d\r\n", adv_data_len,scan_data_len); + gap_ble_set_adv_data(adv_id, &adv_data_info); return; @@ -1359,7 +1377,6 @@ static void svr_ble_adv_stop_cb(uint8_t adv_id, adv_status_t status) if (adv_id == BLE_ADV_ID) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"svr_ble_adv_stop_cb adv_id: %d, status:%d\n", adv_id, status); ble_adv_start=0; - } } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h index 0b3c40c8a..a830a4b38 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.h @@ -73,6 +73,8 @@ bool get_ble_connect(void); bool get_ble_adv_status(void); +void get_adv_data(char *data); + #ifdef __cplusplus } #endif diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index 5d95b98f2..0a7c191df 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -46,7 +46,7 @@ #include #include "bleService.h" #include "sleep/include/SleepModel.h" - +#include "BluetoothModel.h" namespace OHOS { @@ -126,24 +126,33 @@ namespace OHOS return (str); } + static std::string getCurrentWatchadvdata() + { + uint32_t len = 64; + char *buf_advdata = (char *)malloc(len); + if (buf_advdata == NULL) + return ""; + get_adv_data(buf_advdata); + + std::string str = std::string(buf_advdata); + printf("%s | %s \n", buf_advdata, str.c_str()); + + free(buf_advdata); + return (str); + } + + + std::string DebugOutputViewEventListener::get_bt_runtime_status_t(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_bt_runtime_status_t"); std::string result = "bt_powerOn:" + std::to_string(uapi_dev_runtime_get_bt_powerstat()) + " "; result += "bt_ble_connectstat:" + std::to_string(get_ble_connect()) + " "; - result += "bt_br_connectstat:" + std::to_string(uapi_dev_runtime_get_br_connect_stat()) + " "; + result += "bt_br_connectstat:" + std::to_string(uapi_get_acl_connect_state()) + " "; result += "bt_earphone_connectstat:" + std::to_string(uapi_dev_runtime_get_earphone_connect_stat()) + " "; - result += "android_app_connected:" + std::to_string(uapi_dev_runtime_get_android_connection_status()) + " "; - result += "ble_kumi_service_handler: "; - result += "ble_factory_service_handler: "; - result += "ble_alipay_service_handler: "; - result += "ble_hrs_service_handler: "; - result += "ble_hid_service_handler: "; - result += "ble_ancs_client_id:" + std::to_string(uapi_dev_runtime_get_ancs_clientid()) + " "; - result += "ad2p_service_handler: "; - result += "spp_service_handler: "; - result += "hfp_service_handler: "; + result += "android_app_connected:" + std::to_string(get_ble_pair()) + " "; result += "localAddress:" + (getCurrentWatchMacAddress()) + " "; +result += "advdata:" + (getCurrentWatchadvdata()) + " "; result += "ble广播状态:" + std::to_string(get_ble_adv_status()); // 蓝牙ble广播开关,基础信息如,地址,广播状态 diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp index 7f8d745f8..49a4610cd 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp @@ -65,11 +65,17 @@ namespace OHOS } if(imageAnimator) { - + imageAnimator->Stop(); + FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94); delete imageAnimator; imageAnimator = nullptr; } - + if(labelgettag) + { + + delete labelgettag; + labelgettag = nullptr; + } RootView::GetInstance()->Remove(getView); -- 2.17.1