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

Commit 8e7404af authored by Matt Gilbride's avatar Matt Gilbride Committed by Android (Google) Code Review
Browse files

Merge "Add parameters to @PermissionMethod"

parents 2e2f95fd 8e806dd2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -6201,7 +6201,7 @@ public abstract class Context {
     */
    @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)")
    @PackageManager.PermissionResult
    @PermissionMethod
    @PermissionMethod(orSelf = true)
    public abstract int checkCallingOrSelfPermission(@NonNull @PermissionName String permission);

    /**
@@ -6269,7 +6269,7 @@ public abstract class Context {
     *
     * @see #checkCallingOrSelfPermission(String)
     */
    @PermissionMethod
    @PermissionMethod(orSelf = true)
    public abstract void enforceCallingOrSelfPermission(
            @NonNull @PermissionName String permission, @Nullable String message);

+17 −1
Original line number Diff line number Diff line
@@ -33,4 +33,20 @@ import java.lang.annotation.Target;
 */
@Retention(CLASS)
@Target({METHOD})
public @interface PermissionMethod {}
public @interface PermissionMethod {
    /**
     * Hard-coded list of permissions checked by this method
     */
    @PermissionName String[] value() default {};
    /**
     * If true, the check passes if the caller
     * has any ONE of the supplied permissions
     */
    boolean anyOf() default false;
    /**
     * Signifies that the permission check passes if
     * the calling process OR the current process has
     * the permission
     */
    boolean orSelf() default false;
}
+1 −0
Original line number Diff line number Diff line
@@ -6142,6 +6142,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    /**
     * This can be called with or without the global lock held.
     */
    @PermissionMethod(anyOf = true)
    private void enforceCallingHasAtLeastOnePermission(String func, String... permissions) {
        for (String permission : permissions) {
            if (checkCallingPermission(permission) == PackageManager.PERMISSION_GRANTED) {