Make sure checkpoint listeners are always notified
The `IVoldCheckpointListener`s should be notified when checkpointing
completes and when vold becomes aware that no checkpoint will be
required. We were previously not notifying in the case where reading
kMetadataCPFile returned `false` (error while reading) which tells vold
there isn't a checkpoint. Refactored `cp_needsCheckpoint` to make sure
this case isn't missed.
Bug: 362567323
Test: m && ./vendor/google/tools/flashall && adb wait-for-device && adb reboot && adb wait-for-device && adb logcat -s storageproxyd:v vold:V Checkpoint:V
Change-Id: I55a4b908655446517b961bb1affdae694b76a70d
diff --git a/Checkpoint.cpp b/Checkpoint.cpp
index 27d99e7..76e46fb 100644
--- a/Checkpoint.cpp
+++ b/Checkpoint.cpp
@@ -307,21 +307,21 @@
std::string content;
auto module = BootControlClient::WaitForService();
- if (isCheckpointing) return isCheckpointing;
+ if (isCheckpointing) return true;
+
// In case of INVALID slot or other failures, we do not perform checkpoint.
if (module && !module->IsSlotMarkedSuccessful(module->GetCurrentSlot()).value_or(true)) {
isCheckpointing = true;
return true;
}
ret = android::base::ReadFileToString(kMetadataCPFile, &content);
- if (ret) {
- ret = content != "0";
- isCheckpointing = ret;
- if (!isCheckpointing) {
- notifyCheckpointListeners();
- }
- return ret;
+ if (ret && content != "0") {
+ isCheckpointing = true;
+ return true;
}
+
+ // Leave isCheckpointing false and notify listeners now that we know we don't need one
+ notifyCheckpointListeners();
return false;
}