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

Commit ca053512 authored by Richard Uhler's avatar Richard Uhler
Browse files

Set mResolvedBaseFile for apex install sessions.

Which RollbackManager will use to determine the package name and version
of the APEX being installed in the same way it does for APKs.

Bug: 112431924
Test: device boots, apex install succeeds.
Change-Id: I5e1fe031da5ad0b8cad159655abc7781803c1f97
parent 2472cf32
Loading
Loading
Loading
Loading
+26 −5
Original line number Diff line number Diff line
@@ -1000,10 +1000,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        // cannot be modified anymore, there is no leak of information. For staged sessions,
        // further validation is performed by the staging manager.
        if (!params.isMultiPackage) {
            if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
                // For APEX, validation is done by StagingManager post-commit.
                return;
            }
            final PackageInfo pkgInfo = mPm.getPackageInfo(
                    params.appPackageName, PackageManager.GET_SIGNATURES
                            | PackageManager.MATCH_STATIC_SHARED_LIBRARIES /*flags*/, userId);
@@ -1011,7 +1007,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            resolveStageDirLocked();

            try {
                if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
                    validateApexInstallLocked();
                } else {
                    validateApkInstallLocked(pkgInfo);
                }
            } catch (PackageManagerException e) {
                throw e;
            } catch (Throwable e) {
@@ -1302,6 +1302,27 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                (params.installFlags & PackageManager.DONT_KILL_APP) != 0;
    }

    /**
     * Validate apex install.
     * <p>
     * Sets {@link #mResolvedBaseFile} for RollbackManager to use.
     */
    @GuardedBy("mLock")
    private void validateApexInstallLocked()
            throws PackageManagerException {
        final File[] addedFiles = mResolvedStageDir.listFiles(sAddedFilter);
        if (ArrayUtils.isEmpty(addedFiles)) {
            throw new PackageManagerException(INSTALL_FAILED_INVALID_APK, "No packages staged");
        }

        if (ArrayUtils.size(addedFiles) > 1) {
            throw new PackageManagerException(INSTALL_FAILED_INVALID_APK,
                    "Too many files for apex install");
        }

        mResolvedBaseFile = addedFiles[0];
    }

    /**
     * Validate install by confirming that all application packages are have
     * consistent package name, version code, and signing certificates.