List of usage examples for android.content.pm PermissionInfo fixProtectionLevel
public static int fixProtectionLevel(int level)
From source file:android.content.pm.PackageParser.java
private Permission parsePermission(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, String[] outError) throws XmlPullParserException, IOException { Permission perm = new Permission(owner); TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestPermission); if (!parsePackageItemInfo(owner, perm.info, outError, "<permission>", sa, com.android.internal.R.styleable.AndroidManifestPermission_name, com.android.internal.R.styleable.AndroidManifestPermission_label, com.android.internal.R.styleable.AndroidManifestPermission_icon, com.android.internal.R.styleable.AndroidManifestPermission_logo, com.android.internal.R.styleable.AndroidManifestPermission_banner)) { sa.recycle();/*w ww .j a va2 s . c o m*/ mParseError = PackageManager.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(com.android.internal.R.styleable.AndroidManifestPermission_permissionGroup); if (perm.info.group != null) { perm.info.group = perm.info.group.intern(); } perm.info.descriptionRes = sa .getResourceId(com.android.internal.R.styleable.AndroidManifestPermission_description, 0); perm.info.protectionLevel = sa.getInt( com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel, PermissionInfo.PROTECTION_NORMAL); perm.info.flags = sa.getInt(com.android.internal.R.styleable.AndroidManifestPermission_permissionFlags, 0); sa.recycle(); if (perm.info.protectionLevel == -1) { outError[0] = "<permission> does not specify protectionLevel"; mParseError = PackageManager.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 = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } } if (!parseAllMetaData(res, parser, attrs, "<permission>", perm, outError)) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } owner.permissions.add(perm); return perm; }