diff options
author | Hridya Valsaraju <hridya@google.com> | 2018-09-27 10:41:01 -0700 |
---|---|---|
committer | Hridya Valsaraju <hridya@google.com> | 2018-09-28 14:16:47 -0700 |
commit | 7c9bbe948b446b6e995ea9fdd3a3226362372ca9 (patch) | |
tree | 7d1fe9bf09b33c81e0e75174a57868aef80fd3da /fastboot/device/variables.cpp | |
parent | 007e52efe002c3864255bf114be2fb9854d3811d (diff) |
Add support to read fastboot variable 'off-mode-charge'
Bug: 78793464
Bug: 79480454
Test: fastboot getvar off-mode-charge
Change-Id: I4c40847be292e8e2e420340f81bb624b247bc11b
Merged-In: I4c40847be292e8e2e420340f81bb624b247bc11b
(cherry picked from commit b05d278696cbb25e14085362651999204aa51b40)
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r-- | fastboot/device/variables.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 77cd4bc25..bcf13a540 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -95,6 +95,28 @@ bool GetVariant(FastbootDevice* device, const std::vector<std::string>& /* args return true; } +bool GetOffModeChargeState(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->getOffModeChargeState([&](bool off_mode_charging_state, Result result) { + *message = off_mode_charging_state ? "1" : "0"; + ret = result; + }); + if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) { + *message = "Unable to get off mode charge state"; + return false; + } + + return true; +} + bool GetCurrentSlot(FastbootDevice* device, const std::vector<std::string>& /* args */, std::string* message) { std::string suffix = device->GetCurrentSlot(); |