Merge "Throw when taking non-existant Uri permission." into klp-dev

This commit is contained in:
Jeff Sharkey
2013-10-14 17:24:14 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 5 deletions

View 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);

View 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);