namespace OHOS {
enum class SystemLogType {
- POWER_ON = 0, // 开机
- POWER_OFF, // 关机
- RESTART, // 重启
- FACTORY_RESET, // 恢复出厂设置
- SOFTWARE_UPDATE, // 更新
+ POWER_ON = 0, // 开机
+ POWER_OFF, // 关机
+ POWER_OFF_LOW_BATTERY, // 低电量关机
+ RESTART, // 重启
+ FACTORY_RESET, // 恢复出厂设置
+ SOFTWARE_UPDATE, // 更新
};
struct SystemLogData {
void stop_report_log(void);
void resume_report_log(void);
void update_version_report_log(void);
+void set_low_battery_shutdown_flag(bool enable);
void start_report_nextday_log_start(void);
void start_report_nextday_log_end(void);
void nextday_clear_popup_windows_log(void);
OHOS::SystemLogModel::GetInstance()->saveLog(systemlog);
}
+// 低电量关机标志,由业务在触发关机前设置
+static bool g_low_battery_shutdown = false;
+
+void set_low_battery_shutdown_flag(bool enable)
+{
+ g_low_battery_shutdown = enable;
+}
+
// 关机保存
-void start_report_log(void) { report_log(OHOS::SystemLogType::POWER_OFF); }
+void start_report_log(void)
+{
+ if (g_low_battery_shutdown) {
+ report_log(OHOS::SystemLogType::POWER_OFF_LOW_BATTERY);
+ g_low_battery_shutdown = false;
+ } else {
+ report_log(OHOS::SystemLogType::POWER_OFF);
+ }
+}
// 重启保存
void stop_report_log(void) { report_log(OHOS::SystemLogType::RESTART); }
case SystemLogType::POWER_OFF:
uapi_save_runtime_log(RUNTIME_LOG_POWER_OFF);//TOOD*
break;
+ case SystemLogType::POWER_OFF_LOW_BATTERY:
+ // 运行时日志沿用关机码,只在 SystemLogType 上区分“低电量关机”
+ uapi_save_runtime_log(RUNTIME_LOG_POWER_OFF);
+ break;
case SystemLogType::RESTART:
uapi_save_runtime_log(RUNTIME_LOG_REBOOT);//TOOD*
break;
#include "linux/delay.h"
#include "components/ui_circle_progress.h"
#include "uicomponents/UIComponents.h"
+#include "system/include/SystemLogModelC.h"
#include "charge_notification.h"
#include <service/graphic_service.h>
msleep(500);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
if(battery_falg==4)
+ {
shutdown_reboot_prejobs(REBOOT_TYPE);
+ }
else
+ {
+ // 低电量触发的关机,标记为“低电量关机”日志
+ ::set_low_battery_shutdown_flag(true);
shutdown_reboot_prejobs(SHUTDOWN_TYPE);
+ }
// uapi_poweroff_device(); // 关机
}
case SystemLogType::POWER_OFF:
str << "关机:";
break;
+ case SystemLogType::POWER_OFF_LOW_BATTERY:
+ str << "低电量关机:";
+ break;
case SystemLogType::RESTART:
str << "重启:";
break;
#endif
battery_check_chargement();
charger_plug_event_ui_sendmsg_toUI(1);
+ // 记录一次充电线插入时刻的电池数据,用于后续统计充电时间
+ battery_save_data();
}else if (mail.comm.event == BATTERY_CMD_CHARGE_UNPLUG) {
// PRINT("[battery][service] charger_plug_event_ui_sendmsg_toUI unplugged \n");
oncharging_status = 0;
disable_charge();
#endif
charger_plug_event_ui_sendmsg_toUI(0);
+ // 记录一次充电线拔出时刻的电池数据,用于后续统计充电时间
+ battery_save_data();
}else if(mail.comm.event == BATTERY_CMD_FIRST_CHECK)
{
battery_check_chargement();