Loading fastboot/device/commands.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -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)); Loading Loading @@ -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)) { Loading Loading @@ -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"); Loading @@ -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)) { Loading Loading @@ -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); } fastboot/device/utility.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; } fastboot/device/utility.h +1 −0 Original line number Diff line number Diff line Loading @@ -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(); fastboot/device/variables.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading
fastboot/device/commands.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -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)); Loading Loading @@ -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)) { Loading Loading @@ -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"); Loading @@ -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)) { Loading Loading @@ -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); }
fastboot/device/utility.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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; }
fastboot/device/utility.h +1 −0 Original line number Diff line number Diff line Loading @@ -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();
fastboot/device/variables.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading