summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
index e56bda2946f4..5f871ad4f9e4 100644
--- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
+++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
@@ -137,6 +137,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
private final Installer mInstaller;
private final RollbackPackageHealthObserver mPackageHealthObserver;
private final AppDataRollbackHelper mAppDataRollbackHelper;
+ private final Runnable mRunExpiration = this::runExpiration;
// The # of milli-seconds to sleep for each received ACTION_PACKAGE_ENABLE_ROLLBACK.
// Used by #blockRollbackManager to test timeout in enabling rollbacks.
@@ -516,6 +517,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
mRollbackLifetimeDurationInMillis = DEFAULT_ROLLBACK_LIFETIME_DURATION_MILLIS;
}
Slog.d(TAG, "mRollbackLifetimeDurationInMillis=" + mRollbackLifetimeDurationInMillis);
+ runExpiration();
}
@AnyThread
@@ -644,6 +646,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
// Schedules future expiration as appropriate.
@WorkerThread
private void runExpiration() {
+ getHandler().removeCallbacks(mRunExpiration);
+
Instant now = Instant.now();
Instant oldest = null;
synchronized (mLock) {
@@ -667,20 +671,12 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
}
if (oldest != null) {
- scheduleExpiration(now.until(oldest.plusMillis(mRollbackLifetimeDurationInMillis),
- ChronoUnit.MILLIS));
+ long delay = now.until(
+ oldest.plusMillis(mRollbackLifetimeDurationInMillis), ChronoUnit.MILLIS);
+ getHandler().postDelayed(mRunExpiration, delay);
}
}
- /**
- * Schedules an expiration check to be run after the given duration in
- * milliseconds has gone by.
- */
- @AnyThread
- private void scheduleExpiration(long duration) {
- getHandler().postDelayed(() -> runExpiration(), duration);
- }
-
@AnyThread
private Handler getHandler() {
return mHandlerThread.getThreadHandler();
@@ -1179,7 +1175,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
// prepare to rollback if packages crashes too frequently.
mPackageHealthObserver.startObservingHealth(rollback.getPackageNames(),
mRollbackLifetimeDurationInMillis);
- scheduleExpiration(mRollbackLifetimeDurationInMillis);
+ runExpiration();
}
/*