public abstract class PermissionRequirement
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected com.intellij.psi.PsiAnnotation |
annotation |
static java.lang.String |
ATTR_PROTECTION_LEVEL |
static PermissionRequirement |
NONE |
static java.lang.String |
VALUE_DANGEROUS |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addMissingPermissions(PermissionHolder available,
java.util.Set<java.lang.String> result) |
protected abstract void |
addRevocablePermissions(java.util.Set<java.lang.String> result,
PermissionHolder revocable) |
protected static void |
appendOperator(java.lang.StringBuilder sb,
com.intellij.psi.tree.IElementType operator) |
protected boolean |
appliesTo(PermissionHolder available)
Returns false if this permission does not apply given the specified minimum and target
sdk versions
|
static PermissionRequirement |
create(com.android.tools.lint.detector.api.JavaContext context,
com.intellij.psi.PsiAnnotation annotation) |
java.lang.String |
describeMissingPermissions(PermissionHolder available)
Describes the missing permissions (e.g.
|
static java.lang.Boolean |
getAnnotationBooleanValue(com.intellij.psi.PsiAnnotation annotation,
java.lang.String name) |
static java.lang.Double |
getAnnotationDoubleValue(com.intellij.psi.PsiAnnotation annotation,
java.lang.String name) |
static java.lang.Long |
getAnnotationLongValue(com.intellij.psi.PsiAnnotation annotation,
java.lang.String name) |
static java.lang.String |
getAnnotationStringValue(com.intellij.psi.PsiAnnotation annotation,
java.lang.String name) |
static java.lang.String[] |
getAnnotationStringValues(com.intellij.psi.PsiAnnotation annotation,
java.lang.String name) |
abstract java.lang.Iterable<PermissionRequirement> |
getChildren()
Returns nested requirements, combined via
getOperator() |
java.util.Set<java.lang.String> |
getMissingPermissions(PermissionHolder available)
Returns the missing permissions (e.g.
|
abstract com.intellij.psi.tree.IElementType |
getOperator()
For permission requirements that combine children, the operator to combine them with; null
for leaf nodes
|
java.util.Set<java.lang.String> |
getRevocablePermissions(PermissionHolder revocable)
Returns the permissions in the requirement that are revocable
|
boolean |
isConditional()
Returns whether this requirement is conditional, meaning that there are
some circumstances in which the requirement is not necessary.
|
abstract boolean |
isRevocable(PermissionHolder revocable)
Returns whether this permission is revocable
|
static boolean |
isRevocableSystemPermission(java.lang.String name)
Returns true if the given permission name is a revocable permission for
targetSdkVersion ≥ 23
|
abstract boolean |
isSatisfied(PermissionHolder available)
Whether the permission requirement is satisfied given the set of granted permissions
|
boolean |
isSingle()
Returns whether this requirement is for a single permission (rather than
a boolean expression such as one permission or another.)
|
public static final java.lang.String ATTR_PROTECTION_LEVEL
public static final java.lang.String VALUE_DANGEROUS
protected final com.intellij.psi.PsiAnnotation annotation
public static final PermissionRequirement NONE
@NonNull public static PermissionRequirement create(@NonNull com.android.tools.lint.detector.api.JavaContext context, @NonNull com.intellij.psi.PsiAnnotation annotation)
@Nullable public static java.lang.Boolean getAnnotationBooleanValue(@Nullable com.intellij.psi.PsiAnnotation annotation, @NonNull java.lang.String name)
@Nullable public static java.lang.Long getAnnotationLongValue(@Nullable com.intellij.psi.PsiAnnotation annotation, @NonNull java.lang.String name)
@Nullable public static java.lang.Double getAnnotationDoubleValue(@Nullable com.intellij.psi.PsiAnnotation annotation, @NonNull java.lang.String name)
@Nullable public static java.lang.String getAnnotationStringValue(@Nullable com.intellij.psi.PsiAnnotation annotation, @NonNull java.lang.String name)
@Nullable public static java.lang.String[] getAnnotationStringValues(@Nullable com.intellij.psi.PsiAnnotation annotation, @NonNull java.lang.String name)
protected boolean appliesTo(@NonNull PermissionHolder available)
available
- the permission holder which also knows the min and target versionspublic boolean isConditional()
android.app.backup.BackupManager.dataChanged(java.lang.String)
.
Here the android.permission.BACKUP
is required but only if the
argument is not your own package.
This is used to handle permissions differently between the "missing" and "unused" checks. When checking for missing permissions, we err on the side of caution: if you are missing a permission, but the permission is conditional, you may not need it so we may not want to complain. However, when looking for unused permissions, we don't want to flag the conditional permissions as unused since they may be required.
public boolean isSingle()
public abstract boolean isSatisfied(@NonNull PermissionHolder available)
available
- the available permissionspublic java.lang.String describeMissingPermissions(@NonNull PermissionHolder available)
public java.util.Set<java.lang.String> getMissingPermissions(@NonNull PermissionHolder available)
protected abstract void addMissingPermissions(@NonNull PermissionHolder available, @NonNull java.util.Set<java.lang.String> result)
public java.util.Set<java.lang.String> getRevocablePermissions(@NonNull PermissionHolder revocable)
protected abstract void addRevocablePermissions(@NonNull java.util.Set<java.lang.String> result, @NonNull PermissionHolder revocable)
public abstract boolean isRevocable(@NonNull PermissionHolder revocable)
revocable
- the set of revocable permissions@Nullable public abstract com.intellij.psi.tree.IElementType getOperator()
@NonNull public abstract java.lang.Iterable<PermissionRequirement> getChildren()
getOperator()
protected static void appendOperator(java.lang.StringBuilder sb, com.intellij.psi.tree.IElementType operator)
public static boolean isRevocableSystemPermission(@NonNull java.lang.String name)
name
- permission name