diff options
Diffstat (limited to 'fastboot/device/utility.cpp')
-rw-r--r-- | fastboot/device/utility.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp index 07ad9028c..7c6ac8993 100644 --- a/fastboot/device/utility.cpp +++ b/fastboot/device/utility.cpp @@ -77,8 +77,7 @@ bool OpenLogicalPartition(FastbootDevice* device, const std::string& partition_n } // namespace -bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle, - bool read) { +bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle) { // We prioritize logical partitions over physical ones, and do this // consistently for other partition operations (like getvar:partition-size). if (LogicalPartitionExists(device, name)) { @@ -90,9 +89,7 @@ bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHan return false; } - 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))); + unique_fd fd(TEMP_FAILURE_RETRY(open(handle->path().c_str(), O_WRONLY | O_EXCL))); if (fd < 0) { PLOG(ERROR) << "Failed to open block device: " << handle->path(); return false; @@ -204,7 +201,12 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) { } bool GetDeviceLockStatus() { - return android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange"; + 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; } bool UpdateAllPartitionMetadata(FastbootDevice* device, const std::string& super_name, |