From 7494002c94ec103844379303a37926382f138648 Mon Sep 17 00:00:00 2001 From: Patrick Baumann Date: Tue, 29 Sep 2020 13:22:43 -0700 Subject: Fixes PM.grantImplicitAccess for multi-user This change fixes the security check in grantImplicitAccess to support the case that the system user does not have an installed contacts provider. Fixes: 169684344 Test: atest android.provider.cts.contacts.ContactsContract_DirectoryTest Change-Id: I2c80513a5dffa7ad92963e376ea85217f127f39a --- services/core/java/com/android/server/pm/PackageManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index dd7ef5b02877..d42c7eae18ce 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -25434,7 +25434,7 @@ public class PackageManagerService extends IPackageManager.Stub // This API is exposed temporarily to only the contacts provider. (b/158688602) final int callingUid = Binder.getCallingUid(); ProviderInfo contactsProvider = resolveContentProviderInternal( - ContactsContract.AUTHORITY, 0, UserHandle.USER_SYSTEM); + ContactsContract.AUTHORITY, 0, UserHandle.getUserId(callingUid)); if (contactsProvider == null || contactsProvider.applicationInfo == null || !UserHandle.isSameApp(contactsProvider.applicationInfo.uid, callingUid)) { throw new SecurityException(callingUid + " is not allow to call grantImplicitAccess"); -- cgit v1.2.3-59-g8ed1b