优化星历下载解压逻辑,支持多天文件解压 3091/1
authorluozheng <1732036298@qq.com>
Thu, 15 Jan 2026 09:47:03 +0000 (17:47 +0800)
committerluozheng <1732036298@qq.com>
Thu, 15 Jan 2026 09:47:03 +0000 (17:47 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativelauncher/include/UiConfig.h
code/sdk/zhihui/utilscpp/custom_utilscpp.cpp

index 95640a2..598e74c 100644 (file)
@@ -631,7 +631,7 @@ namespace OHOS
     static constexpr const char *PNG_APPLIST_SLEEP_IMAGE = APP_LIST_PATH "/sleeping.bin";           // 睡眠
     static constexpr const char *PNG_APPLIST_INFORMATION_IMAGE = APP_LIST_PATH "/information.bin";  // 计算器
     static constexpr const char *PNG_APPLIST_MUSIC_IMAGE = APP_LIST_PATH "/music.bin";              // 音乐
-    static constexpr const char *PNG_APPLIST_SCHEDULE_IMAGE = APP_LIST_PATH "/schedule.bin";
+    static constexpr const char *PNG_APPLIST_SCHEDULE_IMAGE = APP_LIST_PATH "/schedule.bin";        //日程
     static constexpr const char *PNG_APPLIST_SMART_IMAGE = APP_LIST_PATH "/smart.bin";              //语音助手
     static constexpr const char *PNG_APPLIST_CALENDAR_IMAGE = APP_LIST_PATH "/calendar.bin";              //日历
     static constexpr const char *PNG_APPLIST_HRV_IMAGE = APP_LIST_PATH "/hrv.bin";                  //hrv
index f5340f3..727a5fe 100644 (file)
@@ -387,26 +387,8 @@ errcode_t uapi_epo_lzma_decompress(const char* lzma_file_path)
         return ERRCODE_FAIL;
     }
 
-    /* 第一遍扫描,尝试找到AssistInfo_*文件的时间戳,用作目录名 */
-    char assist_ts[32] = {0};
-    long data_start_pos = ftell(fp);
-    for (uint32_t i = 0; i < file_count; i++) {
-        uint16_t filename_len = 0;
-        if (fread(&filename_len, 1, 2, fp) != 2) { break; }
-        if (filename_len == 0 || filename_len > 255) { break; }
-        char filename[256] = {0};
-        if (fread(filename, 1, filename_len, fp) != filename_len) { break; }
-        uint32_t file_size = 0;
-        if (fread(&file_size, 1, 4, fp) != 4) { break; }
-        if (file_size > 0) { (void)fseek(fp, file_size, SEEK_CUR); }
-        if (assist_ts[0] == '\0' && strncmp(filename, "AssistInfo_", strlen("AssistInfo_")) == 0) {
-            extract_timestamp_from_name(filename, assist_ts, sizeof(assist_ts));
-        }
-    }
-    /* 回到文件列表起始位置准备正式解压 */
-    (void)fseek(fp, data_start_pos, SEEK_SET);
-
     int extracted_count = 0;
+    char current_batch_ts[32] = {0}; // 维护当前批次的时间戳(替代原全局assist_ts)
 
     // 遍历每个文件
     for (uint32_t i = 0; i < file_count; i++) {
@@ -441,21 +423,22 @@ errcode_t uapi_epo_lzma_decompress(const char* lzma_file_path)
             break;
         }
 
-        /* 确定目录时间戳:优先用AssistInfo中的时间戳,否则取自身文件名中的时间戳 */
-        char dir_ts[32] = {0};
-        if (assist_ts[0] != '\0') {
-            (void)strncpy(dir_ts, assist_ts, sizeof(dir_ts) - 1);
-        } else {
-            extract_timestamp_from_name(filename, dir_ts, sizeof(dir_ts));
+        // 关键逻辑:遇到AssistInfo_*文件时,更新当前批次时间戳
+        if (strncmp(filename, "AssistInfo_", strlen("AssistInfo_")) == 0) {
+            extract_timestamp_from_name(filename, current_batch_ts, sizeof(current_batch_ts));
+            printf("[uapi_epo_lzma_decompress] Switch to new batch, timestamp: %s (from file: %s)\n", 
+                   current_batch_ts, filename);
         }
-        if (dir_ts[0] == '\0') {
-            printf("[uapi_epo_lzma_decompress] Failed to parse timestamp for file %s\n", filename);
+
+        // 校验当前批次时间戳是否有效(必须先遇到AssistInfo_*才能解压后续文件)
+        if (current_batch_ts[0] == '\0') {
+            printf("[uapi_epo_lzma_decompress] No valid batch timestamp (not found AssistInfo_* yet) for file %s\n", filename);
             break;
         }
 
         /* 生成输出目录并确保存在 */
         char output_dir[128] = {0};
-        int dir_ret = snprintf(output_dir, sizeof(output_dir), "/user/userdata/gnss/%s", dir_ts);
+        int dir_ret = snprintf(output_dir, sizeof(output_dir), "/user/userdata/gnss/%s", current_batch_ts);
         if (dir_ret < 0 || dir_ret >= (int)sizeof(output_dir)) {
             printf("[uapi_epo_lzma_decompress] Failed to build output dir for file %u\n", i);
             break;
@@ -513,7 +496,8 @@ errcode_t uapi_epo_lzma_decompress(const char* lzma_file_path)
             break;
         }
 
-        printf("[uapi_epo_lzma_decompress] Extracted: %s (%u bytes)\n", output_path, file_size);
+        printf("[uapi_epo_lzma_decompress] Extracted: %s (%u bytes) [batch: %s]\n", 
+               output_path, file_size, current_batch_ts);
         extracted_count++;
     }