Example usage for android.content.pm PermissionInfo PROTECTION_FLAG_PRE23

List of usage examples for android.content.pm PermissionInfo PROTECTION_FLAG_PRE23

Introduction

In this page you can find the example usage for android.content.pm PermissionInfo PROTECTION_FLAG_PRE23.

Prototype

int PROTECTION_FLAG_PRE23

To view the source code for android.content.pm PermissionInfo PROTECTION_FLAG_PRE23.

Click Source Link

Document

Additional flag for #protectionLevel , corresponding to the pre23 value of android.R.attr#protectionLevel .

Usage

From source file:org.fdroid.fdroid.privileged.views.AppSecurityPermissions.java

private boolean isDisplayablePermission(PermissionInfo pInfo, int existingReqFlags) {
    final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
    final boolean isNormal = base == PermissionInfo.PROTECTION_NORMAL;
    final boolean isDangerous = base == PermissionInfo.PROTECTION_DANGEROUS
            || ((pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_PRE23) != 0);

    // Dangerous and normal permissions are always shown to the user
    // this is matches the permission list in AppDetails
    if (isNormal || isDangerous) {
        return true;
    }/*from  w  w  w.j  av  a  2 s  . c  o m*/

    final boolean isDevelopment = (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0;
    final boolean wasGranted = (existingReqFlags & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0;

    // Development permissions are only shown to the user if they are already
    // granted to the app -- if we are installing an app and they are not
    // already granted, they will not be granted as part of the install.
    return isDevelopment && wasGranted;
}