diff --git a/Checkpoint.cpp b/Checkpoint.cpp index e238acf..ce0d00c 100644 --- a/Checkpoint.cpp +++ b/Checkpoint.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include +using android::base::SetProperty; using android::binder::Status; using android::hardware::hidl_string; using android::hardware::boot::V1_0::BoolResult; @@ -81,8 +83,15 @@ Status cp_startCheckpoint(int retry) { return Status::ok(); } +namespace { + +bool isCheckpointing = false; +} + Status cp_commitChanges() { - if (!cp_needsCheckpoint()) return Status::ok(); + if (!isCheckpointing) { + return Status::ok(); + } // Must take action for list of mounted checkpointed things here // To do this, we walk the list of mounted file systems. // But we also need to get the matching fstab entries to see @@ -115,6 +124,8 @@ Status cp_commitChanges() { return Status::fromExceptionCode(EINVAL, "Failed to set bow state"); } } + SetProperty("vold.checkpoint_committed", "1"); + isCheckpointing = false; if (!android::base::RemoveFileIfExists(kMetadataCPFile, &err_str)) return Status::fromExceptionCode(errno, err_str.c_str()); return Status::ok(); @@ -152,10 +163,16 @@ bool cp_needsCheckpoint() { std::string content; sp module = IBootControl::getService(); - if (module && module->isSlotMarkedSuccessful(module->getCurrentSlot()) == BoolResult::FALSE) + if (module && module->isSlotMarkedSuccessful(module->getCurrentSlot()) == BoolResult::FALSE) { + isCheckpointing = true; return true; + } ret = android::base::ReadFileToString(kMetadataCPFile, &content); - if (ret) return content != "0"; + if (ret) { + ret = content != "0"; + isCheckpointing = ret; + return ret; + } return false; }