diff options
Diffstat (limited to 'otautil')
-rw-r--r-- | otautil/Android.bp | 1 | ||||
-rw-r--r-- | otautil/include/otautil/sysutil.h | 4 | ||||
-rw-r--r-- | otautil/sysutil.cpp | 10 |
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); +} |