Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 277eca13 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

adb: reboot: last boot command default

For reboot [reboot_arg] requests via either reboot or adb reboot,
if reboot_arg is empty then report "shell" or "adb" respectively.

Test: boot_reason_test.sh shell_reboot adb_reboot
Bug: 63736262
Change-Id: Ie613d9e62db6a705885e4e7520aede27af3aa1b9
parent b304f6d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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());
+35 −3
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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)) {