Loading core/java/android/app/ActivityManager.java +0 −25 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,6 @@ import android.graphics.GraphicBuffer; import android.graphics.Matrix; import android.graphics.Matrix; import android.graphics.Point; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Rect; import android.net.Uri; import android.os.BatteryStats; import android.os.BatteryStats; import android.os.Binder; import android.os.Binder; import android.os.Build; import android.os.Build; Loading Loading @@ -2762,30 +2761,6 @@ public class ActivityManager { } } } } /** * Updates (grants or revokes) a persitable URI permission. * * @param uri URI to be granted or revoked. * @param prefix if {@code false}, permission apply to this specific URI; if {@code true}, it * applies to all URIs that are prefixed by this URI. * @param packageName target package. * @param grant if {@code true} a new permission will be granted, otherwise an existing * permission will be revoked. * * @return whether or not the requested succeeded. * * @hide */ public boolean updatePersistableUriPermission(Uri uri, boolean prefix, String packageName, boolean grant) { try { return getService().updatePersistableUriPermission(uri, prefix, packageName, grant, UserHandle.myUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * Information you can retrieve about any processes that are in an error condition. * Information you can retrieve about any processes that are in an error condition. */ */ Loading core/java/android/app/IActivityManager.aidl +2 −4 Original line number Original line Diff line number Diff line Loading @@ -423,10 +423,8 @@ interface IActivityManager { void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle); void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle); void restart(); void restart(); void performIdleMaintenance(); void performIdleMaintenance(); void takePersistableUriPermission(in Uri uri, int modeFlags, int userId); void takePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId); boolean updatePersistableUriPermission(in Uri uri, boolean prefix, String packageName, void releasePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId); boolean grant, int userId); void releasePersistableUriPermission(in Uri uri, int modeFlags, int userId); ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming); ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming); void appNotRespondingViaProvider(in IBinder connection); void appNotRespondingViaProvider(in IBinder connection); Rect getTaskBounds(int taskId); Rect getTaskBounds(int taskId); Loading core/java/android/content/ContentResolver.java +34 −2 Original line number Original line Diff line number Diff line Loading @@ -2102,7 +2102,23 @@ public abstract class ContentResolver { Preconditions.checkNotNull(uri, "uri"); Preconditions.checkNotNull(uri, "uri"); try { try { ActivityManager.getService().takePersistableUriPermission( ActivityManager.getService().takePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, resolveUserId(uri)); ContentProvider.getUriWithoutUserId(uri), modeFlags, /* toPackage= */ null, resolveUserId(uri)); } catch (RemoteException e) { } } /** * @hide */ public void takePersistableUriPermission(@NonNull String toPackage, @NonNull Uri uri, @Intent.AccessUriMode int modeFlags) { Preconditions.checkNotNull(toPackage, "toPackage"); Preconditions.checkNotNull(uri, "uri"); try { ActivityManager.getService().takePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, toPackage, resolveUserId(uri)); } catch (RemoteException e) { } catch (RemoteException e) { } } } } Loading @@ -2120,7 +2136,23 @@ public abstract class ContentResolver { Preconditions.checkNotNull(uri, "uri"); Preconditions.checkNotNull(uri, "uri"); try { try { ActivityManager.getService().releasePersistableUriPermission( ActivityManager.getService().releasePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, resolveUserId(uri)); ContentProvider.getUriWithoutUserId(uri), modeFlags, /* toPackage= */ null, resolveUserId(uri)); } catch (RemoteException e) { } } /** * @hide */ public void releasePersistableUriPermission(@NonNull String toPackage, @NonNull Uri uri, @Intent.AccessUriMode int modeFlags) { Preconditions.checkNotNull(toPackage, "toPackage"); Preconditions.checkNotNull(uri, "uri"); try { ActivityManager.getService().releasePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, toPackage, resolveUserId(uri)); } catch (RemoteException e) { } catch (RemoteException e) { } } } } Loading core/res/AndroidManifest.xml +12 −1 Original line number Original line Diff line number Diff line Loading @@ -2978,7 +2978,18 @@ settings app. This permission cannot be granted to third-party apps. settings app. This permission cannot be granted to third-party apps. <p>Protection level: signature <p>Protection level: signature --> --> <permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" <permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" android:protectionLevel="signature" /> <!-- @hide Allows an application to change the status of a persistable URI permission granted to another application. <p>This permission should <em>only</em> be requested by the platform settings app. This permission cannot be granted to third-party apps. <p>Protection level: signature --> <permission android:name="android.permission.FORCE_PERSISTABLE_URI_PERMISSIONS" android:protectionLevel="signature" /> android:protectionLevel="signature" /> <!-- @SystemApi Old permission for deleting an app's cache files, no longer used, <!-- @SystemApi Old permission for deleting an app's cache files, no longer used, Loading services/core/java/com/android/server/am/ActivityManagerService.java +35 −83 Original line number Original line Diff line number Diff line Loading @@ -10148,93 +10148,34 @@ public class ActivityManagerService extends IActivityManager.Stub } } } } /** * Updates (grants or revokes) a persitable URI permission. * * @param uri URI to be granted or revoked. * @param prefix if {@code false}, permission apply to this specific URI; if {@code true}, it * applies to all URIs that are prefixed by this URI. * @param packageName target package. * @param grant if {@code true} a new permission will be granted, otherwise an existing * permission will be revoked. * @param userId user handle * * @return whether or not the requested succeeded. * * @deprecated TODO(b/72055774): caller should use takePersistableUriPermission() or * releasePersistableUriPermission() instead, but such change will be made in a separate CL * so it can be easily reverted if it breaks existing functionality. */ @Deprecated // STOPSHIP if not removed @Override public boolean updatePersistableUriPermission(Uri uri, boolean prefix, String packageName, boolean grant, int userId) { enforceCallingPermission(android.Manifest.permission.GET_APP_GRANTED_URI_PERMISSIONS, "updatePersistableUriPermission"); final int uid = mPackageManagerInt.getPackageUid(packageName, 0, userId); final GrantUri grantUri = new GrantUri(userId, uri, prefix); boolean persistChanged = false; synchronized (this) { if (grant) { // Grant final String authority = uri.getAuthority(); final ProviderInfo pi = getProviderInfoLocked(authority, userId, 0); if (pi == null) { Slog.w(TAG, "No content provider found for authority " + authority); return false; } final UriPermission permission = findOrCreateUriPermissionLocked(pi.packageName, packageName, uid, grantUri); if (permission.isNew()) { final int modeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION; permission.initPersistedModes(modeFlags, System.currentTimeMillis()); persistChanged = true; } else { // Caller should not try to grant permission that is already granted. Slog.w(TAG_URI_PERMISSION, "permission already granted for " + grantUri.toSafeString()); return false; } persistChanged |= maybePrunePersistedUriGrantsLocked(uid); } else { // Revoke final UriPermission permission = findUriPermissionLocked(uid, grantUri); if (permission == null) { // Caller should not try to revoke permission that is not granted. Slog.v(TAG_URI_PERMISSION, "no permission for " + grantUri.toSafeString()); return false; } else { permission.modeFlags = 0; removeUriPermissionIfNeededLocked(permission); persistChanged = true; } } if (persistChanged) { schedulePersistUriGrants(); } } return true; } /** /** * @param uri This uri must NOT contain an embedded userId. * @param uri This uri must NOT contain an embedded userId. * @param toPackage Name of package whose uri is being granted to (if {@code null}, uses * calling uid) * @param userId The userId in which the uri is to be resolved. * @param userId The userId in which the uri is to be resolved. */ */ @Override @Override public void takePersistableUriPermission(Uri uri, final int modeFlags, int userId) { public void takePersistableUriPermission(Uri uri, final int modeFlags, @Nullable String toPackage, int userId) { final int uid; if (toPackage != null) { enforceCallingPermission(android.Manifest.permission.FORCE_PERSISTABLE_URI_PERMISSIONS, "takePersistableUriPermission"); uid = mPackageManagerInt.getPackageUid(toPackage, 0, userId); } else { enforceNotIsolatedCaller("takePersistableUriPermission"); enforceNotIsolatedCaller("takePersistableUriPermission"); uid = Binder.getCallingUid(); } Preconditions.checkFlagsArgument(modeFlags, Preconditions.checkFlagsArgument(modeFlags, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); synchronized (this) { synchronized (this) { final int callingUid = Binder.getCallingUid(); boolean persistChanged = false; boolean persistChanged = false; GrantUri grantUri = new GrantUri(userId, uri, false); GrantUri grantUri = new GrantUri(userId, uri, false); UriPermission exactPerm = findUriPermissionLocked(callingUid, grantUri); UriPermission exactPerm = findUriPermissionLocked(uid, grantUri); UriPermission prefixPerm = findUriPermissionLocked(callingUid, UriPermission prefixPerm = findUriPermissionLocked(uid, new GrantUri(userId, uri, true)); new GrantUri(userId, uri, true)); final boolean exactValid = (exactPerm != null) final boolean exactValid = (exactPerm != null) Loading @@ -10244,7 +10185,7 @@ public class ActivityManagerService extends IActivityManager.Stub if (!(exactValid || prefixValid)) { if (!(exactValid || prefixValid)) { throw new SecurityException("No persistable permission grants found for UID " throw new SecurityException("No persistable permission grants found for UID " + callingUid + " and Uri " + grantUri.toSafeString()); + uid + " and Uri " + grantUri.toSafeString()); } } if (exactValid) { if (exactValid) { Loading @@ -10254,7 +10195,7 @@ public class ActivityManagerService extends IActivityManager.Stub persistChanged |= prefixPerm.takePersistableModes(modeFlags); persistChanged |= prefixPerm.takePersistableModes(modeFlags); } } persistChanged |= maybePrunePersistedUriGrantsLocked(callingUid); persistChanged |= maybePrunePersistedUriGrantsLocked(uid); if (persistChanged) { if (persistChanged) { schedulePersistUriGrants(); schedulePersistUriGrants(); Loading @@ -10264,25 +10205,36 @@ public class ActivityManagerService extends IActivityManager.Stub /** /** * @param uri This uri must NOT contain an embedded userId. * @param uri This uri must NOT contain an embedded userId. * @param toPackage Name of the target package whose uri is being released (if {@code null}, * uses calling uid) * @param userId The userId in which the uri is to be resolved. * @param userId The userId in which the uri is to be resolved. */ */ @Override @Override public void releasePersistableUriPermission(Uri uri, final int modeFlags, int userId) { public void releasePersistableUriPermission(Uri uri, final int modeFlags, @Nullable String toPackage, int userId) { final int uid; if (toPackage != null) { enforceCallingPermission(android.Manifest.permission.FORCE_PERSISTABLE_URI_PERMISSIONS, "releasePersistableUriPermission"); uid = mPackageManagerInt.getPackageUid(toPackage, 0, userId); } else { enforceNotIsolatedCaller("releasePersistableUriPermission"); enforceNotIsolatedCaller("releasePersistableUriPermission"); uid = Binder.getCallingUid(); } Preconditions.checkFlagsArgument(modeFlags, Preconditions.checkFlagsArgument(modeFlags, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); synchronized (this) { synchronized (this) { final int callingUid = Binder.getCallingUid(); boolean persistChanged = false; boolean persistChanged = false; UriPermission exactPerm = findUriPermissionLocked(callingUid, UriPermission exactPerm = findUriPermissionLocked(uid, new GrantUri(userId, uri, false)); new GrantUri(userId, uri, false)); UriPermission prefixPerm = findUriPermissionLocked(callingUid, UriPermission prefixPerm = findUriPermissionLocked(uid, new GrantUri(userId, uri, true)); new GrantUri(userId, uri, true)); if (exactPerm == null && prefixPerm == null) { if (exactPerm == null && prefixPerm == null && toPackage == null) { throw new SecurityException("No permission grants found for UID " + callingUid throw new SecurityException("No permission grants found for UID " + uid + " and Uri " + uri.toSafeString()); + " and Uri " + uri.toSafeString()); } } Loading
core/java/android/app/ActivityManager.java +0 −25 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,6 @@ import android.graphics.GraphicBuffer; import android.graphics.Matrix; import android.graphics.Matrix; import android.graphics.Point; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Rect; import android.net.Uri; import android.os.BatteryStats; import android.os.BatteryStats; import android.os.Binder; import android.os.Binder; import android.os.Build; import android.os.Build; Loading Loading @@ -2762,30 +2761,6 @@ public class ActivityManager { } } } } /** * Updates (grants or revokes) a persitable URI permission. * * @param uri URI to be granted or revoked. * @param prefix if {@code false}, permission apply to this specific URI; if {@code true}, it * applies to all URIs that are prefixed by this URI. * @param packageName target package. * @param grant if {@code true} a new permission will be granted, otherwise an existing * permission will be revoked. * * @return whether or not the requested succeeded. * * @hide */ public boolean updatePersistableUriPermission(Uri uri, boolean prefix, String packageName, boolean grant) { try { return getService().updatePersistableUriPermission(uri, prefix, packageName, grant, UserHandle.myUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * Information you can retrieve about any processes that are in an error condition. * Information you can retrieve about any processes that are in an error condition. */ */ Loading
core/java/android/app/IActivityManager.aidl +2 −4 Original line number Original line Diff line number Diff line Loading @@ -423,10 +423,8 @@ interface IActivityManager { void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle); void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle); void restart(); void restart(); void performIdleMaintenance(); void performIdleMaintenance(); void takePersistableUriPermission(in Uri uri, int modeFlags, int userId); void takePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId); boolean updatePersistableUriPermission(in Uri uri, boolean prefix, String packageName, void releasePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId); boolean grant, int userId); void releasePersistableUriPermission(in Uri uri, int modeFlags, int userId); ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming); ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming); void appNotRespondingViaProvider(in IBinder connection); void appNotRespondingViaProvider(in IBinder connection); Rect getTaskBounds(int taskId); Rect getTaskBounds(int taskId); Loading
core/java/android/content/ContentResolver.java +34 −2 Original line number Original line Diff line number Diff line Loading @@ -2102,7 +2102,23 @@ public abstract class ContentResolver { Preconditions.checkNotNull(uri, "uri"); Preconditions.checkNotNull(uri, "uri"); try { try { ActivityManager.getService().takePersistableUriPermission( ActivityManager.getService().takePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, resolveUserId(uri)); ContentProvider.getUriWithoutUserId(uri), modeFlags, /* toPackage= */ null, resolveUserId(uri)); } catch (RemoteException e) { } } /** * @hide */ public void takePersistableUriPermission(@NonNull String toPackage, @NonNull Uri uri, @Intent.AccessUriMode int modeFlags) { Preconditions.checkNotNull(toPackage, "toPackage"); Preconditions.checkNotNull(uri, "uri"); try { ActivityManager.getService().takePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, toPackage, resolveUserId(uri)); } catch (RemoteException e) { } catch (RemoteException e) { } } } } Loading @@ -2120,7 +2136,23 @@ public abstract class ContentResolver { Preconditions.checkNotNull(uri, "uri"); Preconditions.checkNotNull(uri, "uri"); try { try { ActivityManager.getService().releasePersistableUriPermission( ActivityManager.getService().releasePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, resolveUserId(uri)); ContentProvider.getUriWithoutUserId(uri), modeFlags, /* toPackage= */ null, resolveUserId(uri)); } catch (RemoteException e) { } } /** * @hide */ public void releasePersistableUriPermission(@NonNull String toPackage, @NonNull Uri uri, @Intent.AccessUriMode int modeFlags) { Preconditions.checkNotNull(toPackage, "toPackage"); Preconditions.checkNotNull(uri, "uri"); try { ActivityManager.getService().releasePersistableUriPermission( ContentProvider.getUriWithoutUserId(uri), modeFlags, toPackage, resolveUserId(uri)); } catch (RemoteException e) { } catch (RemoteException e) { } } } } Loading
core/res/AndroidManifest.xml +12 −1 Original line number Original line Diff line number Diff line Loading @@ -2978,7 +2978,18 @@ settings app. This permission cannot be granted to third-party apps. settings app. This permission cannot be granted to third-party apps. <p>Protection level: signature <p>Protection level: signature --> --> <permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" <permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" android:protectionLevel="signature" /> <!-- @hide Allows an application to change the status of a persistable URI permission granted to another application. <p>This permission should <em>only</em> be requested by the platform settings app. This permission cannot be granted to third-party apps. <p>Protection level: signature --> <permission android:name="android.permission.FORCE_PERSISTABLE_URI_PERMISSIONS" android:protectionLevel="signature" /> android:protectionLevel="signature" /> <!-- @SystemApi Old permission for deleting an app's cache files, no longer used, <!-- @SystemApi Old permission for deleting an app's cache files, no longer used, Loading
services/core/java/com/android/server/am/ActivityManagerService.java +35 −83 Original line number Original line Diff line number Diff line Loading @@ -10148,93 +10148,34 @@ public class ActivityManagerService extends IActivityManager.Stub } } } } /** * Updates (grants or revokes) a persitable URI permission. * * @param uri URI to be granted or revoked. * @param prefix if {@code false}, permission apply to this specific URI; if {@code true}, it * applies to all URIs that are prefixed by this URI. * @param packageName target package. * @param grant if {@code true} a new permission will be granted, otherwise an existing * permission will be revoked. * @param userId user handle * * @return whether or not the requested succeeded. * * @deprecated TODO(b/72055774): caller should use takePersistableUriPermission() or * releasePersistableUriPermission() instead, but such change will be made in a separate CL * so it can be easily reverted if it breaks existing functionality. */ @Deprecated // STOPSHIP if not removed @Override public boolean updatePersistableUriPermission(Uri uri, boolean prefix, String packageName, boolean grant, int userId) { enforceCallingPermission(android.Manifest.permission.GET_APP_GRANTED_URI_PERMISSIONS, "updatePersistableUriPermission"); final int uid = mPackageManagerInt.getPackageUid(packageName, 0, userId); final GrantUri grantUri = new GrantUri(userId, uri, prefix); boolean persistChanged = false; synchronized (this) { if (grant) { // Grant final String authority = uri.getAuthority(); final ProviderInfo pi = getProviderInfoLocked(authority, userId, 0); if (pi == null) { Slog.w(TAG, "No content provider found for authority " + authority); return false; } final UriPermission permission = findOrCreateUriPermissionLocked(pi.packageName, packageName, uid, grantUri); if (permission.isNew()) { final int modeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION; permission.initPersistedModes(modeFlags, System.currentTimeMillis()); persistChanged = true; } else { // Caller should not try to grant permission that is already granted. Slog.w(TAG_URI_PERMISSION, "permission already granted for " + grantUri.toSafeString()); return false; } persistChanged |= maybePrunePersistedUriGrantsLocked(uid); } else { // Revoke final UriPermission permission = findUriPermissionLocked(uid, grantUri); if (permission == null) { // Caller should not try to revoke permission that is not granted. Slog.v(TAG_URI_PERMISSION, "no permission for " + grantUri.toSafeString()); return false; } else { permission.modeFlags = 0; removeUriPermissionIfNeededLocked(permission); persistChanged = true; } } if (persistChanged) { schedulePersistUriGrants(); } } return true; } /** /** * @param uri This uri must NOT contain an embedded userId. * @param uri This uri must NOT contain an embedded userId. * @param toPackage Name of package whose uri is being granted to (if {@code null}, uses * calling uid) * @param userId The userId in which the uri is to be resolved. * @param userId The userId in which the uri is to be resolved. */ */ @Override @Override public void takePersistableUriPermission(Uri uri, final int modeFlags, int userId) { public void takePersistableUriPermission(Uri uri, final int modeFlags, @Nullable String toPackage, int userId) { final int uid; if (toPackage != null) { enforceCallingPermission(android.Manifest.permission.FORCE_PERSISTABLE_URI_PERMISSIONS, "takePersistableUriPermission"); uid = mPackageManagerInt.getPackageUid(toPackage, 0, userId); } else { enforceNotIsolatedCaller("takePersistableUriPermission"); enforceNotIsolatedCaller("takePersistableUriPermission"); uid = Binder.getCallingUid(); } Preconditions.checkFlagsArgument(modeFlags, Preconditions.checkFlagsArgument(modeFlags, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); synchronized (this) { synchronized (this) { final int callingUid = Binder.getCallingUid(); boolean persistChanged = false; boolean persistChanged = false; GrantUri grantUri = new GrantUri(userId, uri, false); GrantUri grantUri = new GrantUri(userId, uri, false); UriPermission exactPerm = findUriPermissionLocked(callingUid, grantUri); UriPermission exactPerm = findUriPermissionLocked(uid, grantUri); UriPermission prefixPerm = findUriPermissionLocked(callingUid, UriPermission prefixPerm = findUriPermissionLocked(uid, new GrantUri(userId, uri, true)); new GrantUri(userId, uri, true)); final boolean exactValid = (exactPerm != null) final boolean exactValid = (exactPerm != null) Loading @@ -10244,7 +10185,7 @@ public class ActivityManagerService extends IActivityManager.Stub if (!(exactValid || prefixValid)) { if (!(exactValid || prefixValid)) { throw new SecurityException("No persistable permission grants found for UID " throw new SecurityException("No persistable permission grants found for UID " + callingUid + " and Uri " + grantUri.toSafeString()); + uid + " and Uri " + grantUri.toSafeString()); } } if (exactValid) { if (exactValid) { Loading @@ -10254,7 +10195,7 @@ public class ActivityManagerService extends IActivityManager.Stub persistChanged |= prefixPerm.takePersistableModes(modeFlags); persistChanged |= prefixPerm.takePersistableModes(modeFlags); } } persistChanged |= maybePrunePersistedUriGrantsLocked(callingUid); persistChanged |= maybePrunePersistedUriGrantsLocked(uid); if (persistChanged) { if (persistChanged) { schedulePersistUriGrants(); schedulePersistUriGrants(); Loading @@ -10264,25 +10205,36 @@ public class ActivityManagerService extends IActivityManager.Stub /** /** * @param uri This uri must NOT contain an embedded userId. * @param uri This uri must NOT contain an embedded userId. * @param toPackage Name of the target package whose uri is being released (if {@code null}, * uses calling uid) * @param userId The userId in which the uri is to be resolved. * @param userId The userId in which the uri is to be resolved. */ */ @Override @Override public void releasePersistableUriPermission(Uri uri, final int modeFlags, int userId) { public void releasePersistableUriPermission(Uri uri, final int modeFlags, @Nullable String toPackage, int userId) { final int uid; if (toPackage != null) { enforceCallingPermission(android.Manifest.permission.FORCE_PERSISTABLE_URI_PERMISSIONS, "releasePersistableUriPermission"); uid = mPackageManagerInt.getPackageUid(toPackage, 0, userId); } else { enforceNotIsolatedCaller("releasePersistableUriPermission"); enforceNotIsolatedCaller("releasePersistableUriPermission"); uid = Binder.getCallingUid(); } Preconditions.checkFlagsArgument(modeFlags, Preconditions.checkFlagsArgument(modeFlags, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); synchronized (this) { synchronized (this) { final int callingUid = Binder.getCallingUid(); boolean persistChanged = false; boolean persistChanged = false; UriPermission exactPerm = findUriPermissionLocked(callingUid, UriPermission exactPerm = findUriPermissionLocked(uid, new GrantUri(userId, uri, false)); new GrantUri(userId, uri, false)); UriPermission prefixPerm = findUriPermissionLocked(callingUid, UriPermission prefixPerm = findUriPermissionLocked(uid, new GrantUri(userId, uri, true)); new GrantUri(userId, uri, true)); if (exactPerm == null && prefixPerm == null) { if (exactPerm == null && prefixPerm == null && toPackage == null) { throw new SecurityException("No permission grants found for UID " + callingUid throw new SecurityException("No permission grants found for UID " + uid + " and Uri " + uri.toSafeString()); + " and Uri " + uri.toSafeString()); } }