From 782dcc1996f6b39ef9e085d7153c2f109ff2609a Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 29 Apr 2019 11:23:16 -0700 Subject: Consolidate the codes that handle reboot/shutdown. Test: Choose `Reboot system now`, `Power off`, `Reboot to bootloader` from recovery UI respectively. Test: `adb reboot recovery` while under sideload mode. Change-Id: I0f3d55b80b472178ea4f6970b29cd9df0778b639 --- otautil/include/otautil/sysutil.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'otautil/include') diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h index 692a99e9d..48e9011e5 100644 --- a/otautil/include/otautil/sysutil.h +++ b/otautil/include/otautil/sysutil.h @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef _OTAUTIL_SYSUTIL -#define _OTAUTIL_SYSUTIL +#pragma once #include #include +#include #include #include "rangeset.h" @@ -101,13 +101,14 @@ class MemMapping { std::vector ranges_; }; -// Wrapper function to trigger a reboot, by additionally handling quiescent reboot mode. The -// command should start with "reboot," (e.g. "reboot,bootloader" or "reboot,"). -bool reboot(const std::string& command); +// Reboots the device into the specified target, by additionally handling quiescent reboot mode. +// 'target' can be an empty string, which indicates booting into Android. +bool Reboot(std::string_view target); + +// Triggers a shutdown. +bool Shutdown(); // Returns a null-terminated char* array, where the elements point to the C-strings in the given // vector, plus an additional nullptr at the end. This is a helper function that facilitates // calling C functions (such as getopt(3)) that expect an array of C-strings. std::vector StringVectorToNullTerminatedArray(const std::vector& args); - -#endif // _OTAUTIL_SYSUTIL -- cgit v1.2.3