增加文件下载进度
authorxue <2144439972@qq.com>
Fri, 10 Oct 2025 02:15:45 +0000 (10:15 +0800)
committerxue <2144439972@qq.com>
Fri, 10 Oct 2025 02:15:45 +0000 (10:15 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp

index 2d1e1e2..05054b2 100644 (file)
@@ -100,6 +100,7 @@ static void HandTextUpdateNotify(Request *request);
 static void HandDownloadFileNotify(Request *request);
 static void HandDownloadSuccessNotify(Request *request);
 static void HandDownloadFailNotify(Request *request);
+static void HandDownloadProgressNotify(Request *request);
 static void HandAudioPlaybackEndNotify(Request *request);
 // 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头)
 MsgHandlerEntry msgHandlers[] = {
@@ -117,6 +118,7 @@ MsgHandlerEntry msgHandlers[] = {
     {HAND_DOWNLOAD_FILE_NOTIFY,HandDownloadFileNotify},
     {HAND_DOWNLOAD_SUCCESS_NOTIFY,HandDownloadSuccessNotify},
     {HAND_DOWNLOAD_FAIL_NOTIFY,HandDownloadFailNotify},
+    {HAND_DOWNLOAD_PROGRESS_NOTIFY,HandDownloadProgressNotify},
     {HAND_AUDIO_PLAYBACK_END_NOTIFY,HandAudioPlaybackEndNotify},
 };
 /* -------------------------------------------------------------------------- */
@@ -564,7 +566,7 @@ void HandTextUpdateNotify(Request *request)
 {
     std::string value(static_cast<char*>(request->data), request->len);
     GraphicService::GetInstance()->PostGraphicEvent(
-        std::bind(&OHOS::ThunderBirdModel::SetTextStr,OHOS::ThunderBirdModel::GetInstance(),value.c_str()));
+        std::bind(&OHOS::ThunderBirdModel::SetTextStr,OHOS::ThunderBirdModel::GetInstance(),const_cast<char*>(value.c_str())));
 }
 
 // 下载文件通知
@@ -582,28 +584,35 @@ void HandDownloadSuccessNotify(Request *request)
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDownloadSuccessNotify msg_id = %d", request->msgId);
     int type = *(int *)request->data;
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDownloadSuccessNotify type = %d", type);
-    if(type == 0) //屏保切换
-    {
-        GraphicService::GetInstance()->PostGraphicEvent(
-            std::bind(&OHOS::ThunderBirdModel::HandleScreenImageDownloadSuccess,OHOS::ThunderBirdModel::GetInstance()));
-    }
-    if(type == 1) //表情切换
-    {
-        // GraphicService::GetInstance()->PostGraphicEvent(
-        //     std::bind(&OHOS::ThunderBirdModel::HandleDownloadEmojiSuccess,OHOS::ThunderBirdModel::GetInstance()));
-    }
+    GraphicService::GetInstance()->PostGraphicEvent(
+        std::bind(&OHOS::OtaModel::HandleDownloadSuccess,OHOS::OtaModel::GetInstance(), type));
 }
+
+// 下载进度通知
+void HandDownloadProgressNotify(Request *request)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDownloadProgressNotify msg_id = %d", request->msgId);
+    int progress = *(int *)request->data;
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDownloadProgressNotify progress = %d", progress);
+    GraphicService::GetInstance()->PostGraphicEvent(
+        std::bind(&OHOS::OtaModel::HandleDownloadProgress,OHOS::OtaModel::GetInstance(), progress));
+}
+
 // 下载失败通知
 void HandDownloadFailNotify(Request *request)
 {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDownloadFailNotify msg_id = %d", request->msgId);
     int type = *(int *)request->data;
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandDownloadFailNotify type = %d", type);
+    GraphicService::GetInstance()->PostGraphicEvent(
+        std::bind(&OHOS::OtaModel::HandleDownloadFail,OHOS::OtaModel::GetInstance(), type));
 }
 // 音频播放结束通知
 void HandAudioPlaybackEndNotify(Request *request)
 {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandAudioPlaybackEndNotify msg_id = %d", request->msgId);
+    GraphicService::GetInstance()->PostGraphicEvent(
+        std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackEnd,OHOS::ThunderBirdModel::GetInstance()));
 }
 /* -------------------------------------------------------------------------- */
 #ifdef __cplusplus
index 5d4da4d..36159ed 100644 (file)
@@ -250,6 +250,8 @@ void push_download_fail_notification(int type)
 // 推送文件下载进度通知到UI
 void push_download_progress_notification(int progress)
 {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[DOWNLOAD_SUCCESS] progress=%d", progress);
+    SendMsgToUIService(HAND_DOWNLOAD_PROGRESS_NOTIFY, 0, &progress, sizeof(progress));
 }
 
 //通知音频播放结束了