Merge "Disallow fastboot to modify locked DSU" into main
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index d605393..6de598f 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -639,6 +639,12 @@
return UpdateSuper(device, args[1], wipe);
}
+static bool IsLockedDsu() {
+ std::string active_dsu;
+ android::gsi::GetActiveDsu(&active_dsu);
+ return android::base::EndsWith(active_dsu, ".lock");
+}
+
bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args) {
if (args.size() != 2) {
return device->WriteFail("Invalid arguments");
@@ -653,6 +659,11 @@
return device->WriteStatus(FastbootResult::FAIL, "No GSI is installed");
}
+ if ((args[1] == "wipe" || args[1] == "disable") && GetDeviceLockStatus() && IsLockedDsu()) {
+ // Block commands that modify the states of locked DSU
+ return device->WriteFail("Command not available on locked DSU/devices");
+ }
+
if (args[1] == "wipe") {
if (!android::gsi::UninstallGsi()) {
return device->WriteStatus(FastbootResult::FAIL, strerror(errno));