summaryrefslogtreecommitdiff
path: root/fastboot/device/variables.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-08-31 16:44:25 -0700
committerDavid Anderson <dvander@google.com>2018-08-31 18:39:28 -0700
commit0f6266305ebf1747c91bafc6609b798ff07b25a3 (patch)
tree086ed68d4c4d6611333e10b54163f13bced78f13 /fastboot/device/variables.cpp
parent1fb3fd72428569fb6be8e7c13180d3dad139076d (diff)
fastbootd: Implement getvar all.
This implements getvar all by invoking each callback and writing an INFO status for each result. For commands that take arguments, the variable handler can specify a function that returns all possible arguments. Currently this only applies to partition variables. Bug: 78793464 Test: fastboot getvar all works Change-Id: I1cf84e06bf67614b6f56171c0ee6ca5d7ac383c9
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r--fastboot/device/variables.cpp34
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;
+}