增加debug界面显示gps状态
authorCaisking <Casiking@zhihuishixun.com>
Tue, 1 Jul 2025 09:35:33 +0000 (17:35 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 1 Jul 2025 09:35:33 +0000 (17:35 +0800)
code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h
code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp

index 4574473..c763233 100644 (file)
@@ -50,6 +50,7 @@ namespace OHOS
         std::string get_uart_at_status(void);
         std::string get_current_vote_status(void);
         std::string get_offline_log_status(void);
+        std::string get_gps_status_log(void);
 
 
       private:
index 145184a..0ed7073 100644 (file)
@@ -179,6 +179,9 @@ namespace OHOS
         debugOutputItemInfo[index++] = {index, "CAT1_UPDATA"}; 
         
         debugOutputItemInfo[index++] = {index, "cwm_runtime_log"}; 
+
+        //gps状态日志
+        debugOutputItemInfo[index++] = {index, "gps_status_log"};
      
 
         usedLen = index;
@@ -617,6 +620,35 @@ namespace OHOS
         std::string result = logModel->get_system_mem_info();
         return result;
     }
+    //获取gps状态日志
+    std::string DebugOutputViewEventListener::get_gps_status_log()
+    {
+        std::ostringstream result;
+        result << "gps_status:\n"; // 添加标题
+
+        auto logModel = SystemLogModel::GetInstance();
+        const auto &gps_logs = logModel->get_gps_status_log();
+
+        // 遍历日志并拼接到结果字符串
+        for (const auto &log : gps_logs) {
+            if(log.type == gps_status_type::GPS_SUCCESS)
+            {
+                result << "成功\n";
+            }
+            else if(log.type == gps_status_type::GPS_FAILED)    
+            {
+                result << "失败\n";
+            }
+            std::string timestr;
+            if (log.timestamp == 0) {
+                timestr = "--"; // 默认值
+            } else {
+                timestr = formatTime(log.timestamp);
+            }
+            result << "[" << timestr << "] "<< "\n";
+        }
+        return result.str();
+    }
     std::string DebugOutputViewEventListener::get_nextday_log()
     {
         std::ostringstream result;
@@ -1096,6 +1128,9 @@ namespace OHOS
                 }
             }
             break;
+        case 22:
+            str = get_gps_status_log();
+            break;
         default:
             str = "--";
             break;