本文整理汇总了Java中android.content.pm.PermissionInfo.PROTECTION_FLAG_DEVELOPMENT属性的典型用法代码示例。如果您正苦于以下问题:Java PermissionInfo.PROTECTION_FLAG_DEVELOPMENT属性的具体用法?Java PermissionInfo.PROTECTION_FLAG_DEVELOPMENT怎么用?Java PermissionInfo.PROTECTION_FLAG_DEVELOPMENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.pm.PermissionInfo
的用法示例。
在下文中一共展示了PermissionInfo.PROTECTION_FLAG_DEVELOPMENT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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();
}
示例8: isDevelopment
@Override
public boolean isDevelopment() {
return isSignature() && (mSystemPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0;
}