From ded86e4aae9c28d29766648160095d8a4c6b0e41 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Mon, 1 Jul 2019 16:27:43 +0100 Subject: [PATCH] delete ENABLING rollback if we can't get session info for it. If we can't get the SessionInfo for a rollback in ENABLE state on boot, then presumably we'll never be able to get SessionInfo for it, so delete the rollback. Test: adb install TestAppAv1.apk; adb install --enable-rollback --staged TestAppAv2.apk dumpsys rollback adb shell pm install-abandon adb reboot, confirm /data/rollback/ does not exist adb reboot dumpsys rollback, confirm rollback is no longer listed. Bug: 134652027 Change-Id: Ie583536d0ec75c442bd4c9e4456bee120050728c --- .../rollback/RollbackManagerServiceImpl.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java index de3e89f031d8e..42a16132e5e1d 100644 --- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java @@ -648,17 +648,14 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { PackageInstaller installer = mContext.getPackageManager().getPackageInstaller(); PackageInstaller.SessionInfo session = installer.getSessionInfo( data.stagedSessionId); - // TODO: What if session is null? - if (session != null) { - if (session.isStagedSessionApplied()) { - makeRollbackAvailable(data); - } else if (session.isStagedSessionFailed()) { - // TODO: Do we need to remove this from - // mRollbacks, or is it okay to leave as - // unavailable until the next reboot when it will go - // away on its own? - deleteRollback(data); - } + if (session == null || session.isStagedSessionFailed()) { + // TODO: Do we need to remove this from + // mRollbacks, or is it okay to leave as + // unavailable until the next reboot when it will go + // away on its own? + deleteRollback(data); + } else if (session.isStagedSessionApplied()) { + makeRollbackAvailable(data); } }