OSDN Git Service

Throw when taking non-existant Uri permission.
authorJeff Sharkey <jsharkey@android.com>
Sat, 12 Oct 2013 00:46:47 +0000 (17:46 -0700)
committerJeff Sharkey <jsharkey@android.com>
Mon, 14 Oct 2013 17:01:33 +0000 (10:01 -0700)
Bug: 11080911
Change-Id: Ib73a20f497b447aebe69c88266369605e69a7812

services/java/com/android/server/am/ActivityManagerService.java
services/java/com/android/server/am/UriPermission.java

index 456a0a7..74393ba 100644 (file)
@@ -6413,9 +6413,8 @@ public final class ActivityManagerService extends ActivityManagerNative
             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);
index 684f247..1f12b74 100644 (file)
@@ -21,7 +21,6 @@ import android.net.Uri;
 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 @@ final class UriPermission {
      * @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);