diff options
author | Scott Lobdell <slobdell@google.com> | 2021-04-07 05:35:55 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-04-07 05:35:55 +0000 |
commit | ec6cfacad7283c60a33cfefacf5031247a2f81dc (patch) | |
tree | 5b473e86fc8ab0afc2241b6ac25875b25fa354bd /fastboot/device/utility.cpp | |
parent | 79aff2b0a0653fcafaf9099ad60075f2903e8de1 (diff) | |
parent | 268fff7088f0ab311c2de902178054ce40a42243 (diff) |
Merge "Merge SP1A.210329.001" into s-keystone-qcom-dev
Diffstat (limited to 'fastboot/device/utility.cpp')
-rw-r--r-- | fastboot/device/utility.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp index 7c6ac8993..07ad9028c 100644 --- a/fastboot/device/utility.cpp +++ b/fastboot/device/utility.cpp @@ -77,7 +77,8 @@ bool OpenLogicalPartition(FastbootDevice* device, const std::string& partition_n } // namespace -bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle) { +bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle, + bool read) { // We prioritize logical partitions over physical ones, and do this // consistently for other partition operations (like getvar:partition-size). if (LogicalPartitionExists(device, name)) { @@ -89,7 +90,9 @@ bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHan return false; } - unique_fd fd(TEMP_FAILURE_RETRY(open(handle->path().c_str(), O_WRONLY | O_EXCL))); + int flags = (read ? O_RDONLY : O_WRONLY); + flags |= (O_EXCL | O_CLOEXEC | O_BINARY); + unique_fd fd(TEMP_FAILURE_RETRY(open(handle->path().c_str(), flags))); if (fd < 0) { PLOG(ERROR) << "Failed to open block device: " << handle->path(); return false; @@ -201,12 +204,7 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) { } bool GetDeviceLockStatus() { - std::string cmdline; - // Return lock status true if unable to read kernel command line. - if (!android::base::ReadFileToString("/proc/cmdline", &cmdline)) { - return true; - } - return cmdline.find("androidboot.verifiedbootstate=orange") == std::string::npos; + return android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange"; } bool UpdateAllPartitionMetadata(FastbootDevice* device, const std::string& super_name, |