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

Commit a77a677c authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Bypass most session work for APEX packages

Fixes a merge error introduced in the multi-package API refactor that
causes all APEX installs to fail as they were being treated as full
APKs while making the session active for handling by
PackageManagerService. This change bypasses that work if the package
is being installed as APEX as the package will not be passed to
PackageManagerService.

Change-Id: Ic7534e49e4a552b64cc1e046ce79272ece1be73a
Fixes: 119411166
Test: adb install apex.test.apex
parent 4e7b7c1a
Loading
Loading
Loading
Loading
+92 −87
Original line number Diff line number Diff line
@@ -1126,6 +1126,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR, "Session not sealed");
        }

        final IPackageInstallObserver2 localObserver;
        if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
            localObserver = null;
        } else {
            if (!params.isMultiPackage) {
                Preconditions.checkNotNull(mPackageName);
                Preconditions.checkNotNull(mSigningDetails);
@@ -1173,8 +1177,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                                    final int splitIndex = libPath.lastIndexOf('/');
                                    if (splitIndex < 0 || splitIndex >= libPath.length() - 1) {
                                        Slog.e(TAG,
                                            "Skipping native library creation for linking due to "
                                                    + "invalid path: " + libPath);
                                                "Skipping native library creation for linking due"
                                                        + " to invalid path: " + libPath);
                                        continue;
                                    }
                                    final String libDirPath = libPath.substring(1, splitIndex);
@@ -1204,11 +1208,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                computeProgressLocked(true);

                // Unpack native libraries
            extractNativeLibraries(mResolvedStageDir, params.abiOverride, mayInheritNativeLibs());
                extractNativeLibraries(mResolvedStageDir, params.abiOverride,
                        mayInheritNativeLibs());
            }

            // We've reached point of no return; call into PMS to install the stage.
            // Regardless of success or failure we always destroy session.
        final IPackageInstallObserver2 localObserver = new IPackageInstallObserver2.Stub() {
            localObserver = new IPackageInstallObserver2.Stub() {
                @Override
                public void onUserActionRequired(Intent intent) {
                    throw new IllegalStateException();
@@ -1221,6 +1227,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                    dispatchSessionFinished(returnCode, msg, extras);
                }
            };
        }

        final UserHandle user;
        if ((params.installFlags & PackageManager.INSTALL_ALL_USERS) != 0) {
@@ -1230,11 +1237,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        }

        mRelinquished = true;
        final PackageManagerService.ActiveInstallSession activeInstallSession =
                new PackageManagerService.ActiveInstallSession(mPackageName, stageDir,
        return new PackageManagerService.ActiveInstallSession(mPackageName, stageDir,
                localObserver, params, mInstallerPackageName, mInstallerUid, user,
                mSigningDetails);
        return activeInstallSession;
    }

    private static void maybeRenameFile(File from, File to) throws PackageManagerException {