优化蓝牙
authorxue <2144439972@qq.com>
Sat, 28 Mar 2026 06:14:31 +0000 (14:14 +0800)
committerxue <2144439972@qq.com>
Sat, 28 Mar 2026 06:14:31 +0000 (14:14 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp

index f9254d9..ee49dcb 100644 (file)
@@ -1208,6 +1208,8 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState)
         GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr));
         int earphoneConnectStatus = 1;
         SendMsgToUIService(HAND_BLUETOOTH_EARPHONE_CONNECT_STATUS_NOTIFY, 0, &earphoneConnectStatus, sizeof(earphoneConnectStatus));
+        /* 与回调状态一致上报,避免 ln_bt_report_earphone_connection_status 二次读栈导致错序弹窗 */
+        GraphicService::GetInstance()->PostGraphicEvent([]() { ln_send_bluetooth_status_report("CONNECTED", true); });
     }
 
     if (connState == PROFILE_STATE_DISCONNECTED) {
@@ -1226,9 +1228,8 @@ 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);
         }
+        GraphicService::GetInstance()->PostGraphicEvent([]() { ln_send_bluetooth_status_report("DISCONNECTED", true); });
     }
-    //上报蓝牙耳机连接状态
-    GraphicService::GetInstance()-> PostGraphicEvent([]() { ln_bt_report_earphone_connection_status(true); });  // 显示弹窗
 }
 
 uint8_t A2dpSrcPlayingState=0;
index 04a4bfb..1cb949e 100644 (file)
@@ -146,8 +146,8 @@ extern "C" {
     static void stress_test_save_task(void *arg)
     {
         uint32_t msg = 0;
-        uint32_t copy_count = 0;
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stress_test_save: task started (periodic memcpy only, no file)");
+        UNUSED(arg);
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stress_test_save: task started (periodic memcpy only, no file)");
         for (;;) {
             uint32_t timeout_ms = g_stress_test_active_for_save ? 1000 : osWaitForever;  /* 产测中每 1 秒唤醒 */
             osStatus_t st = osMessageQueueGet(g_stress_save_queue, &msg, nullptr, timeout_ms);
@@ -155,10 +155,6 @@ extern "C" {
             if (st != osOK && g_stress_test_active_for_save) {
                 /* 超时且产测进行中:重复内存拷贝,拉高 CPU */
                 stress_test_do_copy_only();
-                copy_count++;
-                if (copy_count % 10 == 1) {  /* 每 10 秒打印一次,便于确认在运行 */
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stress_test_save: memcpy running, count=%u", copy_count);
-                }
             }
         }
     }
@@ -3511,7 +3507,8 @@ extern "C" {
             if (g_stress_save_queue) {
                 osThreadAttr_t attr = {0};
                 attr.name = "stress_save";
-                attr.stack_size = 1024;
+                /* 原 1024 易 stack overflow;保留足额栈以容纳 osMessageQueueGet 等调用链 */
+                attr.stack_size = 4096;
                 attr.priority = osPriorityBelowNormal;
                 if (osThreadNew(stress_test_save_task, nullptr, &attr) != nullptr) {
                     g_stress_save_created = true;