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 b05d278696)
This commit is contained in:
Hridya Valsaraju 2018-09-27 10:41:01 -07:00
parent 007e52efe0
commit 7c9bbe948b
4 changed files with 26 additions and 0 deletions

View file

@ -61,3 +61,4 @@
#define FB_VAR_IS_USERSPACE "is-userspace"
#define FB_VAR_HW_REVISION "hw-revision"
#define FB_VAR_VARIANT "variant"
#define FB_VAR_OFF_MODE_CHARGE_STATE "off-mode-charge"

View file

@ -95,6 +95,7 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args)
{FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}},
{FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}},
{FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}},
{FB_VAR_OFF_MODE_CHARGE_STATE, {GetOffModeChargeState, nullptr}},
{FB_VAR_HW_REVISION, {GetHardwareRevision, nullptr}}};
if (args.size() < 2) {

View file

@ -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();

View file

@ -53,6 +53,8 @@ bool GetIsUserspace(FastbootDevice* device, const std::vector<std::string>& args
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);
bool GetOffModeChargeState(FastbootDevice* device, const std::vector<std::string>& args,
std::string* message);
// Helpers for getvar all.
std::vector<std::vector<std::string>> GetAllPartitionArgsWithSlot(FastbootDevice* device);