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

Commit e4f393f6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disable APEX install on unsupported devices."

parents 6e05a5c8 83620602
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -192,6 +192,18 @@ class ApexManager {
        }
    }

    /**
     * Whether the current device supports the management of APEX packages.
     *
     * @return true if APEX packages can be managed on this device, false otherwise.
     */
    boolean isApexSupported() {
        // There is no system-wide property available to check if APEX are flattened and hence can't
        // be updated. In absence of such property, we assume that if we didn't index APEX packages
        // since they were flattened, no APEX management should be possible.
        return !mActivePackagesCache.isEmpty();
    }

    /**
     * Dumps various state information to the provided {@link PrintWriter} object.
     *
+13 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements

    private final Context mContext;
    private final PackageManagerService mPm;
    private final ApexManager mApexManager;
    private final StagingManager mStagingManager;
    private final PermissionManagerServiceInternal mPermissionManager;

@@ -204,6 +205,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        mSessionsDir = new File(Environment.getDataSystemDirectory(), "install_sessions");
        mSessionsDir.mkdirs();

        mApexManager = am;
        mStagingManager = new StagingManager(pm, this, am);
    }

@@ -485,6 +487,17 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
            mContext.enforceCallingOrSelfPermission(Manifest.permission.INSTALL_PACKAGES, TAG);
        }

        if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
            if (!mApexManager.isApexSupported()) {
                throw new IllegalArgumentException(
                    "This device doesn't support the installation of APEX files");
            }
            if (!params.isStaged) {
                throw new IllegalArgumentException(
                    "APEX files can only be installed as part of a staged session.");
            }
        }

        if (!params.isMultiPackage) {
            // Only system components can circumvent runtime permissions when installing.
            if ((params.installFlags & PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS) != 0