Merge "Adds caller check to getAllPackages()" into oc-mr1-dev

This commit is contained in:
TreeHugger Robot
2021-03-03 18:05:52 +00:00
committed by Android (Google) Code Review

View File

@@ -6541,6 +6541,11 @@ public class PackageManagerService extends IPackageManager.Stub
@Override
public List<String> getAllPackages() {
final int callingUid = Binder.getCallingUid();
// enforceSystemOrRootOrShell:
if (callingUid != Process.SYSTEM_UID && callingUid != Process.ROOT_UID
&& callingUid != Process.SHELL_UID) {
throw new SecurityException("getAllPackages is limited to privileged callers");
}
final int callingUserId = UserHandle.getUserId(callingUid);
synchronized (mPackages) {
if (canViewInstantApps(callingUid, callingUserId)) {