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

Commit 6016496e authored by JW Wang's avatar JW Wang
Browse files

Extract verication code to a new class (2/n)

* A new class (PackageSessionVerifier) to run pre-reboot verification
  for staged-sessions.
* StagingManager.commitSession() is called after pre-reboot
  verification is done which will then notify the observers
  for staged apex.
* Dead code will be removed in next CLs.

Bug: 161121612
Test: atest StagingManagerTest
Test: atest CtsAtomicInstallTestCases
Test: atest CtsPackageInstallTestCases
Test: atest CtsStagedInstallHostTestCases
Change-Id: I9c80c34543af1d7f363b12af4a3720d3e6d4e7aa
parent 7fb926b5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
    private final File mSessionsDir;

    private final InternalCallback mInternalCallback = new InternalCallback();
    private final PackageSessionVerifier mSessionVerifier;

    /**
     * Used for generating session IDs. Since this is created at boot time,
@@ -259,6 +260,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        mApexManager = ApexManager.getInstance();
        mStagingManager = new StagingManager(context, apexParserSupplier,
                mInstallThread.getLooper());
        mSessionVerifier = new PackageSessionVerifier(context, mPm, mApexManager,
                apexParserSupplier, mInstallThread.getLooper());

        LocalServices.getService(SystemServiceManager.class).startService(
                new Lifecycle(context, this));
@@ -1159,6 +1162,11 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }
    }

    @Override
    public PackageSessionVerifier getSessionVerifier() {
        return mSessionVerifier;
    }

    @Override
    public void bypassNextStagedInstallerCheck(boolean value) {
        if (!isCalledBySystemOrShell(Binder.getCallingUid())) {
+6 −1
Original line number Diff line number Diff line
@@ -2692,7 +2692,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        // staged session or not. For a staged session, we will hand it over to the staging
        // manager to complete the installation.
        if (isStaged()) {
            mSessionProvider.getSessionVerifier().verifyStaged(mStagedSession, (error, msg) -> {
                mStagedSession.notifyEndPreRebootVerification();
                if (error == SessionInfo.STAGED_SESSION_NO_ERROR) {
                    mStagingManager.commitSession(mStagedSession);
                }
            });
            return;
        }

+5 −1
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package com.android.server.pm;

/** Provides access to individual sessions managed by the install service */
/**
 * Provides access to individual sessions managed by the install service as well as utilities
 * used by the install process.
 */
public interface PackageSessionProvider {

    /**
@@ -25,4 +28,5 @@ public interface PackageSessionProvider {
     */
    PackageInstallerSession getSession(int sessionId);

    PackageSessionVerifier getSessionVerifier();
}
+485 −0

File added.

Preview size limit exceeded, changes collapsed.

+8 −237

File changed.

Preview size limit exceeded, changes collapsed.

Loading