Merge "Switch /data/misc/reboot/last_reboot_reason to persistent property" am: 13cb599536

am: 37c6015d9d

Change-Id: Ie884649d96ed020696a2ae6ba5bc46cf0d7ad92d
This commit is contained in:
Mark Salyzyn 2017-08-25 14:37:44 +00:00 committed by android-build-merger
commit a0641b5c13
5 changed files with 19 additions and 22 deletions

View file

@ -347,14 +347,10 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
Timer t; Timer t;
LOG(INFO) << "Reboot start, reason: " << reason << ", rebootTarget: " << rebootTarget; LOG(INFO) << "Reboot start, reason: " << reason << ", rebootTarget: " << rebootTarget;
android::base::WriteStringToFile(StringPrintf("%s\n", reason.c_str()), LAST_REBOOT_REASON_FILE, property_set(LAST_REBOOT_REASON_PROPERTY, reason.c_str());
S_IRUSR | S_IWUSR, AID_SYSTEM, AID_SYSTEM); sync();
bool is_thermal_shutdown = false; bool is_thermal_shutdown = cmd == ANDROID_RB_THERMOFF;
if (cmd == ANDROID_RB_THERMOFF) {
is_thermal_shutdown = true;
runFsck = false;
}
auto shutdown_timeout = 0ms; auto shutdown_timeout = 0ms;
if (!SHUTDOWN_ZERO_TIMEOUT) { if (!SHUTDOWN_ZERO_TIMEOUT) {
@ -476,10 +472,15 @@ bool HandlePowerctlMessage(const std::string& command) {
command_invalid = true; command_invalid = true;
} else if (cmd_params[0] == "shutdown") { } else if (cmd_params[0] == "shutdown") {
cmd = ANDROID_RB_POWEROFF; cmd = ANDROID_RB_POWEROFF;
if (cmd_params.size() == 2 && cmd_params[1] == "userrequested") { if (cmd_params.size() == 2) {
// The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED. if (cmd_params[1] == "userrequested") {
// Run fsck once the file system is remounted in read-only mode. // The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
run_fsck = true; // 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") { } else if (cmd_params[0] == "reboot") {
cmd = ANDROID_RB_RESTART2; cmd = ANDROID_RB_RESTART2;
@ -495,14 +496,11 @@ bool HandlePowerctlMessage(const std::string& command) {
<< err; << err;
} }
} }
// If there is an additional bootloader parameter, pass it along // If there is an additional parameter, pass it along
if (cmd_params.size() == 3) { if ((cmd_params.size() == 3) && cmd_params[2].size()) {
reboot_target += "," + cmd_params[2]; 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 { } else {
command_invalid = true; command_invalid = true;
} }

View file

@ -27,7 +27,7 @@ void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string&
/* Reboot / shutdown the system. /* Reboot / shutdown the system.
* cmd ANDROID_RB_* as defined in android_reboot.h * 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 * rebootTarget Reboot target string like "bootloader". Otherwise, it should be an
* empty string. * empty string.
* runFsck Whether to run fsck after umount is done. * runFsck Whether to run fsck after umount is done.

View file

@ -35,11 +35,11 @@ int android_reboot(int cmd, int flags __unused, const char* arg) {
restart_cmd = "shutdown"; restart_cmd = "shutdown";
break; break;
case ANDROID_RB_THERMOFF: case ANDROID_RB_THERMOFF:
restart_cmd = "thermal-shutdown"; restart_cmd = "shutdown,thermal";
break; break;
} }
if (!restart_cmd) return -1; if (!restart_cmd) return -1;
if (arg) { if (arg && arg[0]) {
ret = asprintf(&prop_value, "%s,%s", restart_cmd, arg); ret = asprintf(&prop_value, "%s,%s", restart_cmd, arg);
} else { } else {
ret = asprintf(&prop_value, "%s", restart_cmd); ret = asprintf(&prop_value, "%s", restart_cmd);

View file

@ -29,8 +29,8 @@ __BEGIN_DECLS
/* Properties */ /* Properties */
#define ANDROID_RB_PROPERTY "sys.powerctl" #define ANDROID_RB_PROPERTY "sys.powerctl"
/* Android reboot reason stored in this file */ /* Android reboot reason stored in this property */
#define LAST_REBOOT_REASON_FILE "/data/misc/reboot/last_reboot_reason" #define LAST_REBOOT_REASON_PROPERTY "persist.sys.boot.reason"
/* Reboot or shutdown the system. /* Reboot or shutdown the system.
* This call uses ANDROID_RB_PROPERTY to request reboot to init process. * This call uses ANDROID_RB_PROPERTY to request reboot to init process.

View file

@ -434,7 +434,6 @@ on post-fs-data
mkdir /data/misc/boottrace 0771 system shell mkdir /data/misc/boottrace 0771 system shell
mkdir /data/misc/update_engine 0700 root root mkdir /data/misc/update_engine 0700 root root
mkdir /data/misc/trace 0700 root root mkdir /data/misc/trace 0700 root root
mkdir /data/misc/reboot 0700 system system
# profile file layout # profile file layout
mkdir /data/misc/profiles 0771 system system mkdir /data/misc/profiles 0771 system system
mkdir /data/misc/profiles/cur 0771 system system mkdir /data/misc/profiles/cur 0771 system system