summaryrefslogtreecommitdiffstats
path: root/otautil/sysutil.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-04-30 00:19:32 +0200
committerandroid-build-merger <android-build-merger@google.com>2019-04-30 00:19:32 +0200
commit3486372d69782073b5cebe07dee14ff580a2531f (patch)
treed97b289dc37b820fa70a79b7a1907cbbebbb4bf3 /otautil/sysutil.cpp
parentMerge "Add install/wipe_device.cpp." (diff)
parentMerge "Consolidate the codes that handle reboot/shutdown." (diff)
downloadandroid_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.tar
android_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.tar.gz
android_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.tar.bz2
android_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.tar.lz
android_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.tar.xz
android_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.tar.zst
android_bootable_recovery-3486372d69782073b5cebe07dee14ff580a2531f.zip
Diffstat (limited to 'otautil/sysutil.cpp')
-rw-r--r--otautil/sysutil.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp
index 8366fa0ac..2b4861809 100644
--- a/otautil/sysutil.cpp
+++ b/otautil/sysutil.cpp
@@ -214,14 +214,21 @@ MemMapping::~MemMapping() {
ranges_.clear();
}
-bool reboot(const std::string& command) {
- std::string cmd = command;
- if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
+bool Reboot(std::string_view target) {
+ std::string cmd = "reboot," + std::string(target);
+ // Honor the quiescent mode if applicable.
+ if (target != "bootloader" && target != "fastboot" &&
+ android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent";
}
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
}
+bool Shutdown() {
+ // "shutdown" doesn't need a "reason" arg nor a comma.
+ return android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown");
+}
+
std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args) {
std::vector<char*> result(args.size());
std::transform(args.cbegin(), args.cend(), result.begin(),