summaryrefslogtreecommitdiffstats
path: root/otautil
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-05-04 08:01:13 +0200
committerTao Bao <tbao@google.com>2018-05-04 08:18:38 +0200
commit2c52639d01cb2ff9f0a805e0dda72d39a5487d88 (patch)
treef376f2005a2bc514781e4f94ca176378ab9a9f68 /otautil
parentotautil: Rename dir/sys/thermal utils. (diff)
downloadandroid_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.tar
android_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.tar.gz
android_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.tar.bz2
android_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.tar.lz
android_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.tar.xz
android_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.tar.zst
android_bootable_recovery-2c52639d01cb2ff9f0a805e0dda72d39a5487d88.zip
Diffstat (limited to 'otautil')
-rw-r--r--otautil/Android.bp1
-rw-r--r--otautil/include/otautil/sysutil.h4
-rw-r--r--otautil/sysutil.cpp10
3 files changed, 15 insertions, 0 deletions
diff --git a/otautil/Android.bp b/otautil/Android.bp
index 0be019c06..b058f7b35 100644
--- a/otautil/Android.bp
+++ b/otautil/Android.bp
@@ -48,6 +48,7 @@ cc_library_static {
static_libs: [
"libselinux",
+ "libcutils",
],
},
},
diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h
index 52f6d20a7..649f8ffae 100644
--- a/otautil/include/otautil/sysutil.h
+++ b/otautil/include/otautil/sysutil.h
@@ -50,4 +50,8 @@ class MemMapping {
std::vector<MappedRange> 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);
+
#endif // _OTAUTIL_SYSUTIL
diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp
index e6385c4e9..ab1513088 100644
--- a/otautil/sysutil.cpp
+++ b/otautil/sysutil.cpp
@@ -28,8 +28,10 @@
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
+#include <cutils/android_reboot.h>
bool MemMapping::MapFD(int fd) {
struct stat sb;
@@ -201,3 +203,11 @@ MemMapping::~MemMapping() {
};
ranges_.clear();
}
+
+bool reboot(const std::string& command) {
+ std::string cmd = command;
+ if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
+ cmd += ",quiescent";
+ }
+ return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
+}