diff options
author | David Anderson <dvander@google.com> | 2018-09-04 20:41:54 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-04 20:41:54 +0000 |
commit | 33dcdb808b7d60107d527c22815d586b51836836 (patch) | |
tree | 609172cdcf3e5ca919a3526552ef1f27bbe8a209 /fastboot/device/variables.cpp | |
parent | 304308ca3f9903674db9afda6b0dfbdf9c0ba672 (diff) | |
parent | 0f6266305ebf1747c91bafc6609b798ff07b25a3 (diff) |
Merge "fastbootd: Implement getvar all."
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r-- | fastboot/device/variables.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 8eeda98f7..9f3fa7597 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -222,3 +222,37 @@ bool GetIsUserspace(FastbootDevice* /* device */, const std::vector<std::string> *message = "yes"; return true; } + +std::vector<std::vector<std::string>> GetAllPartitionArgsWithSlot(FastbootDevice* device) { + std::vector<std::vector<std::string>> args; + auto partitions = ListPartitions(device); + for (const auto& partition : partitions) { + args.emplace_back(std::initializer_list<std::string>{partition}); + } + return args; +} + +std::vector<std::vector<std::string>> GetAllPartitionArgsNoSlot(FastbootDevice* device) { + auto partitions = ListPartitions(device); + + std::string slot_suffix = device->GetCurrentSlot(); + if (!slot_suffix.empty()) { + auto names = std::move(partitions); + for (const auto& name : names) { + std::string slotless_name = name; + if (android::base::EndsWith(name, "_a") || android::base::EndsWith(name, "_b")) { + slotless_name = name.substr(0, name.rfind("_")); + } + if (std::find(partitions.begin(), partitions.end(), slotless_name) == + partitions.end()) { + partitions.emplace_back(slotless_name); + } + } + } + + std::vector<std::vector<std::string>> args; + for (const auto& partition : partitions) { + args.emplace_back(std::initializer_list<std::string>{partition}); + } + return args; +} |