am 7a531be1: am 94758633: am b5da7b23: Merge "Throw when taking non-existant Uri permission." into klp-dev
* commit '7a531be13bc9ba6218747c185cd199c9e864c60f':
Throw when taking non-existant Uri permission.
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index c472df5..ef9b2c4 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6417,9 +6417,8 @@
final int callingUid = Binder.getCallingUid();
final UriPermission perm = findUriPermissionLocked(callingUid, uri);
if (perm == null) {
- Slog.w(TAG, "No permission grant found for UID " + callingUid + " and Uri "
- + uri.toSafeString());
- return;
+ throw new SecurityException("No permission grant found for UID " + callingUid
+ + " and Uri " + uri.toSafeString());
}
boolean persistChanged = perm.takePersistableModes(modeFlags);
diff --git a/services/java/com/android/server/am/UriPermission.java b/services/java/com/android/server/am/UriPermission.java
index 684f247..1f12b74 100644
--- a/services/java/com/android/server/am/UriPermission.java
+++ b/services/java/com/android/server/am/UriPermission.java
@@ -21,7 +21,6 @@
import android.os.UserHandle;
import android.util.Log;
-import com.android.internal.util.Preconditions;
import com.google.android.collect.Sets;
import java.io.PrintWriter;
@@ -131,7 +130,11 @@
* @return if mode changes should trigger persisting.
*/
boolean takePersistableModes(int modeFlags) {
- Preconditions.checkFlagsArgument(modeFlags, persistableModeFlags);
+ if ((modeFlags & persistableModeFlags) != modeFlags) {
+ throw new SecurityException("Requested flags 0x"
+ + Integer.toHexString(modeFlags) + ", but only 0x"
+ + Integer.toHexString(persistableModeFlags) + " are allowed");
+ }
final int before = persistedModeFlags;
persistedModeFlags |= (persistableModeFlags & modeFlags);