From: xue <2144439972@qq.com> Date: Wed, 14 Jan 2026 09:53:21 +0000 (+0800) Subject: 蓝牙过程中上报过信息则退出时不再上报 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=6b46a47aa2826a57e576c20ab83d617b39cbce55;p=mirrors%2FFD230.git 蓝牙过程中上报过信息则退出时不再上报 --- 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 c1d23d898..090717c2b 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 @@ -319,17 +319,37 @@ extern "C" WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: a2dpState=%d, isEarphoneConnected=%d", a2dpState, isEarphoneConnected); + // 检查当前是否在蓝牙界面,如果在则设置标志 + OHOS::ThunderBirdMainView *mainView = OHOS::ThunderBirdMainView::GetInstance(); + bool isInBlueView = false; + if (mainView != nullptr) { + int currentView = mainView->GetCurrentView(); + isInBlueView = (currentView == 7); + } + if (isEarphoneConnected) { // 蓝牙已连接,上报蓝牙状态 char *bluetoothStatus = "CONNECTED"; do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_BLUETOOTH_STATUS_REPORT, bluetoothStatus, strlen(bluetoothStatus)); + + // 如果当前在蓝牙界面,设置标志表示已上报 + if (isInBlueView && mainView != nullptr) { + mainView->m_btStatusReportedInBlueView_ = true; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: 在蓝牙界面内上报状态,设置标志"); + } } else { // 蓝牙已断开,上报蓝牙状态 char *bluetoothStatus = "DISCONNECTED"; do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_BLUETOOTH_STATUS_REPORT, bluetoothStatus, strlen(bluetoothStatus)); + + // 如果当前在蓝牙界面,设置标志表示已上报 + if (isInBlueView && mainView != nullptr) { + mainView->m_btStatusReportedInBlueView_ = true; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: 在蓝牙界面内上报状态,设置标志"); + } } return 0; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h index ba90700e6..0d9dc2115 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h @@ -126,6 +126,8 @@ namespace OHOS UIImageView *iconView{nullptr}; UIImageView *backGroundView{nullptr}; + bool m_btStatusReportedInBlueView_{false}; // 是否在蓝牙界面内已经上报过状态 + private: void DeInit(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp index 578dc7c34..3e03338b8 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -1161,10 +1161,20 @@ namespace OHOS // 如果屏保模式未开启,才调用InvalidateGroup1(false)隐藏iconView // 如果屏保模式已开启,不应该隐藏iconView,否则会关闭屏保模式 InvalidateGroup1(false); - ln_bt_report_earphone_connection_status(); + + // 如果蓝牙界面已经上报过状态,则退出时不再上报 + if (m_btStatusReportedInBlueView_) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView: 蓝牙界面已上报过状态,退出时不再上报"); + m_btStatusReportedInBlueView_ = false; // 清除标志 + } else { + ln_bt_report_earphone_connection_status(); + } } if(showView == THUNDERBIRD_BLUEVIEW ) { + // 进入蓝牙界面时,清除上报标志 + m_btStatusReportedInBlueView_ = false; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView: 进入蓝牙界面,清除上报标志"); if(hideView == THUNDERBIRD_LULLABYVIEW) {