Merge "Allow holders of INSTALL_PACKAGE_UPDATES permission to update APEXes" into sc-dev am: 4173c5a51a

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

Change-Id: Ieaf28ffb309ffc258c79eac8c82cfe95d75837fa
This commit is contained in:
Nikita Ioffe
2021-06-15 21:36:07 +00:00
committed by Automerger Merge Worker

View File

@@ -626,7 +626,14 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
}
boolean isApex = (params.installFlags & PackageManager.INSTALL_APEX) != 0;
if (params.isStaged || isApex) {
if (isApex) {
if (mContext.checkCallingOrSelfPermission(Manifest.permission.INSTALL_PACKAGE_UPDATES)
== PackageManager.PERMISSION_DENIED
&& mContext.checkCallingOrSelfPermission(Manifest.permission.INSTALL_PACKAGES)
== PackageManager.PERMISSION_DENIED) {
throw new SecurityException("Not allowed to perform APEX updates");
}
} else if (params.isStaged) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.INSTALL_PACKAGES, TAG);
}