use of com.getcapacitor.annotation.Permission in project capacitor by ionic-team.
the class Plugin method isPermissionDeclared.
/**
* Checks if the given permission alias is correctly declared in AndroidManifest.xml
* @param alias a permission alias defined on the plugin
* @return true only if all permissions associated with the given alias are declared in the manifest
*/
public boolean isPermissionDeclared(String alias) {
CapacitorPlugin annotation = handle.getPluginAnnotation();
if (annotation != null) {
for (Permission perm : annotation.permissions()) {
if (alias.equalsIgnoreCase(perm.alias())) {
boolean result = true;
for (String permString : perm.strings()) {
result = result && PermissionHelper.hasDefinedPermission(getContext(), permString);
}
return result;
}
}
}
Logger.error(String.format("isPermissionDeclared: No alias defined for %s " + "or missing @CapacitorPlugin annotation.", alias));
return false;
}
Aggregations