pgnss指针置空,运动界面gps开始改成同步
authorluozheng <1732036298@qq.com>
Fri, 3 Apr 2026 02:35:09 +0000 (10:35 +0800)
committerluozheng <1732036298@qq.com>
Fri, 3 Apr 2026 02:35:09 +0000 (10:35 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp
code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c

index 60de425..4d49fb9 100644 (file)
@@ -3269,11 +3269,13 @@ void TraingModel::SetGpsOpen(bool open) {
    TraingModel *model = TraingModel::GetInstance();
    if (gps_timer_count == 5 && model != nullptr && !model->GetGpsOpen()) {
      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开启gps");
-     GraphicService::GetInstance()->PostGraphicEvent([]() {
-       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "异步执行gnss_start()");
-       gnss_start();
-     });
-     model->SetGpsOpen(true);
+    //  GraphicService::GetInstance()->PostGraphicEvent([]() {
+    //    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "异步执行gnss_start()");
+    //    gnss_start();
+    //  });
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "同步执行gnss_start()");
+    gnss_start();
+    model->SetGpsOpen(true);
    }
    gps_data_t send_gps_data = {0};
    gps_data_t *gps_data = getPGPSGlobaldata();
index 4a5abf9..d8c583c 100644 (file)
@@ -1013,8 +1013,16 @@ static int check_agnss_folder_expired(void)
     // 检查内存分配是否成功
     if (candidate_folder_path == NULL || candidate_folder_name == NULL) {
         printf("ERROR: Failed to allocate memory for candidate folder variables\n");
-        if (candidate_folder_path != NULL) free(candidate_folder_path);
-        if (candidate_folder_name != NULL) free(candidate_folder_name);
+        if (candidate_folder_path != NULL) 
+        {
+            free(candidate_folder_path);
+            candidate_folder_path = NULL;
+        }
+        if (candidate_folder_name != NULL) 
+        {
+            free(candidate_folder_name);
+            candidate_folder_name = NULL;
+        }
         closedir(dir);
         return 1;
     }
@@ -1113,7 +1121,9 @@ static int check_agnss_folder_expired(void)
     // 如果找到了完整的有效文件夹,直接返回
     if (found_valid_folder) {
         free(candidate_folder_path);
+        candidate_folder_path = NULL;
         free(candidate_folder_name);
+        candidate_folder_name = NULL;
         return 0; // 未过期
     }
     
@@ -1153,18 +1163,24 @@ static int check_agnss_folder_expired(void)
                         free(g_current_agnss_folder);
                         g_current_agnss_folder = NULL;
                         free(candidate_folder_path);
+                        candidate_folder_path = NULL;
                         free(candidate_folder_name);
+                        candidate_folder_name = NULL;
                         return 1; // 失败
                     }
                 } else {
                     printf("ERROR: Failed to allocate memory for g_current_agnss_folder\n");
                     free(candidate_folder_path);
+                    candidate_folder_path = NULL;
                     free(candidate_folder_name);
+                    candidate_folder_name = NULL;
                     return 1; // 失败
                 }
                 
                 free(candidate_folder_path);
+                candidate_folder_path = NULL;
                 free(candidate_folder_name);
+                candidate_folder_name = NULL;
                 return 0; // 未过期,文件已完整
             }
             
@@ -1181,7 +1197,9 @@ static int check_agnss_folder_expired(void)
     
     printf("No valid AGNSS folder found within 24 hours with 26 files\n");
     free(candidate_folder_path);
+    candidate_folder_path = NULL;
     free(candidate_folder_name);
+    candidate_folder_name = NULL;
     return 1; // 过期
 }