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

Commit 1f484774 authored by Jackal Guo's avatar Jackal Guo Committed by Android (Google) Code Review
Browse files

Merge "Prevent arbitrary installers installing apps as instant"

parents 73faccb8 e1d6549d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -997,6 +997,7 @@ package android.content.pm {
    method public void setEnableRollback(boolean, int);
    method @RequiresPermission("android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS") public void setGrantedRuntimePermissions(String[]);
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setInstallAsApex();
    method public void setInstallAsInstantApp(boolean);
    method public void setInstallerPackageName(@Nullable String);
    method public void setRequestDowngrade(boolean);
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setStaged();
+1 −0
Original line number Diff line number Diff line
@@ -1878,6 +1878,7 @@ public class PackageInstaller {

        /** {@hide} */
        @SystemApi
        @TestApi
        public void setInstallAsInstantApp(boolean isInstantApp) {
            if (isInstantApp) {
                installFlags |= PackageManager.INSTALL_INSTANT_APP;
+7 −0
Original line number Diff line number Diff line
@@ -618,6 +618,13 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
            }
        }

        if ((params.installFlags & PackageManager.INSTALL_INSTANT_APP) != 0
                && !isCalledBySystemOrShell(callingUid)
                && (mPm.getFlagsForUid(callingUid) & ApplicationInfo.FLAG_SYSTEM) == 0) {
            throw new SecurityException(
                    "Only system apps could use the PackageManager.INSTALL_INSTANT_APP flag.");
        }

        if (params.isStaged && !isCalledBySystemOrShell(callingUid)) {
            if (mBypassNextStagedInstallerCheck) {
                mBypassNextStagedInstallerCheck = false;