summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adb/services.cpp1
-rwxr-xr-xbootstat/boot_reason_test.sh38
-rw-r--r--bootstat/bootstat.cpp2
-rw-r--r--reboot/reboot.c1
4 files changed, 39 insertions, 3 deletions
diff --git a/adb/services.cpp b/adb/services.cpp
index dbf71d36d..ca345568d 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -150,6 +150,7 @@ static bool reboot_service_impl(int fd, const char* arg) {
150 150
151 sync(); 151 sync();
152 152
153 if (!reboot_arg || !reboot_arg[0]) reboot_arg = "adb";
153 std::string reboot_string = android::base::StringPrintf("reboot,%s", reboot_arg); 154 std::string reboot_string = android::base::StringPrintf("reboot,%s", reboot_arg);
154 if (!android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_string)) { 155 if (!android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_string)) {
155 WriteFdFmt(fd, "reboot (%s) failed\n", reboot_string.c_str()); 156 WriteFdFmt(fd, "reboot (%s) failed\n", reboot_string.c_str());
diff --git a/bootstat/boot_reason_test.sh b/bootstat/boot_reason_test.sh
index 7b0b0daeb..d78980878 100755
--- a/bootstat/boot_reason_test.sh
+++ b/bootstat/boot_reason_test.sh
@@ -427,8 +427,8 @@ test_factory_reset() {
427 adb reboot >&2 427 adb reboot >&2
428 wait_for_screen 428 wait_for_screen
429 EXPECT_PROPERTY sys.boot.reason reboot,factory_reset 429 EXPECT_PROPERTY sys.boot.reason reboot,factory_reset
430 EXPECT_PROPERTY persist.sys.boot.reason reboot, 430 EXPECT_PROPERTY persist.sys.boot.reason "reboot,.*"
431 report_bootstat_logs reboot,factory_reset reboot, \ 431 report_bootstat_logs reboot,factory_reset reboot, reboot,adb \
432 "-bootstat: Failed to read /data/misc/bootstat/build_date: No such file or directory" \ 432 "-bootstat: Failed to read /data/misc/bootstat/build_date: No such file or directory" \
433 "-bootstat: Failed to parse boot time record: /data/misc/bootstat/build_date" 433 "-bootstat: Failed to parse boot time record: /data/misc/bootstat/build_date"
434} 434}
@@ -599,6 +599,38 @@ test_userrequested_shutdown() {
599 report_bootstat_logs shutdown,userrequested 599 report_bootstat_logs shutdown,userrequested
600} 600}
601 601
602[ "USAGE: test_shell_reboot
603
604shell reboot test:
605- adb shell reboot
606- (wait until screen is up, boot has completed)
607- adb shell getprop sys.boot.reason
608- NB: should report reboot,shell" ]
609test_shell_reboot() {
610 echo "INFO: expected duration of ${TEST} test roughly 45 seconds" >&2
611 adb shell reboot
612 wait_for_screen
613 EXPECT_PROPERTY sys.boot.reason reboot,shell
614 EXPECT_PROPERTY persist.sys.boot.reason reboot,shell
615 report_bootstat_logs reboot,shell
616}
617
618[ "USAGE: test_adb_reboot
619
620adb reboot test:
621- adb reboot
622- (wait until screen is up, boot has completed)
623- adb shell getprop sys.boot.reason
624- NB: should report reboot,adb" ]
625test_adb_reboot() {
626 echo "INFO: expected duration of ${TEST} test roughly 45 seconds" >&2
627 adb reboot
628 wait_for_screen
629 EXPECT_PROPERTY sys.boot.reason reboot,adb
630 EXPECT_PROPERTY persist.sys.boot.reason reboot,adb
631 report_bootstat_logs reboot,adb
632}
633
602[ "USAGE: ${0##*/} [-s SERIAL] [tests] 634[ "USAGE: ${0##*/} [-s SERIAL] [tests]
603 635
604Mainline executive to run the above tests" ] 636Mainline executive to run the above tests" ]
@@ -650,7 +682,7 @@ if [ -z "$*" ]; then
650 if [ -z "${2}" ]; then 682 if [ -z "${2}" ]; then
651 # Hard coded should shell fail to find them above (search/permission issues) 683 # Hard coded should shell fail to find them above (search/permission issues)
652 eval set ota cold factory_reset hard battery unknown kernel_panic warm \ 684 eval set ota cold factory_reset hard battery unknown kernel_panic warm \
653 thermal_shutdown userrequested_shutdown 685 thermal_shutdown userrequested_shutdown shell_reboot adb_reboot
654 fi 686 fi
655 if [ X"nothing" = X"${1}" ]; then 687 if [ X"nothing" = X"${1}" ]; then
656 shift 1 688 shift 1
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 418c71165..a0a9307a9 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -202,6 +202,8 @@ const std::map<std::string, int32_t> kBootReasonMap = {
202 {"reboot,ota", 63}, 202 {"reboot,ota", 63},
203 {"reboot,factory_reset", 64}, 203 {"reboot,factory_reset", 64},
204 {"reboot,", 65}, 204 {"reboot,", 65},
205 {"reboot,shell", 66},
206 {"reboot,adb", 67},
205}; 207};
206 208
207// Converts a string value representing the reason the system booted to an 209// Converts a string value representing the reason the system booted to an
diff --git a/reboot/reboot.c b/reboot/reboot.c
index 007dfbaa4..f0cf40c89 100644
--- a/reboot/reboot.c
+++ b/reboot/reboot.c
@@ -56,6 +56,7 @@ int main(int argc, char *argv[])
56 56
57 if (argc > optind) 57 if (argc > optind)
58 optarg = argv[optind]; 58 optarg = argv[optind];
59 if (!optarg || !optarg[0]) optarg = "shell";
59 60
60 prop_len = snprintf(property_val, sizeof(property_val), "%s,%s", cmd, optarg); 61 prop_len = snprintf(property_val, sizeof(property_val), "%s,%s", cmd, optarg);
61 if (prop_len >= sizeof(property_val)) { 62 if (prop_len >= sizeof(property_val)) {