当前位置: 首页>>代码示例>>Java>>正文


Java PermissionInfo.PROTECTION_MASK_BASE属性代码示例

本文整理汇总了Java中android.content.pm.PermissionInfo.PROTECTION_MASK_BASE属性的典型用法代码示例。如果您正苦于以下问题:Java PermissionInfo.PROTECTION_MASK_BASE属性的具体用法?Java PermissionInfo.PROTECTION_MASK_BASE怎么用?Java PermissionInfo.PROTECTION_MASK_BASE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.pm.PermissionInfo的用法示例。


在下文中一共展示了PermissionInfo.PROTECTION_MASK_BASE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isDisplayablePermission

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 AppDetails2
    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;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:20,代码来源:AppSecurityPermissions.java

示例2: isDisplayablePermission

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
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;

    // Dangerous and normal permissions are always shown to the user
    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;
}
 
开发者ID:CmDnoEdition,项目名称:fdroid,代码行数:19,代码来源:AppSecurityPermissions.java

示例3: bindData

@Override
public void bindData(View view, int position, PermissionInfo info) {
    Drawable drawable = info.loadIcon(getMContext().getPackageManager());
    mIcon.setImageDrawable(drawable);
    mTitle.setText(info.loadLabel(getMContext().getPackageManager()));
    mContent.setText(info.name);
    mProtectionLevel.setVisibility(View.VISIBLE);
    String protectionLevel = null;
    switch (info.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE) {
        case PermissionInfo.PROTECTION_NORMAL:
            protectionLevel = "normal";
            break;
        case PermissionInfo.PROTECTION_DANGEROUS:
            protectionLevel = "dangerous";
            break;
        case PermissionInfo.PROTECTION_SIGNATURE:
            protectionLevel = "signature";
            break;
        case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
            protectionLevel = "signature Or system";
            break;
    }
    mProtectionLevel.setText(protectionLevel);
}
 
开发者ID:binkery,项目名称:allinone,代码行数:24,代码来源:PermissionRecyclerItem.java

示例4: isRevocable

public static boolean isRevocable(@NonNull final Context context, @NonNull final String permission) {
    if (Build.VERSION.SDK_INT < MARSHMALLOW) {
        return false;
    }

    final PackageManager packageManager = context.getPackageManager();
    if (packageManager == null) {
        return false;
    }
    try {
        final PermissionInfo permissionInfo = packageManager.getPermissionInfo(permission, 0);
        @SuppressLint("InlinedApi") // API-16+
        final int protectionLevel = (permissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE);
        return (protectionLevel != PermissionInfo.PROTECTION_NORMAL);
    }
    catch (final Exception e) {
        Log.e(TAG, e.getMessage(), e);
        return false;
    }
}
 
开发者ID:shkschneider,项目名称:android_RuntimePermissionsCompat,代码行数:20,代码来源:RuntimePermissionsCompat.java

示例5: isDisplayablePermission

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);
    final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS);
    // TODO: recheck
    //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 ((isNormal || 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.
    return isDevelopment && wasGranted;
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:26,代码来源:AppSecurityPermissions.java

示例6: isDisplayablePermission

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
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;
    final boolean isDangerous = base == PermissionInfo.PROTECTION_DANGEROUS;
    final boolean isRequired =
            (newReqFlags & PackageInfo.REQUESTED_PERMISSION_REQUIRED) != 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 ((isNormal || isDangerous) && (isRequired || wasGranted || isGranted ||
            Build.VERSION.SDK_INT < 16)) {
        return true;
    }

    final boolean isDevelopment =
            (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 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;
}
 
开发者ID:nutellarlz,项目名称:AppHub,代码行数:28,代码来源:AppSecurityPermissions.java

示例7: getProtectionLevelString

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;
}
 
开发者ID:MajeurAndroid,项目名称:Android-Applications-Info,代码行数:27,代码来源:Utils.java

