diff options
Diffstat (limited to 'otautil/sysutil.cpp')
-rw-r--r-- | otautil/sysutil.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp index 8366fa0ac..420db4cac 100644 --- a/otautil/sysutil.cpp +++ b/otautil/sysutil.cpp @@ -94,6 +94,11 @@ BlockMapData BlockMapData::ParseBlockMapFile(const std::string& block_map_path) remaining_blocks -= range_blocks; } + if (remaining_blocks != 0) { + LOG(ERROR) << "Invalid ranges: remaining blocks " << remaining_blocks; + return {}; + } + return BlockMapData(block_dev, file_size, blksize, std::move(ranges)); } @@ -214,14 +219,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(), |