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

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

Merge "Allow erase, set_active and download commands only on unlocked devices."

parents f3186de1 d1e62316
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -131,6 +131,11 @@ bool EraseHandler(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, "Erase is not allowed on locked devices");
    }

    PartitionHandle handle;
    if (!OpenPartition(device, args[1], &handle)) {
        return device->WriteStatus(FastbootResult::FAIL, "Partition doesn't exist");
@@ -163,6 +168,12 @@ bool DownloadHandler(FastbootDevice* device, const std::vector<std::string>& arg
    if (args.size() < 2) {
        return device->WriteStatus(FastbootResult::FAIL, "size argument unspecified");
    }

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

    // arg[0] is the command name, arg[1] contains size of data to be downloaded
    unsigned int size;
    if (!android::base::ParseUint("0x" + args[1], &size, UINT_MAX)) {
@@ -203,6 +214,11 @@ bool SetActiveHandler(FastbootDevice* device, const std::vector<std::string>& ar
        return device->WriteStatus(FastbootResult::FAIL, "Missing slot argument");
    }

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

    // Slot suffix needs to be between 'a' and 'z'.
    Slot slot;
    if (!GetSlotNumber(args[1], &slot)) {