示例8: isRuntimePermission

private boolean isRuntimePermission(PackageManager packageManager, String permission) {
    try {
        PermissionInfo pInfo = packageManager.getPermissionInfo(permission, 0);
        if (pInfo != null) {
            if ((pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
                    == PermissionInfo.PROTECTION_DANGEROUS) {
                return true;
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
        Log.i(TAG, "Could not retrieve info about the permission: " + permission);
    }
    return false;
}
 
开发者ID:googlesamples,项目名称:android-testdpc,代码行数:14,代码来源:PostProvisioningTask.java

示例9: checkProtectionLevelRaw

@SuppressLint("InlinedApi")
// TODO: drop this method once we migrate PermissionFetcher to MyPackageManager
static boolean checkProtectionLevelRaw(PermissionInfo permissionInfo, int protectionFilter) {
    // Skip test if all options are checked
    if ((protectionFilter & PROTECTION_ANY_LEVEL) == PROTECTION_ANY_LEVEL) {
        return true;
    }

    // Test protectionLevel
    int protectionLevel = permissionInfo.protectionLevel;
    if (protectionLevel == PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM) {
        protectionLevel = PermissionInfo.PROTECTION_SIGNATURE | PermissionInfo.PROTECTION_FLAG_SYSTEM;
    }
    int protectionLevelBase = protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
    int protectionLevelFlags = protectionLevel & PermissionInfo.PROTECTION_MASK_FLAGS;

    // Match against our flags
    return ((
            protectionLevel == PermissionInfo.PROTECTION_NORMAL ? PROTECTION_NORMAL :
            protectionLevel == PermissionInfo.PROTECTION_DANGEROUS ? PROTECTION_DANGEROUS :
            (
                ((protectionLevelBase == PermissionInfo.PROTECTION_SIGNATURE)
                    ? PROTECTION_SIGNATURE : 0) |
                    (((protectionLevelFlags & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0)
                            ? PROTECTION_SYSTEM : 0) |
                    (((protectionLevelFlags & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0)
                            ? PROTECTION_DEVELOPMENT : 0)
            )
    ) & protectionFilter) != 0;
}
 
开发者ID:michalbednarski,项目名称:IntentsLab,代码行数:30,代码来源:ComponentFetcher.java

示例10: protectionLevelToString

@SuppressLint("InlinedApi")
private static String protectionLevelToString(int protectionLevel) {
    int base = protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
    int flags = protectionLevel & PermissionInfo.PROTECTION_MASK_FLAGS;

    // Base
    StringBuilder builder = new StringBuilder(
            base == PermissionInfo.PROTECTION_NORMAL ? "normal" :
            base == PermissionInfo.PROTECTION_DANGEROUS ? "dangerous" :
            base == PermissionInfo.PROTECTION_SIGNATURE ? "signature" :
            base == PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM ? "signatureOrSystem" :
                    String.valueOf(base) // If none matched
    );

    // Flags
    if ((flags & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) {
        builder.append("|system");
    }
    if ((flags & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
        builder.append("|development");
    }

    // Unrecognized flags
    int unknownFlags = flags & ~(
            PermissionInfo.PROTECTION_FLAG_SYSTEM |
            PermissionInfo.PROTECTION_FLAG_DEVELOPMENT
    );
    if (unknownFlags != 0) {
        builder.append("|");
        builder.append(unknownFlags);
    }
    return builder.toString();
}
 
开发者ID:michalbednarski,项目名称:IntentsLab,代码行数:33,代码来源:PermissionInfoFragment.java

示例11: isSignature

@Override
public boolean isSignature() {
    int baseProtection = mSystemPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
    return
            baseProtection == PermissionInfo.PROTECTION_SIGNATURE ||
            baseProtection == PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM;
}
 
开发者ID:michalbednarski,项目名称:IntentsLab,代码行数:7,代码来源:MyPermissionInfoImpl.java

示例12: isSystem

@Override
public boolean isSystem() {
    if (!isSignature()) {
        return false;
    }

    int protectionLevel = mSystemPermissionInfo.protectionLevel;

    return
            (protectionLevel & PermissionInfo.PROTECTION_MASK_BASE) == PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM ||
            (protectionLevel & PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0;
}
 
开发者ID:michalbednarski,项目名称:IntentsLab,代码行数:12,代码来源:MyPermissionInfoImpl.java

示例13: parsePermission

private Permission parsePermission(DynamicApkInfo owner, Resources res,
                                       XmlPullParser parser, AttributeSet attrs, String[] outError)
            throws XmlPullParserException, IOException {
        Permission perm = new Permission(owner);

        TypedArray sa = res.obtainAttributes(attrs,
                Hooks.getStyleableArray("AndroidManifestPermission"));

        if (!parsePackageItemInfo(owner, perm.info, outError,
                "<permission>", sa,
                Hooks.getStyleable("AndroidManifestPermission_name"),
                Hooks.getStyleable("AndroidManifestPermission_label"),
                Hooks.getStyleable("AndroidManifestPermission_icon"),
                Hooks.getStyleable("AndroidManifestPermission_logo"),
                Hooks.getStyleable("AndroidManifestPermission_banner"))) {
            sa.recycle();
            mParseError = INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
            return null;
        }

        // Note: don't allow this value to be a reference to a resource
        // that may change.
        perm.info.group = sa.getNonResourceString(
                Hooks.getStyleable("AndroidManifestPermission_permissionGroup"));
        if (perm.info.group != null) {
            perm.info.group = perm.info.group.intern();
        }

        perm.info.descriptionRes = sa.getResourceId(
                Hooks.getStyleable("AndroidManifestPermission_description"),
                0);

        perm.info.protectionLevel = sa.getInt(
                Hooks.getStyleable("AndroidManifestPermission_protectionLevel"),
                PermissionInfo.PROTECTION_NORMAL);

        perm.info.flags = sa.getInt(
                Hooks.getStyleable("AndroidManifestPermission_permissionFlags"), 0);

        sa.recycle();

        if (perm.info.protectionLevel == -1) {
            outError[0] = "<permission> does not specify protectionLevel";
            mParseError = INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
            return null;
        }

//        perm.info.protectionLevel = PermissionInfo.fixProtectionLevel(perm.info.protectionLevel);

        if ((perm.info.protectionLevel&PermissionInfo.PROTECTION_MASK_FLAGS) != 0) {
            if ((perm.info.protectionLevel&PermissionInfo.PROTECTION_MASK_BASE) !=
                    PermissionInfo.PROTECTION_SIGNATURE) {
                outError[0] = "<permission>  protectionLevel specifies a flag but is "
                        + "not based on signature type";
                mParseError = INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                return null;
            }
        }

        if (!parseAllMetaData(res, parser, attrs, "<permission>", perm,
                outError)) {
            mParseError = INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
            return null;
        }

        owner.permissions.add(perm);

        return perm;
    }
 
开发者ID:ximsfei,项目名称:Android-plugin-support,代码行数:69,代码来源:DynamicApkParser.java

示例14: isNormal

@Override
public boolean isNormal() {
    return (mSystemPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
            == PermissionInfo.PROTECTION_NORMAL;
}
 
开发者ID:michalbednarski,项目名称:IntentsLab,代码行数:5,代码来源:MyPermissionInfoImpl.java

示例15: isDangerous

@Override
public boolean isDangerous() {
    return (mSystemPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
            == PermissionInfo.PROTECTION_DANGEROUS;
}
 
开发者ID:michalbednarski,项目名称:IntentsLab,代码行数:5,代码来源:MyPermissionInfoImpl.java


注:本文中的android.content.pm.PermissionInfo.PROTECTION_MASK_BASE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。