From: luozheng <1732036298@qq.com> Date: Thu, 4 Dec 2025 09:00:21 +0000 (+0800) Subject: 雷鸟: X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5a4c3ef5fc1acc6bb89b09ce018d6859a0569798;p=mirrors%2FFD230.git 雷鸟: 1.解决蓝牙页面开启扫描定时器后退出未停止定时器bug,2.优化连接新设备ui处理,优化开机连接耳机后, 3.等待网络连接后上报状态 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index c34c3e35e..2137417c3 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -454,6 +454,7 @@ bool BluetoothModel::IsTagConnectNew(void) return tagConnectNew; } +// 设置是否已点击设备请求连接 void BluetoothModel::SetTagScanDeviceClicked(bool tag) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagScanDeviceClicked:%d", tag); @@ -818,12 +819,25 @@ void BluetoothModel::BtGapDiscoveryResultCallbakHandle(const bd_addr_t &bdAddr) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BtGapDiscoveryResultCallback end"); } +//蓝牙取消配对ui处理 +static void UnpairDevice(const bd_addr_t *bdAddr) +{ + if(ThunderBirdMainView::GetInstance()) { + int currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + ThunderBirdMainView::GetInstance()->ChangeView(currentView, + THUNDERBIRD_BLUEVIEW, + ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS_NEW); + } + return; +} + void BtGapPairStatusChangedCallback(const bd_addr_t *bdAddr, int status) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "配对状态变化 addr: ****%02x%02x%02x%02x status: %d\n", bdAddr->addr[3], bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], status); /* addr下标 0 1 2 3 */ if(status == GAP_PAIR_NONE){ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "取消配对"); + GraphicService::GetInstance()->PostGraphicEvent(std::bind(UnpairDevice, bdAddr)); } else if(status == GAP_PAIR_PAIRING){ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "正在配对"); } else if(status == GAP_PAIR_PAIRED){ @@ -938,6 +952,17 @@ static void ACLConnectionSuss(const bd_addr_t &bdAddr) // 回调:ACL连接失败 static void ACLConnectionFail(const bd_addr_t &bdAddr) { + // 如果当前正处于“切换到新耳机”的流程中(用户点了另一台设备准备自动重连), + // 就不要弹出“连接已断开”页面,直接走后续新设备连接流程,避免多余页面跳转。 + BluetoothModel* btModel = BluetoothModel::GetInstance(); + if (btModel != nullptr && (btModel->IsTagConnectNew() || btModel->IsTagScanDeviceClicked())) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "ACLConnectionFail: in switch-device flow, skip DISCONNECT_SUCCESS page"); + // 清掉“需要自动连接新设备”的标记,由后续连接结果负责更新界面 + btModel->SetTagConnectNew(false); + return; + } + BluetoothCaseInfo caseInfo; (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr.addr, BD_ADDR_LEN); unsigned char nameLen = BD_NAME_LEN; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp index 71b104c0c..1775da79a 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp @@ -266,7 +266,7 @@ extern "C" if (ln_ws_get_connection_state() != 2) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: ws not connected"); - return 0; + return -1; } OHOS::BluetoothModel *bluetoothModel = OHOS::BluetoothModel::GetInstance(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdBlueView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdBlueView.h index e1c3e5ccf..775d264a2 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdBlueView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdBlueView.h @@ -88,7 +88,7 @@ namespace OHOS THUNDERBIRD_BULEVIEW_CONNECT_SUCCESS, // 连接成功 THUNDERBIRD_BULEVIEW_DISCONNECT_CONFIRM, // 断连询问 THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS, // 断连成功 - THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS_NEW, // 断连成功(新) + THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS_NEW, // 解绑(新) THUNDERBIRD_BULEVIEW_DISCONNECT_FAILED // 断连失败 }; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 3c006fd1d..3d8c95d80 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -1652,6 +1652,16 @@ extern "C" { #endif do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_VAD_AUTH, NULL, 0); + + + //上报一次耳机状态 + if(ln_bt_report_earphone_connection_status() != 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status failed"); + LOS_Msleep(200); + ln_bt_report_earphone_connection_status();//上报耳机状态 + } + init_falg = true; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index eacebdd19..820410dda 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -925,6 +925,10 @@ namespace OHOS ThunderBirdBlueView::GetInstance()->OnConnectFailed(); ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_BLUEVIEW, ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DEVICE_LIST); break; + case ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS_NEW: + //解绑成功,返回主界面,提示用户解绑成功 + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); + break; } } else if(keyType == KEY_TYPE_VENDOR_DOWN) @@ -1182,6 +1186,7 @@ namespace OHOS ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); break; } + ln_bt_scan_stop(); ln_bt_report_earphone_connection_status(); } }