Schedule rollback expiration when a rollback is enabled.
Otherwise rollbacks will only be expired if the device reboots.
Currently there are no tests that scheduled rollback expiration works,
which explains why this bug wasn't found earlier. The plan is to add
tests for scheduled rollback expiration after the expiration timeout has
been made configurable, because it will be much easier to write the
tests with a configurable timeout.
Test: atest RollbackTest
Bug: 112431924
Change-Id: If16185b5db1a6f55efb83067e8f80a8bcb0816e7
diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
index 8021265..d12f7ed 100644
--- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
+++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
@@ -977,6 +977,8 @@
ensureRollbackDataLoadedLocked();
mAvailableRollbacks.add(data);
}
+
+ scheduleExpiration(ROLLBACK_LIFETIME_DURATION_MILLIS);
} catch (IOException e) {
Log.e(TAG, "Unable to enable rollback", e);
removeFile(data.backupDir);