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

Commit 92b24d9d authored by Nikita Ioffe's avatar Nikita Ioffe Committed by Automerger Merge Worker
Browse files

Merge "Check that only allowed installers can perform a non-staged APEX...

Merge "Check that only allowed installers can perform a non-staged APEX update" into sc-dev am: 42b407a0 am: 2e5d7001

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14843821

Change-Id: Ibf53a1e4a457278d6cead5ad8c59762ae0ad477a
parents 23db5bf0 2e5d7001
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -653,13 +653,20 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }

        if (params.isStaged && !isCalledBySystemOrShell(callingUid)) {
            if (mBypassNextStagedInstallerCheck) {
                mBypassNextStagedInstallerCheck = false;
            } else if (!isStagedInstallerAllowed(requestedInstallerPackageName)) {
            if (!mBypassNextStagedInstallerCheck
                    && !isStagedInstallerAllowed(requestedInstallerPackageName)) {
                throw new SecurityException("Installer not allowed to commit staged install");
            }
        }
        if (isApex && !isCalledBySystemOrShell(callingUid)) {
            if (!mBypassNextStagedInstallerCheck
                    && !isStagedInstallerAllowed(requestedInstallerPackageName)) {
                throw new SecurityException(
                        "Installer not allowed to commit non-staged APEX install");
            }
        }

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