Allow erase, set_active and download commands only on unlocked devices.
Bug: 117276890 Bug: 117277405 Bug: 117278071 Test: make Change-Id: Ic5e3a3ce9e2199578c2788b3b14aac7a8860a270
This commit is contained in:
parent
d7f2c56089
commit
d1e623160c
|
@ -129,6 +129,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");
|
||||
|
@ -161,6 +166,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)) {
|
||||
|
@ -201,6 +212,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)) {
|
||||
|
|
Loading…
Reference in New Issue