@@ -347,14 +347,10 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
347
347
Timer t;
348
348
LOG (INFO) << " Reboot start, reason: " << reason << " , rebootTarget: " << rebootTarget;
349
349
350
- android::base::WriteStringToFile ( StringPrintf ( " %s \n " , reason.c_str ()), LAST_REBOOT_REASON_FILE,
351
- S_IRUSR | S_IWUSR, AID_SYSTEM, AID_SYSTEM );
350
+ property_set (LAST_REBOOT_REASON_PROPERTY , reason.c_str ());
351
+ sync ( );
352
352
353
- bool is_thermal_shutdown = false ;
354
- if (cmd == ANDROID_RB_THERMOFF) {
355
- is_thermal_shutdown = true ;
356
- runFsck = false ;
357
- }
353
+ bool is_thermal_shutdown = cmd == ANDROID_RB_THERMOFF;
358
354
359
355
auto shutdown_timeout = 0ms;
360
356
if (!SHUTDOWN_ZERO_TIMEOUT) {
@@ -476,10 +472,15 @@ bool HandlePowerctlMessage(const std::string& command) {
476
472
command_invalid = true ;
477
473
} else if (cmd_params[0 ] == " shutdown" ) {
478
474
cmd = ANDROID_RB_POWEROFF;
479
- if (cmd_params.size () == 2 && cmd_params[1 ] == " userrequested" ) {
480
- // The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
481
- // Run fsck once the file system is remounted in read-only mode.
482
- run_fsck = true ;
475
+ if (cmd_params.size () == 2 ) {
476
+ if (cmd_params[1 ] == " userrequested" ) {
477
+ // The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
478
+ // Run fsck once the file system is remounted in read-only mode.
479
+ run_fsck = true ;
480
+ } else if (cmd_params[1 ] == " thermal" ) {
481
+ // run_fsck is false to avoid delay
482
+ cmd = ANDROID_RB_THERMOFF;
483
+ }
483
484
}
484
485
} else if (cmd_params[0 ] == " reboot" ) {
485
486
cmd = ANDROID_RB_RESTART2;
@@ -495,14 +496,11 @@ bool HandlePowerctlMessage(const std::string& command) {
495
496
<< err;
496
497
}
497
498
}
498
- // If there is an additional bootloader parameter, pass it along
499
- if (cmd_params.size () == 3 ) {
499
+ // If there is an additional parameter, pass it along
500
+ if (( cmd_params.size () == 3 ) && cmd_params[ 2 ]. size () ) {
500
501
reboot_target += " ," + cmd_params[2 ];
501
502
}
502
503
}
503
- } else if (command == " thermal-shutdown" ) { // no additional parameter allowed
504
- // run_fsck is false to avoid delay
505
- cmd = ANDROID_RB_THERMOFF;
506
504
} else {
507
505
command_invalid = true ;
508
506
}
0 commit comments