From 08f1959e1050f339dfe1821760da717634760661 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 21 Dec 2016 13:27:04 -0700 Subject: [PATCH] Always create grant structures when persistable. Certain apps may already hold permissions to an underlying provider, but they expect APIs like takePersistableUriPermission() and getPersistedUriPermissions() to work when a permission grant was extended with FLAG_GRANT_PERSISTABLE_URI_PERMISSION. Test: builds, boots Bug: 31239684 Change-Id: I4b21c57956b70133ecadb50d0d3ee339f41e2260 --- .../java/com/android/server/am/ActivityManagerService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index eae4905f27e4c..cacba3789e469 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -8154,6 +8154,12 @@ public class ActivityManagerService extends IActivityManager.Stub } } + // If we're extending a persistable grant, then we always need to create + // the grant data structure so that take/release APIs work + if ((modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0) { + return targetUid; + } + if (targetUid >= 0) { // First... does the target actually need this permission? if (checkHoldingPermissionsLocked(pm, pi, grantUri, targetUid, modeFlags)) {