diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-09-08 02:47:41 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-08 02:47:41 +0000 |
commit | e9997f8152442bd99732efc8c39c1278c61b55a0 (patch) | |
tree | 0529b9ce635cd3b0f69e493898c10e97fd0822bf /fastboot/device/variables.cpp | |
parent | 756e28ee0c40abd33beb9f700345351435d0e88e (diff) | |
parent | bf9f8d1a643b7586af009ec65b1358859e3aea64 (diff) |
Merge "Integrate with fastboot HAL to get partition type"
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r-- | fastboot/device/variables.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index a9601896d..75352489e 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -31,6 +31,9 @@ using ::android::hardware::boot::V1_0::BoolResult; using ::android::hardware::boot::V1_0::Slot; +using ::android::hardware::fastboot::V1_0::FileSystemType; +using ::android::hardware::fastboot::V1_0::Result; +using ::android::hardware::fastboot::V1_0::Status; constexpr int kMaxDownloadSizeDefault = 0x20000000; constexpr char kFastbootProtocolVersion[] = "0.4"; @@ -195,6 +198,47 @@ bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& ar return true; } +bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args, + std::string* message) { + if (args.size() < 1) { + *message = "Missing argument"; + return false; + } + std::string partition_name = args[0]; + auto fastboot_hal = device->fastboot_hal(); + if (!fastboot_hal) { + *message = "Fastboot HAL not found"; + return false; + } + + FileSystemType type; + Result ret; + auto ret_val = + fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) { + type = fs_type; + ret = result; + }); + if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) { + *message = "Unable to retrieve partition type"; + } else { + switch (type) { + case FileSystemType::RAW: + *message = "raw"; + return true; + case FileSystemType::EXT4: + *message = "ext4"; + return true; + case FileSystemType::F2FS: + *message = "f2fs"; + return true; + default: + *message = "Unknown file system type"; + } + } + + return false; +} + bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args, std::string* message) { if (args.size() < 1) { |