Merge "Add parameters to @PermissionMethod"
This commit is contained in:
committed by
Android (Google) Code Review
commit
8e7404af95
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user