Java Code Examples for android.content.pm.PermissionInfo#PROTECTION_FLAG_DEVELOPMENT

The following examples show how to use android.content.pm.PermissionInfo#PROTECTION_FLAG_DEVELOPMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppSecurityPermissions.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(23)
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 AppDetailsActivity
    if (isNormal || isDangerous) {
        return true;
    }

    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;
}
 
Example 2
Source File: AppSecurityPermissions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean isDisplayablePermission(PermissionInfo pInfo, int newReqFlags,
        int existingReqFlags) {
    final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
    final boolean isNormal = (base == PermissionInfo.PROTECTION_NORMAL);

    // We do not show normal permissions in the UI.
    if (isNormal) {
        return false;
    }

    final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS)
            || ((pInfo.protectionLevel&PermissionInfo.PROTECTION_FLAG_PRE23) != 0);
    final boolean isRequired =
            ((newReqFlags&PackageInfo.REQUESTED_PERMISSION_REQUIRED) != 0);
    final boolean isDevelopment =
            ((pInfo.protectionLevel&PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0);
    final boolean wasGranted =
            ((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
    final boolean isGranted =
            ((newReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);

    // Dangerous and normal permissions are always shown to the user if the permission
    // is required, or it was previously granted
    if (isDangerous && (isRequired || wasGranted || isGranted)) {
        return true;
    }

    // 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.
    if (isDevelopment && wasGranted) {
        if (localLOGV) Log.i(TAG, "Special perm " + pInfo.name
                + ": protlevel=0x" + Integer.toHexString(pInfo.protectionLevel));
        return true;
    }
    return false;
}
 
Example 3
Source File: Utils.java    From Android-Applications-Info with Apache License 2.0 5 votes vote down vote up
public static String getProtectionLevelString(int level) {
    String protLevel = "????";
    switch (level & PermissionInfo.PROTECTION_MASK_BASE) {
        case PermissionInfo.PROTECTION_DANGEROUS:
            protLevel = "dangerous";
            break;
        case PermissionInfo.PROTECTION_NORMAL:
            protLevel = "normal";
            break;
        case PermissionInfo.PROTECTION_SIGNATURE:
            protLevel = "signature";
            break;
        case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
            protLevel = "signatureOrSystem";
            break;
    }
    if ((level & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) {
        protLevel += "|system";
    }
    if ((level & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
        protLevel += "|development";
    }
    if ((level & PermissionInfo.PROTECTION_FLAG_APPOP) != 0) {
        protLevel += "|appop";
    }
    return protLevel;
}
 
Example 4
Source File: BasePermission.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public boolean isDevelopment() {
    return isSignature()
            && (protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0;
}