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

Commit 3ad7361b authored by Dario Freni's avatar Dario Freni
Browse files

Remove unused codepath.

APEX installations now have to go through staged install. This CL also
enforces this.

Test: atest apex_e2e_tests
Change-Id: I1920b3e090e9a968be36937ffe9332580aea9a24
parent e8c4958b
Loading
Loading
Loading
Loading
+6 −29
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import static com.android.server.pm.PackageInstallerService.prepareStageDir;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.apex.IApexService;
import android.app.admin.DevicePolicyManagerInternal;
import android.content.Context;
import android.content.IIntentReceiver;
@@ -80,7 +79,6 @@ import android.os.ParcelableException;
import android.os.Process;
import android.os.RemoteException;
import android.os.RevocableFileDescriptor;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.storage.StorageManager;
@@ -1084,6 +1082,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            dispatchSessionFinished(PackageManager.INSTALL_SUCCEEDED, "Session staged", null);
            return;
        }
        if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
            throw new PackageManagerException(
                PackageManager.INSTALL_FAILED_INTERNAL_ERROR,
                "APEX packages can only be installed using staged sessions.");
        }
        final PackageManagerService.ActiveInstallSession committingSession =
                makeSessionActiveLocked();
        if (committingSession == null) {
@@ -1101,12 +1104,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                    final PackageManagerService.ActiveInstallSession activeSession =
                            session.makeSessionActiveLocked();
                    if (activeSession != null) {
                        if ((activeSession.getSessionParams().installFlags
                                & PackageManager.INSTALL_APEX) != 0) {
                            throw new PackageManagerException(
                                    PackageManager.INSTALL_FAILED_INTERNAL_ERROR,
                                    "Atomic install is not supported for APEX packages.");
                        }
                        childSessions.add(activeSession);
                    }
                } catch (PackageManagerException e) {
@@ -1123,30 +1120,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                return;
            }
            mPm.installStage(childSessions);
        } else {
            if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
                commitApexLocked();
        } else {
            mPm.installStage(committingSession);
        }
    }
    }

    @GuardedBy("mLock")
    private void commitApexLocked() throws PackageManagerException {
        try {
            IApexService apex = IApexService.Stub.asInterface(
                    ServiceManager.getService("apexservice"));
            apex.stagePackage(mResolvedBaseFile.toString());
        } catch (Throwable e) {
            // Convert all exceptions into package manager exceptions as only those are handled
            // in the code above
            throw new PackageManagerException(e);
        } finally {
            destroyInternal();
            dispatchSessionFinished(PackageManager.INSTALL_SUCCEEDED, "APEX installed", null);
        }
    }

    /**
     * Stages this session for install and returns a