Merge "Add supportsCheckpoint"
diff --git a/Checkpoint.cpp b/Checkpoint.cpp
index 7586a6c..e06e855 100644
--- a/Checkpoint.cpp
+++ b/Checkpoint.cpp
@@ -67,6 +67,21 @@
 
 }  // namespace
 
+Status cp_supportsCheckpoint(bool& result) {
+    result = false;
+    auto fstab_default = std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)>{
+        fs_mgr_read_fstab_default(), fs_mgr_free_fstab};
+    if (!fstab_default) return Status::fromExceptionCode(EINVAL, "Failed to get fstab");
+
+    for (int i = 0; i < fstab_default->num_entries; ++i) {
+        if (fs_mgr_is_checkpoint(&fstab_default->recs[i])) {
+            result = true;
+            return Status::ok();
+        }
+    }
+    return Status::ok();
+}
+
 Status cp_startCheckpoint(int retry) {
     if (retry < -1) return Status::fromExceptionCode(EINVAL, "Retry count must be more than -1");
     std::string content = std::to_string(retry + 1);
diff --git a/Checkpoint.h b/Checkpoint.h
index eac2f94..64ceed3 100644
--- a/Checkpoint.h
+++ b/Checkpoint.h
@@ -23,6 +23,8 @@
 namespace android {
 namespace vold {
 
+android::binder::Status cp_supportsCheckpoint(bool& result);
+
 android::binder::Status cp_startCheckpoint(int retry);
 
 android::binder::Status cp_commitChanges();
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index c58ff01..1001d2b 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -864,5 +864,12 @@
     return cp_abortChanges();
 }
 
+binder::Status VoldNativeService::supportsCheckpoint(bool* _aidl_return) {
+    ENFORCE_UID(AID_SYSTEM);
+    ACQUIRE_LOCK;
+
+    return cp_supportsCheckpoint(*_aidl_return);
+}
+
 }  // namespace vold
 }  // namespace android
diff --git a/VoldNativeService.h b/VoldNativeService.h
index 161acb8..7db3e5c 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -129,6 +129,7 @@
     binder::Status restoreCheckpoint(const std::string& mountPoint);
     binder::Status markBootAttempt();
     binder::Status abortChanges();
+    binder::Status supportsCheckpoint(bool* _aidl_return);
 };
 
 }  // namespace vold
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index 976eab1..4b21078 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -104,6 +104,7 @@
     void prepareCheckpoint();
     void restoreCheckpoint(@utf8InCpp String device);
     void markBootAttempt();
+    boolean supportsCheckpoint();
 
     @utf8InCpp String createStubVolume(@utf8InCpp String sourcePath,
             @utf8InCpp String mountPath, @utf8InCpp String fsType,
diff --git a/vdc.cpp b/vdc.cpp
index e971d52..35775a7 100644
--- a/vdc.cpp
+++ b/vdc.cpp
@@ -105,6 +105,10 @@
         checkStatus(vold->mountFstab(args[2]));
     } else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 3) {
         checkStatus(vold->encryptFstab(args[2]));
+    } else if (args[0] == "checkpoint" && args[1] == "supportsCheckpoint" && args.size() == 2) {
+        bool supported = false;
+        checkStatus(vold->supportsCheckpoint(&supported));
+        return supported ? 1 : 0;
     } else if (args[0] == "checkpoint" && args[1] == "startCheckpoint" && args.size() == 3) {
         int retry;
         if (!android::base::ParseInt(args[2], &retry)) exit(EINVAL);