Don't return early on error (1/n)

Continue the call flow even when #enableRollbackForPackageSession fails
so #completeEnableRollback has a chance to delete a rollback when any of
the child sessions fails to enable the rollback for the package.

Without this CL, the rollback data won't be deleted until next reboot.
Since storage cost might be heavy for the rollback data, we want to
delete it as soon as possible without waiting for reboot which might
happen much later.

Bug: 149352598
Test: test RollbackTest StagedRollbackTest
Change-Id: I4aeda1f2447e1b12353d2e3866408aab67a637eb
This commit is contained in:
JW Wang
2020-02-12 10:53:28 +08:00
parent a000089341
commit b3ea9a61d4

View File

@@ -982,8 +982,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
if (!session.isMultiPackage()) {
if (!enableRollbackForPackageSession(newRollback, session)) {
Slog.e(TAG, "Unable to enable rollback for session: " + sessionId);
result.offer(-1);
return;
}
} else {
for (int childSessionId : session.getChildSessionIds()) {
@@ -991,13 +989,11 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
installer.getSessionInfo(childSessionId);
if (childSession == null) {
Slog.e(TAG, "No matching child install session for: " + childSessionId);
result.offer(-1);
return;
break;
}
if (!enableRollbackForPackageSession(newRollback, childSession)) {
Slog.e(TAG, "Unable to enable rollback for session: " + sessionId);
result.offer(-1);
return;
break;
}
}
}
@@ -1188,8 +1184,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
}
/**
* Add a rollback to the list of rollbacks. This should be called after rollback has been
* enabled for all packages in the rollback. It does not make the rollback available yet.
* Add a rollback to the list of rollbacks. It does not make the rollback available yet.
*
* @return the Rollback instance for a successfully enable-completed rollback,
* or null on error.