Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e83c49de authored by Hridya Valsaraju's avatar Hridya Valsaraju Committed by android-build-merger
Browse files

Merge "Add support to read fastboot variable 'off-mode-charge'"

am: e15267b5

Change-Id: I7334f80c14e77a8ab8abca7d093f602fd6f12ff6
parents f9568659 e15267b5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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"
+1 −0
Original line number Diff line number Diff line
@@ -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) {
+22 −0
Original line number Diff line number Diff line
@@ -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();
+2 −0
Original line number Diff line number Diff line
@@ -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);