diff options
-rw-r--r-- | adb/services.cpp | 1 | ||||
-rwxr-xr-x | bootstat/boot_reason_test.sh | 38 | ||||
-rw-r--r-- | bootstat/bootstat.cpp | 2 | ||||
-rw-r--r-- | reboot/reboot.c | 1 |
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) { sync(); + if (!reboot_arg || !reboot_arg[0]) reboot_arg = "adb"; std::string reboot_string = android::base::StringPrintf("reboot,%s", reboot_arg); if (!android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_string)) { 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() { adb reboot >&2 wait_for_screen EXPECT_PROPERTY sys.boot.reason reboot,factory_reset - EXPECT_PROPERTY persist.sys.boot.reason reboot, - report_bootstat_logs reboot,factory_reset reboot, \ + EXPECT_PROPERTY persist.sys.boot.reason "reboot,.*" + report_bootstat_logs reboot,factory_reset reboot, reboot,adb \ "-bootstat: Failed to read /data/misc/bootstat/build_date: No such file or directory" \ "-bootstat: Failed to parse boot time record: /data/misc/bootstat/build_date" } @@ -599,6 +599,38 @@ test_userrequested_shutdown() { report_bootstat_logs shutdown,userrequested } +[ "USAGE: test_shell_reboot + +shell reboot test: +- adb shell reboot +- (wait until screen is up, boot has completed) +- adb shell getprop sys.boot.reason +- NB: should report reboot,shell" ] +test_shell_reboot() { + echo "INFO: expected duration of ${TEST} test roughly 45 seconds" >&2 + adb shell reboot + wait_for_screen + EXPECT_PROPERTY sys.boot.reason reboot,shell + EXPECT_PROPERTY persist.sys.boot.reason reboot,shell + report_bootstat_logs reboot,shell +} + +[ "USAGE: test_adb_reboot + +adb reboot test: +- adb reboot +- (wait until screen is up, boot has completed) +- adb shell getprop sys.boot.reason +- NB: should report reboot,adb" ] +test_adb_reboot() { + echo "INFO: expected duration of ${TEST} test roughly 45 seconds" >&2 + adb reboot + wait_for_screen + EXPECT_PROPERTY sys.boot.reason reboot,adb + EXPECT_PROPERTY persist.sys.boot.reason reboot,adb + report_bootstat_logs reboot,adb +} + [ "USAGE: ${0##*/} [-s SERIAL] [tests] Mainline executive to run the above tests" ] @@ -650,7 +682,7 @@ if [ -z "$*" ]; then if [ -z "${2}" ]; then # Hard coded should shell fail to find them above (search/permission issues) eval set ota cold factory_reset hard battery unknown kernel_panic warm \ - thermal_shutdown userrequested_shutdown + thermal_shutdown userrequested_shutdown shell_reboot adb_reboot fi if [ X"nothing" = X"${1}" ]; then 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 = { {"reboot,ota", 63}, {"reboot,factory_reset", 64}, {"reboot,", 65}, + {"reboot,shell", 66}, + {"reboot,adb", 67}, }; // 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[]) if (argc > optind) optarg = argv[optind]; + if (!optarg || !optarg[0]) optarg = "shell"; prop_len = snprintf(property_val, sizeof(property_val), "%s,%s", cmd, optarg); if (prop_len >= sizeof(property_val)) { |