diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-09-28 20:15:46 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-28 20:15:46 +0000 |
commit | 007e52efe002c3864255bf114be2fb9854d3811d (patch) | |
tree | 7447316ae8e5db1d24400243374e4b85392ebc8d | |
parent | bd9751a387d4b587bd284f2661245504f2a92f26 (diff) | |
parent | 4af80901a66ea6b3f62d0b21bb96026ba602eb25 (diff) | |
download | system_core-007e52efe002c3864255bf114be2fb9854d3811d.tar.gz system_core-007e52efe002c3864255bf114be2fb9854d3811d.tar.bz2 system_core-007e52efe002c3864255bf114be2fb9854d3811d.zip |
Merge "Support fastboot variable 'variant'."
-rw-r--r-- | fastboot/constants.h | 1 | ||||
-rw-r--r-- | fastboot/device/commands.cpp | 1 | ||||
-rw-r--r-- | fastboot/device/variables.cpp | 21 | ||||
-rw-r--r-- | fastboot/device/variables.h | 1 |
4 files changed, 24 insertions, 0 deletions
diff --git a/fastboot/constants.h b/fastboot/constants.h index 2a68a2b03..ad2e1a173 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -60,3 +60,4 @@ #define FB_VAR_IS_LOGICAL "is-logical" #define FB_VAR_IS_USERSPACE "is-userspace" #define FB_VAR_HW_REVISION "hw-revision" +#define FB_VAR_VARIANT "variant" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index b7cafac4a..e70de1b6d 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -82,6 +82,7 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args) {FB_VAR_VERSION_BASEBAND, {GetBasebandVersion, nullptr}}, {FB_VAR_PRODUCT, {GetProduct, nullptr}}, {FB_VAR_SERIALNO, {GetSerial, nullptr}}, + {FB_VAR_VARIANT, {GetVariant, nullptr}}, {FB_VAR_SECURE, {GetSecure, nullptr}}, {FB_VAR_UNLOCKED, {GetUnlocked, nullptr}}, {FB_VAR_MAX_DOWNLOAD_SIZE, {GetMaxDownloadSize, nullptr}}, diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 002e04349..77cd4bc25 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -74,6 +74,27 @@ bool GetSecure(FastbootDevice* /* device */, const std::vector<std::string>& /* return true; } +bool GetVariant(FastbootDevice* device, const std::vector<std::string>& /* args */, + std::string* message) { + auto fastboot_hal = device->fastboot_hal(); + if (!fastboot_hal) { + *message = "Fastboot HAL not found"; + return false; + } + + Result ret; + auto ret_val = fastboot_hal->getVariant([&](std::string device_variant, Result result) { + *message = device_variant; + ret = result; + }); + if (!ret_val.isOk() || ret.status != Status::SUCCESS) { + *message = "Unable to get device variant"; + return false; + } + + return true; +} + bool GetCurrentSlot(FastbootDevice* device, const std::vector<std::string>& /* args */, std::string* message) { std::string suffix = device->GetCurrentSlot(); diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h index 63f267024..0546942a8 100644 --- a/fastboot/device/variables.h +++ b/fastboot/device/variables.h @@ -52,6 +52,7 @@ bool GetIsUserspace(FastbootDevice* device, const std::vector<std::string>& args std::string* message); bool GetHardwareRevision(FastbootDevice* device, const std::vector<std::string>& args, std::string* message); +bool GetVariant(FastbootDevice* device, const std::vector<std::string>& args, std::string* message); // Helpers for getvar all. std::vector<std::vector<std::string>> GetAllPartitionArgsWithSlot(FastbootDevice* device); |