From: xue <2144439972@qq.com> Date: Fri, 10 Oct 2025 02:15:45 +0000 (+0800) Subject: 增加文件下载进度 X-Git-Tag: V1.0.9_20251128_194606_LN~268^2~7 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=f8eaec35f7b70798384972b0645948b45ad71b5b;p=mirrors%2FFD230.git 增加文件下载进度 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp index 2d1e1e217..05054b273 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp @@ -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(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(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 diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp index 5d4da4d93..36159ed1e 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp @@ -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)); } //通知音频播放结束了