Switch /data/misc/reboot/last_reboot_reason to persistent property
Switch from /data/misc/reboot/last_reboot_reason to persistent Android property persist.sys.boot.reason for indicating why the device is rebooted or shutdown. persist.sys.boot.reason has a standard as outlined in b/63736262 and the associated investigation. Made adjustments to the values so that we did not create a problem even before we started. Compliance is part of the tests in boot_reason_test.sh. Test: system/core/bootstat/boot_reason_test.sh Bug: 64687998 Change-Id: I812c55a12faf7cb7ff92101009be058ad9958d07
This commit is contained in:
parent
2732a7e023
commit
73e6b49c0c
|
@ -347,14 +347,10 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
|
|||
Timer t;
|
||||
LOG(INFO) << "Reboot start, reason: " << reason << ", rebootTarget: " << rebootTarget;
|
||||
|
||||
android::base::WriteStringToFile(StringPrintf("%s\n", reason.c_str()), LAST_REBOOT_REASON_FILE,
|
||||
S_IRUSR | S_IWUSR, AID_SYSTEM, AID_SYSTEM);
|
||||
property_set(LAST_REBOOT_REASON_PROPERTY, reason.c_str());
|
||||
sync();
|
||||
|
||||
bool is_thermal_shutdown = false;
|
||||
if (cmd == ANDROID_RB_THERMOFF) {
|
||||
is_thermal_shutdown = true;
|
||||
runFsck = false;
|
||||
}
|
||||
bool is_thermal_shutdown = cmd == ANDROID_RB_THERMOFF;
|
||||
|
||||
auto shutdown_timeout = 0ms;
|
||||
if (!SHUTDOWN_ZERO_TIMEOUT) {
|
||||
|
@ -476,10 +472,15 @@ bool HandlePowerctlMessage(const std::string& command) {
|
|||
command_invalid = true;
|
||||
} else if (cmd_params[0] == "shutdown") {
|
||||
cmd = ANDROID_RB_POWEROFF;
|
||||
if (cmd_params.size() == 2 && cmd_params[1] == "userrequested") {
|
||||
// The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
|
||||
// Run fsck once the file system is remounted in read-only mode.
|
||||
run_fsck = true;
|
||||
if (cmd_params.size() == 2) {
|
||||
if (cmd_params[1] == "userrequested") {
|
||||
// The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
|
||||
// Run fsck once the file system is remounted in read-only mode.
|
||||
run_fsck = true;
|
||||
} else if (cmd_params[1] == "thermal") {
|
||||
// run_fsck is false to avoid delay
|
||||
cmd = ANDROID_RB_THERMOFF;
|
||||
}
|
||||
}
|
||||
} else if (cmd_params[0] == "reboot") {
|
||||
cmd = ANDROID_RB_RESTART2;
|
||||
|
@ -495,14 +496,11 @@ bool HandlePowerctlMessage(const std::string& command) {
|
|||
<< err;
|
||||
}
|
||||
}
|
||||
// If there is an additional bootloader parameter, pass it along
|
||||
if (cmd_params.size() == 3) {
|
||||
// If there is an additional parameter, pass it along
|
||||
if ((cmd_params.size() == 3) && cmd_params[2].size()) {
|
||||
reboot_target += "," + cmd_params[2];
|
||||
}
|
||||
}
|
||||
} else if (command == "thermal-shutdown") { // no additional parameter allowed
|
||||
// run_fsck is false to avoid delay
|
||||
cmd = ANDROID_RB_THERMOFF;
|
||||
} else {
|
||||
command_invalid = true;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string&
|
|||
|
||||
/* Reboot / shutdown the system.
|
||||
* cmd ANDROID_RB_* as defined in android_reboot.h
|
||||
* reason Reason string like "reboot", "userrequested"
|
||||
* reason Reason string like "reboot", "shutdown,userrequested"
|
||||
* rebootTarget Reboot target string like "bootloader". Otherwise, it should be an
|
||||
* empty string.
|
||||
* runFsck Whether to run fsck after umount is done.
|
||||
|
|
|
@ -35,11 +35,11 @@ int android_reboot(int cmd, int flags __unused, const char* arg) {
|
|||
restart_cmd = "shutdown";
|
||||
break;
|
||||
case ANDROID_RB_THERMOFF:
|
||||
restart_cmd = "thermal-shutdown";
|
||||
restart_cmd = "shutdown,thermal";
|
||||
break;
|
||||
}
|
||||
if (!restart_cmd) return -1;
|
||||
if (arg) {
|
||||
if (arg && arg[0]) {
|
||||
ret = asprintf(&prop_value, "%s,%s", restart_cmd, arg);
|
||||
} else {
|
||||
ret = asprintf(&prop_value, "%s", restart_cmd);
|
||||
|
|
|
@ -29,8 +29,8 @@ __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"
|
||||
/* Android reboot reason stored in this property */
|
||||
#define LAST_REBOOT_REASON_PROPERTY "persist.sys.boot.reason"
|
||||
|
||||
/* Reboot or shutdown the system.
|
||||
* This call uses ANDROID_RB_PROPERTY to request reboot to init process.
|
||||
|
|
|
@ -430,7 +430,6 @@ on post-fs-data
|
|||
mkdir /data/misc/boottrace 0771 system shell
|
||||
mkdir /data/misc/update_engine 0700 root root
|
||||
mkdir /data/misc/trace 0700 root root
|
||||
mkdir /data/misc/reboot 0700 system system
|
||||
# profile file layout
|
||||
mkdir /data/misc/profiles 0771 system system
|
||||
mkdir /data/misc/profiles/cur 0771 system system
|
||||
|
|
Loading…
Reference in New Issue