public abstract class PermissionRequirement
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected org.jetbrains.uast.UAnnotation |
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(org.jetbrains.uast.UAnnotation annotation) |
java.lang.String |
describeMissingPermissions(PermissionHolder available)
Describes the missing permissions (e.g.
|
static java.lang.Boolean |
getAnnotationBooleanValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name) |
static boolean |
getAnnotationBooleanValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name,
boolean defaultValue) |
static java.lang.Double |
getAnnotationDoubleValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name) |
static double |
getAnnotationDoubleValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name,
double defaultValue) |
static java.lang.Long |
getAnnotationLongValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name) |
static long |
getAnnotationLongValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name,
long defaultValue) |
static java.lang.String |
getAnnotationStringValue(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name) |
static java.lang.String[] |
getAnnotationStringValues(org.jetbrains.uast.UAnnotation annotation,
java.lang.String name) |
abstract java.lang.Iterable<PermissionRequirement> |
getChildren()
Returns nested requirements, combined via
getOperator() |
int |
getFirstApplicableApi()
Returns the level of the first applicable API level, or 1 if the requirement does
not have a specific API range.
|
int |
getLastApplicableApi()
Returns the level of the last applicable API level for this permission requirement,
if the requirement no longer applies.
|
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 org.jetbrains.uast.UAnnotation annotation
public static final PermissionRequirement NONE
@NonNull public static PermissionRequirement create(@NonNull org.jetbrains.uast.UAnnotation annotation)
@Nullable public static java.lang.Boolean getAnnotationBooleanValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name)
public static boolean getAnnotationBooleanValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name, boolean defaultValue)
@Nullable public static java.lang.Long getAnnotationLongValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name)
public static long getAnnotationLongValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name, long defaultValue)
@Nullable public static java.lang.Double getAnnotationDoubleValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name)
public static double getAnnotationDoubleValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name, double defaultValue)
@Nullable public static java.lang.String getAnnotationStringValue(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name)
@Nullable public static java.lang.String[] getAnnotationStringValues(@Nullable org.jetbrains.uast.UAnnotation annotation, @NonNull java.lang.String name)
protected boolean appliesTo(@NonNull PermissionHolder available)
available
- the permission holder which also knows the min and target versionspublic int getLastApplicableApi()
Integer.MAX_VALUE
if the permission
is not specific to a range and applies for all current API levels.Integer.MAX_VALUE
if applies anywhere.public int getFirstApplicableApi()
public 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