Merge "checkpoint: Fix metadata file contents bug" into main
diff --git a/Checkpoint.cpp b/Checkpoint.cpp
index 76e46fb..195a137 100644
--- a/Checkpoint.cpp
+++ b/Checkpoint.cpp
@@ -136,13 +136,16 @@
         return error(ENOTSUP, "Checkpoints not supported");
 
     if (retry < -1) return error(EINVAL, "Retry count must be more than -1");
-    std::string content = std::to_string(retry + 1);
+    std::string content;
     if (retry == -1) {
+        content = std::to_string(-1);
         auto module = BootControlClient::WaitForService();
         if (module) {
             std::string suffix = module->GetSuffix(module->GetCurrentSlot());
             if (!suffix.empty()) content += " " + suffix;
         }
+    } else {
+        content = std::to_string(retry + 1);
     }
     if (!android::base::WriteStringToFile(content, kMetadataCPFile))
         return error("Failed to write checkpoint file");