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

Commit 595db8a1 authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Re-seal the sessions on reboot.

Previously we were validating them as well. This is unnecessary as
validation will happen on commit/transfer calls later.

This was introduced in 43f1af9d when we
were using mSealed flag for both sealing and validation. It's not the
case anymore and we can safely deffer validation to commit/transfer.

Test: atest PackageManagerShellCommandTest SplitTests StagedRollbackTest CtsAtomicInstallTestCases PackageInstallerSessionTest InstallSessionTransferTest
Bug: b/136132412
Change-Id: Iedba991ff057bcfc4aeb2ba0d450e59bb4f035d8
parent 65aea378
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -400,10 +400,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        } finally {
            IoUtils.closeQuietly(fis);
        }
        // After all of the sessions were loaded, they are ready to be sealed and validated
        // Re-sealing the sealed sessions.
        for (int i = 0; i < mSessions.size(); ++i) {
            PackageInstallerSession session = mSessions.valueAt(i);
            session.sealAndValidateIfNecessary();
            session.sealIfNecessary();
        }
    }

+4 −8
Original line number Diff line number Diff line
@@ -1374,15 +1374,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    }

    /**
     * If session should be sealed, then it's sealed to prevent further modification
     * and then it's validated.
     *
     * If the session was sealed but something went wrong then it's destroyed.
     * If session should be sealed, then it's sealed to prevent further modification.
     * If the session can't be sealed then it's destroyed.
     *
     * <p> This is meant to be called after all of the sessions are loaded and added to
     * PackageInstallerService
     */
    void sealAndValidateIfNecessary() {
    void sealIfNecessary() {
        synchronized (mLock) {
            if (!mShouldBeSealed || isStagedAndInTerminalState()) {
                return;
@@ -1391,9 +1389,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        List<PackageInstallerSession> childSessions = getChildSessions();
        synchronized (mLock) {
            try {
                sealAndValidateLocked(childSessions);
            } catch (StreamingException e) {
                Slog.e(TAG, "Streaming failed", e);
                sealLocked(childSessions);
            } catch (PackageManagerException e) {
                Slog.e(TAG, "Package not valid", e);
            }