// 死机文件列表
debugOutputItemInfo[index++] = {index, "shutdown_file_list"};
// 睡眠数据
- debugOutputItemInfo[index++] = {index, "sleep_time"};
+ debugOutputItemInfo[index++] = {index, "sleep_data"};
// 系统空闲内存
debugOutputItemInfo[index++] = {index, "system_free_memory"};
// nextday执行日志
return oss.str(); // 返回以换行符分隔的文件名字符串
}
- // è\8e·å\8f\96ç\9d¡ç\9c æ\97¶é\97´æ\88³
- std::string DebugOutputViewEventListener::get_sleep_time(void)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_sleep_time");
- do_custom_fileoperate_service_check_msg(
- CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ, nullptr, 0);
- LOS_Msleep(100);
- std::string result = "asleep_time:" + get_sleep_asleep_time_str() + " ";
- result += "wake_time:" + get_sleep_wake_time_str() + " ";
- return result;
- }
+ // è\8e·å\8f\96ç\9d¡ç\9c æ\95°æ\8d®
+ static const char *SLEEP_DATA_PATH = "/user/userdata/sleep";
+ // 获取睡眠数据
+ std::string DebugOutputViewEventListener::get_sleep_time(void) {
+ std::string result;
+ uint8_t falg = 0;
+ result += "--------------------\n";
+ // 进行文件读取
+ do_custom_fileoperate_service_check_msg(
+ CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ, nullptr, 0);
+ LOS_Msleep(100); // 等待文件系统准备
+ // 打开目录
+ DIR *dir = opendir(SLEEP_DATA_PATH);
+ if (dir == NULL) {
+ // 如果失败,打印错误信息
+ perror("Error opening directory");
+ return "目前无睡眠数据";
+ }
+
+ struct dirent *entry; // 结构体用于存放目录项信息
+ while ((entry = readdir(dir)) != NULL) {
+ // 忽略当前目录和父目录
+ if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
+ // 检查文件类型是否为普通文件
+ if (entry->d_type == DT_REG) {
+ // 获取文件名并添加到结果中
+ result += entry->d_name;
+ result += "\n"; // 添加换行符以分隔文件名
+ falg = 1;
+ }
+ }
+ }
+
+ // 关闭目录
+ closedir(dir);
+ if(falg == 0) {
+ result += "目录没有文件\n";
+ }
+
+ result += "--------------------\n";
+
+ // 获取当天最新的入睡与醒来时间
+ result += "asleep_time: " + get_sleep_asleep_time_str() + " ";
+ result += "wake_time: " + get_sleep_wake_time_str() + " ";
+
+ return result; // 返回结果字符串
+ }
// 获取系统free内存
std::string DebugOutputViewEventListener::get_free_memory()
{
get_vote_status(buf);
return std::string(buf);
}
+
bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
std::string viewId = view.GetViewId();