Skip to content
Snippets Groups Projects
Commit b2c5cacd authored by Richard Uhler's avatar Richard Uhler
Browse files

RollbackManager: Check for applied staged sessions on boot.

Bug: 112431924
Test: atest RollbackTest

Change-Id: I5062993da04a4c1a8f3fa2a1cb97e0a488b630d3
parent ac0d0f9b
No related branches found
No related tags found
No related merge requests found
......@@ -44,4 +44,11 @@ public final class RollbackManagerService extends SystemService {
public void onUnlockUser(int user) {
mService.onUnlockUser(user);
}
@Override
public void onBootPhase(int phase) {
if (phase == SystemService.PHASE_BOOT_COMPLETED) {
mService.onBootCompleted();
}
}
}
......@@ -486,6 +486,47 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
});
}
void onBootCompleted() {
getHandler().post(() -> {
// Check to see if any staged sessions with rollback enabled have
// been applied.
List<RollbackData> staged = new ArrayList<>();
synchronized (mLock) {
ensureRollbackDataLoadedLocked();
for (RollbackData data : mAvailableRollbacks) {
if (data.stagedSessionId != -1) {
staged.add(data);
}
}
}
for (RollbackData data : staged) {
PackageInstaller installer = mContext.getPackageManager().getPackageInstaller();
PackageInstaller.SessionInfo session = installer.getSessionInfo(
data.stagedSessionId);
if (session != null) {
if (session.isSessionApplied()) {
synchronized (mLock) {
data.isAvailable = true;
}
try {
mRollbackStore.saveAvailableRollback(data);
} catch (IOException ioe) {
Log.e(TAG, "Unable to save rollback info for : "
+ data.rollbackId, ioe);
}
} else if (session.isSessionFailed()) {
// TODO: Do we need to remove this from
// mAvailableRollbacks, or is it okay to leave as
// unavailable until the next reboot when it will go
// away on its own?
mRollbackStore.deleteAvailableRollback(data);
}
}
}
});
}
/**
* Load rollback data from storage if it has not already been loaded.
* After calling this funciton, mAvailableRollbacks and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment