Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fa7d13e authored by Richard Uhler's avatar Richard Uhler
Browse files

Notify RollbackManager of the apk session for a staged install.

The rollback manager needs to know the apk session to avoid doing an
extra backup of the apks when the apk session is applied post-reboot.

Bug: 112431924
Test: atest RollbackTest

Change-Id: Ie84969760b9b1fd3949a7241f23e52cfb403e294
parent 60ac706f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -47,4 +47,8 @@ interface IRollbackManager {
    //
    // NOTE: This call is synchronous.
    boolean notifyStagedSession(int sessionId);

    // Used by the staging manager to notify the RollbackManager of the apk
    // session for a staged session.
    void notifyStagedApkSession(int originalSessionId, int apkSessionId);
}
+13 −0
Original line number Diff line number Diff line
@@ -380,6 +380,19 @@ public class StagingManager {

    private boolean commitApkSession(@NonNull PackageInstallerSession apkSession,
                                     int originalSessionId) {

        if ((apkSession.params.installFlags & PackageManager.INSTALL_ENABLE_ROLLBACK) != 0) {
            // If rollback is available for this session, notify the rollback
            // manager of the apk session so it can properly enable rollback.
            final IRollbackManager rm = IRollbackManager.Stub.asInterface(
                    ServiceManager.getService(Context.ROLLBACK_SERVICE));
            try {
                rm.notifyStagedApkSession(originalSessionId, apkSession.sessionId);
            } catch (RemoteException re) {
                // Cannot happen, the rollback manager is in the same process.
            }
        }

        final LocalIntentReceiver receiver = new LocalIntentReceiver();
        apkSession.commit(receiver.getIntentSender(), false);
        final Intent result = receiver.getResult();
+5 −0
Original line number Diff line number Diff line
@@ -928,6 +928,11 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
        }
    }

    @Override
    public void notifyStagedApkSession(int originalSessionId, int apkSessionId) {
        // TODO: Handle this callback.
    }

    /**
     * Gets the version of the package currently installed.
     * Returns null if the package is not currently installed.