public class PermissionsServices extends ApplicationContextProvider
All methods in this class are thread safe and can be called from any thread.
Added in daily build 2016.2828.
ApplicationContextProvider
Modifier and Type | Class and Description |
---|---|
static class |
PermissionsServices.Permission
API Level independent constants for
dangerous Android permissions
supported by Corona, sorted by permission groups.
|
static class |
PermissionsServices.PermissionGroup
API Level independent constants for supported permission-group names.
|
Constructor and Description |
---|
PermissionsServices(android.content.Context context)
Creates an object that provides easy access to the application's permissions.
|
Modifier and Type | Method and Description |
---|---|
String[] |
findAllPermissionsInManifestForGroup(String permissionGroup)
Searches the AndroidManifest.xml
for all permissions within the desired permission group.
|
String |
findPermissionInManifestForGroup(String permissionGroup)
Searches the AndroidManifest.xml
for a permission within the desired permission group.
|
String |
getPAAppPermissionNameFromAndroidPermission(String permission)
Gets the Platform-Agnostic App Permission name for the given Android permission.
|
String |
getPAAppPermissionNameFromPermissionGroup(String permissionGroup)
Gets the Platform-Agnostic App Permission name for the given Permission Group name.
|
String |
getPermissionGroupFromPAAppPermissionName(String pAAppPermissionName)
Gets the Permission Group name for the given Platform-Agnostic App Permission name.
|
String |
getPermissionGroupFromPermission(String permission)
Gets the permission group for the desired permission.
|
PermissionState |
getPermissionStateFor(String permission)
Determines the current state of the desired permission and returns it.
|
PermissionState |
getPermissionStateForSupportedGroup(String permissionGroup)
Determines the current state of the desired permission group supported by Corona and returns it.
|
String[] |
getRequestedPermissions()
Grabs all the requested permissions in the
AndroidManifest.xml.
|
String[] |
getRequestedPermissionsInState(PermissionState permissionState)
Gets all the requested permissions in the
AndroidManifest.xml in the desired state.
|
String[] |
getRequestedPermissionsInStateForGroup(PermissionState permissionState,
String permissionGroup)
Gets all the requested permissions in the
AndroidManifest.xml
in the desired state for the desired Permission Group.
|
String[] |
getSupportedPermissionGroups()
Returns a
String array of all dangerous-level permissions groups supported by Corona. |
boolean |
isPAAppPermissionName(String name)
Determines if this name corresponds to the name of a Platform-Agnostic App Permission.
|
boolean |
isPartOfPAAppPermission(String permission)
Determines if this Android permission is part of a Platform-Agnostic App Permission.
|
boolean |
isPermissionInManifest(String permission)
Determines if the desired Android permission is in the
AndroidManifest.xml.
|
boolean |
isSupportedPermissionGroupName(String name)
Determines if this name corresponds to the name of a dangerous-level Android Permission Group supported by Corona.
|
void |
requestAllDeniedPermissionsInGroup(String permissionGroup,
CoronaActivity.OnRequestPermissionsResultHandler resultHandler)
Requests all permissions that are currently denied in the desired permission group.
|
void |
requestPermissions(PermissionsSettings settings,
CoronaActivity.OnRequestPermissionsResultHandler resultHandler)
Requests the desired permissions, gathering data about which permissions are requested.
|
boolean |
shouldNeverAskAgain(String permission)
Determines if the user has requested the desired permission never be asked for again.
|
void |
showPermissionGroupMissingFromManifestAlert(String permissionGroup)
Displays a native alert stating that the
AndroidManifest.xml
doesn't contain any permissions from the desired permission group.
|
void |
showPermissionMissingFromManifestAlert(String permission,
String message)
Displays a native alert stating that this permission is missing from the
AndroidManifest.xml.
|
getApplicationContext
public PermissionsServices(android.content.Context context)
context
- Reference to an Android created context used to access the input device system.
Note: Setting this to null will cause an exception to be thrown.public String[] findAllPermissionsInManifestForGroup(String permissionGroup)
permissionGroup
- The permission group we're looking for the presence of.Returns null if no permission in the desired permission group is in the AndroidManifest.xml or we're in an invalid environment.
public String findPermissionInManifestForGroup(String permissionGroup)
permissionGroup
- The permission group we're looking for the presence of.Returns null if no permission in the desired permission group is in the AndroidManifest.xml or we're in an invalid environment.
public PermissionState getPermissionStateFor(String permission)
permission
- The permission we want the current state of.PermissionState enum
depicting what state the desired permission is in.
Returns null if we are in an invalid environemnt.
public PermissionState getPermissionStateForSupportedGroup(String permissionGroup)
permissionGroup
- The permission group we want the current state of.PermissionState enum
depicting what state the desired permission group is in.
Will return PermissionState.GRANTED
if all requested permissions in that group are granted.
If any of the requested permissions in the desired permission group are denied,
then this method will return PermissionState.DENIED
.
Will return PermissionState.MISSING
if this group isn't supported by Corona or for this version of Android.
Returns null if we are in an invalid environemnt.
public String getPermissionGroupFromPermission(String permission)
permission
- The permission whose group we want.Returns null if this permission doesn't belong to a group, is not defined on this device, or we're in an invalid environment.
public String getPermissionGroupFromPAAppPermissionName(String pAAppPermissionName)
pAAppPermissionName
- The Platform-Agnostic App Permission name to convert to a Permission Group name.Returns null if there's no permission group for this Platform-Agnostic App Permission.
public String getPAAppPermissionNameFromPermissionGroup(String permissionGroup)
permissionGroup
- The Permission Group name to convert to a Platform-Agnostic App Permission name.Returns null if there's no Platform-Agnostic App Permission name for this Permission Group name.
public String getPAAppPermissionNameFromAndroidPermission(String permission)
permission
- The Android permission to convert to a Platform-Agnostic App Permission name.Returns null if there's no Platform-Agnostic App Permission for this Android permission.
public String[] getRequestedPermissions()
String
array with the name of each
Returns null if no
public String[] getRequestedPermissionsInState(PermissionState permissionState)
Note: "Requested Permissions" are those defined in the
AndroidManifest.xml. As such, calling this
method with the argument "PermissionState.MISSING"
is invalid.
permissionState
- A PermissionState
corresponding to the state of the requested
permissions we wish to fetch.String
array containing all the requested permissions in the desired state.
Returns null if given invalid arguments, in an invalid environemnt, or unable to get PackageInfo from the Android PackageManager.
public String[] getRequestedPermissionsInStateForGroup(PermissionState permissionState, String permissionGroup)
Note: "Requested Permissions" are those defined in the
AndroidManifest.xml. As such, calling this
method with the argument "PermissionState.MISSING"
is invalid.
permissionState
- A PermissionState
corresponding to the state of the requested
permissions we wish to fetch.permissionGroup
- The Permission Group for which we want to get all the Android permissions in the
AndroidManifest.xml.String
array containing all the requested permissions in the
desired state for the desired Permission Group.
Returns null if given invalid arguments, in an invalid environemnt, or unable to get PackageInfo from the Android PackageManager.
public String[] getSupportedPermissionGroups()
String
array of all dangerous-level permissions groups supported by Corona.public boolean isPartOfPAAppPermission(String permission)
permission
- The Android permission to check.public boolean isPAAppPermissionName(String name)
name
- The name we're checking.public boolean isSupportedPermissionGroupName(String name)
name
- The name we're checking.public boolean isPermissionInManifest(String permission)
permission
- The Android permission we're looking for.public final void requestPermissions(PermissionsSettings settings, CoronaActivity.OnRequestPermissionsResultHandler resultHandler)
settings
- The PermissionsSettings
used for this request.
Cannot be null!resultHandler
- The
OnRequestPermissionsResultHandler
that will be used to handle this permissions request.public void requestAllDeniedPermissionsInGroup(String permissionGroup, CoronaActivity.OnRequestPermissionsResultHandler resultHandler)
permissionGroup
- The Permission Group we want to request all denied permissions for.resultHandler
- The
OnRequestPermissionsResultHandler
that will be used to handle this permissions request.public boolean shouldNeverAskAgain(String permission)
permission
- The Android permission we want to know if it should never be requested again.public void showPermissionMissingFromManifestAlert(String permission, String message)
permission
- The name of the permission that's missing.message
- A message to explain why the action can't be performed.public void showPermissionGroupMissingFromManifestAlert(String permissionGroup)
permissionGroup
- The name of the permission group that's there's no permissions for.