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

Commit e4931c5b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Support 'fastboot getvar unlocked' command."

parents 6cc0d76d dca328d5
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -180,6 +180,12 @@ bool FlashHandler(FastbootDevice* device, const std::vector<std::string>& args)
    if (args.size() < 2) {
        return device->WriteStatus(FastbootResult::FAIL, "Invalid arguments");
    }

    if (GetDeviceLockStatus()) {
        return device->WriteStatus(FastbootResult::FAIL,
                                   "Flashing is not allowed on locked devices");
    }

    int ret = Flash(device, args[1]);
    if (ret < 0) {
        return device->WriteStatus(FastbootResult::FAIL, strerror(-ret));
@@ -325,6 +331,10 @@ bool CreatePartitionHandler(FastbootDevice* device, const std::vector<std::strin
        return device->WriteFail("Invalid partition name and size");
    }

    if (GetDeviceLockStatus()) {
        return device->WriteStatus(FastbootResult::FAIL, "Command not available on locked devices");
    }

    uint64_t partition_size;
    std::string partition_name = args[1];
    if (!android::base::ParseUint(args[2].c_str(), &partition_size)) {
@@ -365,6 +375,10 @@ bool DeletePartitionHandler(FastbootDevice* device, const std::vector<std::strin
        return device->WriteFail("Invalid partition name and size");
    }

    if (GetDeviceLockStatus()) {
        return device->WriteStatus(FastbootResult::FAIL, "Command not available on locked devices");
    }

    PartitionBuilder builder(device);
    if (!builder.Valid()) {
        return device->WriteFail("Could not open super partition");
@@ -381,6 +395,10 @@ bool ResizePartitionHandler(FastbootDevice* device, const std::vector<std::strin
        return device->WriteFail("Invalid partition name and size");
    }

    if (GetDeviceLockStatus()) {
        return device->WriteStatus(FastbootResult::FAIL, "Command not available on locked devices");
    }

    uint64_t partition_size;
    std::string partition_name = args[1];
    if (!android::base::ParseUint(args[2].c_str(), &partition_size)) {
@@ -409,6 +427,11 @@ bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>&
    if (args.size() < 2) {
        return device->WriteFail("Invalid arguments");
    }

    if (GetDeviceLockStatus()) {
        return device->WriteStatus(FastbootResult::FAIL, "Command not available on locked devices");
    }

    bool wipe = (args.size() >= 3 && args[2] == "wipe");
    return UpdateSuper(device, args[1], wipe);
}
+7 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <unistd.h>

#include <android-base/file.h>
#include <android-base/logging.h>
#include <fs_mgr_dm_linear.h>
#include <liblp/liblp.h>
@@ -159,3 +160,9 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) {
    }
    return partitions;
}

bool GetDeviceLockStatus() {
    std::string cmdline;
    android::base::ReadFileToString("/proc/cmdline", &cmdline);
    return cmdline.find("androidboot.verifiedbootstate=orange") == std::string::npos;
}
+1 −0
Original line number Diff line number Diff line
@@ -58,3 +58,4 @@ bool LogicalPartitionExists(const std::string& name, const std::string& slot_suf
bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle);
bool GetSlotNumber(const std::string& slot, android::hardware::boot::V1_0::Slot* number);
std::vector<std::string> ListPartitions(FastbootDevice* device);
bool GetDeviceLockStatus();
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ bool GetMaxDownloadSize(FastbootDevice* /* device */, const std::vector<std::str

bool GetUnlocked(FastbootDevice* /* device */, const std::vector<std::string>& /* args */,
                 std::string* message) {
    *message = "yes";
    *message = GetDeviceLockStatus() ? "no" : "yes";
    return true;
}