From faa877f797c45ec0acaaed8637ec6cfec320daed Mon Sep 17 00:00:00 2001 From: Nicholas Sauer Date: Thu, 20 Dec 2018 19:31:03 -0800 Subject: [PATCH] specialCrossUserGrant should not be false by default for secondary users. bug: 120913988 Test: adb shell am switch-user 0 cts-tradefed run cts-dev -a arm64-v8a -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSsts#testPermissionDiffCert adb shell am switch-user 10 cts-tradefed run cts-dev -a arm64-v8a -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSsts#testPermissionDiffCert Verified continued functionality (See b/120913988#comment4): open a document in quickOffice In the menu, tap share in the disambig dialog, tap Android for work Change-Id: I94960bc91276a2a797df97fa84aa67890582b046 --- .../java/com/android/server/uri/UriGrantsManagerService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/uri/UriGrantsManagerService.java b/services/core/java/com/android/server/uri/UriGrantsManagerService.java index 9a7e75e548afe..744efab7d78d0 100644 --- a/services/core/java/com/android/server/uri/UriGrantsManagerService.java +++ b/services/core/java/com/android/server/uri/UriGrantsManagerService.java @@ -1129,7 +1129,8 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub { * In this case, we grant a uri permission, even if the ContentProvider does not normally * grant uri permissions. */ - boolean specialCrossUserGrant = UserHandle.getUserId(targetUid) != grantUri.sourceUserId + boolean specialCrossUserGrant = targetUid >= 0 + && UserHandle.getUserId(targetUid) != grantUri.sourceUserId && checkHoldingPermissionsInternal(pm, pi, grantUri, callingUid, modeFlags, false /*without considering the uid permissions*/);