增加错误信息提醒
authorxue <2144439972@qq.com>
Mon, 29 Sep 2025 09:24:28 +0000 (17:24 +0800)
committerxue <2144439972@qq.com>
Mon, 29 Sep 2025 09:24:28 +0000 (17:24 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp

index 4d542c8..9bc21af 100644 (file)
@@ -521,7 +521,23 @@ static void HandChatStaminaNotify(Request *request)
 void HandApiErrorNotify(Request *request)
 {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandApiErrorNotify msg_id = %d", request->msgId);
-    std::string value(static_cast<char*>(request->data), request->len);
+    
+    if (request->data == nullptr || request->len <= 0) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandApiErrorNotify: invalid data");
+        return;
+    }
+    
+    // 解析接收到的数据:API错误信息
+    std::string message(static_cast<char*>(request->data), request->len);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandApiErrorNotify message = %s", message.c_str());
+    
+    // 通过图形服务调用 ThunderBirdModel 的处理函数
+    GraphicService::GetInstance()->PostGraphicEvent(
+        [message]() {
+            if (OHOS::ThunderBirdModel::GetInstance()) {
+                OHOS::ThunderBirdModel::GetInstance()->HandleApiError(message.c_str());
+            }
+        });
 }
 
 // 绑定和解绑通知
@@ -538,8 +554,8 @@ void HandBindAndUnbindNotify(Request *request)
 void HandScreenImageDownloadSuccessNotify(Request *request)
 {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandScreenImageDownloadSuccessNotify msg_id = %d", request->msgId);
-    // GraphicService::GetInstance()->PostGraphicEvent(
-    //     std::bind(&OHOS::ThunderBirdModel::HandleScreenImageDownloadSuccess,OHOS::ThunderBirdModel::GetInstance()));
+    GraphicService::GetInstance()->PostGraphicEvent(
+        std::bind(&OHOS::ThunderBirdModel::HandleScreenImageDownloadSuccess,OHOS::ThunderBirdModel::GetInstance()));
 }
 
 // 更新文本内容通知