本文整理匯總了Java中android.content.pm.PermissionInfo.PROTECTION_MASK_FLAGS屬性的典型用法代碼示例。如果您正苦於以下問題:Java PermissionInfo.PROTECTION_MASK_FLAGS屬性的具體用法?Java PermissionInfo.PROTECTION_MASK_FLAGS怎麽用?Java PermissionInfo.PROTECTION_MASK_FLAGS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.content.pm.PermissionInfo
的用法示例。
在下文中一共展示了PermissionInfo.PROTECTION_MASK_FLAGS屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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();
}
示例3: 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;
}