diff options
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r-- | fastboot/device/variables.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index bcf13a540..01415d72b 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -24,6 +24,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <ext4_utils/ext4_utils.h> +#include <healthhalutils/HealthHalUtils.h> #include "fastboot_device.h" #include "flashing.h" @@ -117,6 +118,30 @@ bool GetOffModeChargeState(FastbootDevice* device, const std::vector<std::string return true; } +bool GetBatteryVoltage(FastbootDevice* device, const std::vector<std::string>& /* args */, + std::string* message) { + using android::hardware::health::V2_0::HealthInfo; + using android::hardware::health::V2_0::Result; + + auto health_hal = device->health_hal(); + if (!health_hal) { + *message = "Health HAL not found"; + return false; + } + + Result ret; + auto ret_val = health_hal->getHealthInfo([&](Result result, HealthInfo info) { + *message = std::to_string(info.legacy.batteryVoltage); + ret = result; + }); + if (!ret_val.isOk() || (ret != Result::SUCCESS)) { + *message = "Unable to get battery voltage"; + return false; + } + + return true; +} + bool GetCurrentSlot(FastbootDevice* device, const std::vector<std::string>& /* args */, std::string* message) { std::string suffix = device->GetCurrentSlot(); |