am 94758633: am b5da7b23: Merge "Throw when taking non-existant Uri permission." into klp-dev
* commit '94758633943e77c820fd77f96329848cc7f31230':
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 ea49a06..fcd3386 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6413,9 +6413,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);