diff --git a/Checkpoint.cpp b/Checkpoint.cpp index 75a22ec..f96ca39 100644 --- a/Checkpoint.cpp +++ b/Checkpoint.cpp @@ -84,6 +84,30 @@ Status cp_supportsCheckpoint(bool& result) { return Status::ok(); } +Status cp_supportsBlockCheckpoint(bool& result) { + result = false; + + for (const auto& entry : fstab_default) { + if (entry.fs_mgr_flags.checkpoint_blk) { + result = true; + return Status::ok(); + } + } + return Status::ok(); +} + +Status cp_supportsFileCheckpoint(bool& result) { + result = false; + + for (const auto& entry : fstab_default) { + if (entry.fs_mgr_flags.checkpoint_fs) { + 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 70dad8a..d077d19 100644 --- a/Checkpoint.h +++ b/Checkpoint.h @@ -25,6 +25,10 @@ namespace vold { android::binder::Status cp_supportsCheckpoint(bool& result); +android::binder::Status cp_supportsBlockCheckpoint(bool& result); + +android::binder::Status cp_supportsFileCheckpoint(bool& result); + android::binder::Status cp_startCheckpoint(int retry); android::binder::Status cp_commitChanges(); diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp index 69f8a8c..6868c83 100644 --- a/VoldNativeService.cpp +++ b/VoldNativeService.cpp @@ -879,5 +879,19 @@ binder::Status VoldNativeService::supportsCheckpoint(bool* _aidl_return) { return cp_supportsCheckpoint(*_aidl_return); } +binder::Status VoldNativeService::supportsBlockCheckpoint(bool* _aidl_return) { + ENFORCE_UID(AID_SYSTEM); + ACQUIRE_LOCK; + + return cp_supportsBlockCheckpoint(*_aidl_return); +} + +binder::Status VoldNativeService::supportsFileCheckpoint(bool* _aidl_return) { + ENFORCE_UID(AID_SYSTEM); + ACQUIRE_LOCK; + + return cp_supportsFileCheckpoint(*_aidl_return); +} + } // namespace vold } // namespace android diff --git a/VoldNativeService.h b/VoldNativeService.h index 954b8ae..8fbc32d 100644 --- a/VoldNativeService.h +++ b/VoldNativeService.h @@ -131,6 +131,8 @@ class VoldNativeService : public BinderService, public os::Bn binder::Status markBootAttempt(); binder::Status abortChanges(); binder::Status supportsCheckpoint(bool* _aidl_return); + binder::Status supportsBlockCheckpoint(bool* _aidl_return); + binder::Status supportsFileCheckpoint(bool* _aidl_return); }; } // namespace vold diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl index 83ee116..3c5ef78 100644 --- a/binder/android/os/IVold.aidl +++ b/binder/android/os/IVold.aidl @@ -106,6 +106,8 @@ interface IVold { void restoreCheckpointPart(@utf8InCpp String device, int count); void markBootAttempt(); boolean supportsCheckpoint(); + boolean supportsBlockCheckpoint(); + boolean supportsFileCheckpoint(); @utf8InCpp String createStubVolume(@utf8InCpp String sourcePath, @utf8InCpp String mountPath, @utf8InCpp String fsType, diff --git a/vdc.cpp b/vdc.cpp index d01fb49..1ec46c8 100644 --- a/vdc.cpp +++ b/vdc.cpp @@ -109,6 +109,14 @@ int main(int argc, char** argv) { bool supported = false; checkStatus(vold->supportsCheckpoint(&supported)); return supported ? 1 : 0; + } else if (args[0] == "checkpoint" && args[1] == "supportsBlockCheckpoint" && args.size() == 2) { + bool supported = false; + checkStatus(vold->supportsBlockCheckpoint(&supported)); + return supported ? 1 : 0; + } else if (args[0] == "checkpoint" && args[1] == "supportsFileCheckpoint" && args.size() == 2) { + bool supported = false; + checkStatus(vold->supportsFileCheckpoint(&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);