Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 582f7124 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Throw when taking non-existant Uri permission.

Bug: 11080911
Change-Id: Ib73a20f497b447aebe69c88266369605e69a7812
parent 11def8f0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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);
+5 −2
Original line number Diff line number Diff line
@@ -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);