#include "vibrator_service.h"
#include "wearable_log.h"
#include <array>
+
#include <cmsis_os2.h>
#include <cstdint>
#include <custom_runtime.h>
#include <custom_utils.h>
+#include <dirent.h>
#include <fstream>
#include <iomanip>
#include <iostream>
debugOutputItemInfo[index++] = {4, "system_log"};
//电池服务
debugOutputItemInfo[index++] = {5, "battery_service"};
+ //死机文件列表
+ debugOutputItemInfo[index++] = {6, "shutdown_file_list"};
usedLen = index;
/* -------------------------------- Add data -------------------------------- */
for (uint8_t i = 0; i < usedLen; i++)
str << "[" << timestr << "] "<< "\n"; // 拼接日志内容
}
- return str.str(); // 返回拼接后的字符串
+ return str.str(); // 返回拼接后的字符串
}
-
-
+
// 获取电池相关信息
std::string DebugOutputViewEventListener::get_battery_info() {
// 获取电池温度
return oss.str();
}
+
+ // 死机文件名称列表
+ static const char *SHUTDOWN_PATH = "/user/tar";
+ std::string DebugOutputViewEventListener::get_shutdown_info() {
+ std::ostringstream oss;
+
+ // 打开目录
+ DIR *dir = opendir(SHUTDOWN_PATH);
+ if (dir == nullptr) {
+ return "死机目录不存在或者目录下不存在文件";
+ }
+
+ struct dirent *entry;
+ while ((entry = readdir(dir)) != nullptr) {
+ // 跳过. 和 ..
+ if (entry->d_name[0] != '.') {
+ oss << entry->d_name << "\n"; // 逐行添加
+ }
+ }
+
+ closedir(dir); // 关闭目录
+ return oss.str(); // 返回以换行符分隔的文件名字符串
+ }
+
bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
std::string viewId = view.GetViewId();
case 5:
str = get_battery_info();
break;
+ case 6:
+ str = get_shutdown_info();
+ break;
default:
str = "--";
break;