Loading libcutils/android_reboot.c +45 −0 Original line number Diff line number Diff line Loading @@ -189,11 +189,56 @@ out: free_entries(&ro_entries); } static void save_reboot_reason(int cmd, const char *arg) { FILE *fp; const char *reason = NULL; fp = fopen(LAST_REBOOT_REASON_FILE, "w"); if (fp == NULL) { KLOG_WARNING(TAG, "Error creating " LAST_REBOOT_REASON_FILE ": %s\n", strerror(errno)); return; } switch (cmd) { case ANDROID_RB_RESTART: reason = "restart"; break; case ANDROID_RB_POWEROFF: reason = "power-off"; break; case ANDROID_RB_RESTART2: reason = arg && strlen(arg) ? arg : "restart"; break; case ANDROID_RB_THERMOFF: reason = "thermal-shutdown"; break; default: fprintf(fp,"0x%08X\n", cmd); break; } if (reason) { if (fprintf(fp, "%s\n", reason) < 0) { KLOG_WARNING(TAG, "Error writing " LAST_REBOOT_REASON_FILE ": %s\n", strerror(errno)); } } fclose(fp); } int android_reboot_with_callback( int cmd, int flags __unused, const char *arg, void (*cb_on_remount)(const struct mntent*)) { int ret; save_reboot_reason(cmd, arg); remount_ro(cb_on_remount); switch (cmd) { case ANDROID_RB_RESTART: Loading libcutils/include/cutils/android_reboot.h +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ __BEGIN_DECLS /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" /* Android reboot reason stored in this file */ #define LAST_REBOOT_REASON_FILE "/data/misc/reboot/last_reboot_reason" int android_reboot(int cmd, int flags, const char *arg); int android_reboot_with_callback( int cmd, int flags, const char *arg, Loading Loading
libcutils/android_reboot.c +45 −0 Original line number Diff line number Diff line Loading @@ -189,11 +189,56 @@ out: free_entries(&ro_entries); } static void save_reboot_reason(int cmd, const char *arg) { FILE *fp; const char *reason = NULL; fp = fopen(LAST_REBOOT_REASON_FILE, "w"); if (fp == NULL) { KLOG_WARNING(TAG, "Error creating " LAST_REBOOT_REASON_FILE ": %s\n", strerror(errno)); return; } switch (cmd) { case ANDROID_RB_RESTART: reason = "restart"; break; case ANDROID_RB_POWEROFF: reason = "power-off"; break; case ANDROID_RB_RESTART2: reason = arg && strlen(arg) ? arg : "restart"; break; case ANDROID_RB_THERMOFF: reason = "thermal-shutdown"; break; default: fprintf(fp,"0x%08X\n", cmd); break; } if (reason) { if (fprintf(fp, "%s\n", reason) < 0) { KLOG_WARNING(TAG, "Error writing " LAST_REBOOT_REASON_FILE ": %s\n", strerror(errno)); } } fclose(fp); } int android_reboot_with_callback( int cmd, int flags __unused, const char *arg, void (*cb_on_remount)(const struct mntent*)) { int ret; save_reboot_reason(cmd, arg); remount_ro(cb_on_remount); switch (cmd) { case ANDROID_RB_RESTART: Loading
libcutils/include/cutils/android_reboot.h +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ __BEGIN_DECLS /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" /* Android reboot reason stored in this file */ #define LAST_REBOOT_REASON_FILE "/data/misc/reboot/last_reboot_reason" int android_reboot(int cmd, int flags, const char *arg); int android_reboot_with_callback( int cmd, int flags, const char *arg, Loading