本文整理汇总了Java中android.content.pm.PermissionInfo.PROTECTION_SIGNATURE属性的典型用法代码示例。如果您正苦于以下问题:Java PermissionInfo.PROTECTION_SIGNATURE属性的具体用法?Java PermissionInfo.PROTECTION_SIGNATURE怎么用?Java PermissionInfo.PROTECTION_SIGNATURE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.pm.PermissionInfo
的用法示例。
在下文中一共展示了PermissionInfo.PROTECTION_SIGNATURE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: protectionLevel
@SuppressWarnings("deprecation")
public String protectionLevel() {
switch (this.protectionLevel) {
case PermissionInfo.PROTECTION_NORMAL:
return "PROTECTION_NORMAL";
case PermissionInfo.PROTECTION_DANGEROUS:
return "PROTECTION_DANGEROUS";
case PermissionInfo.PROTECTION_SIGNATURE:
return "PROTECTION_SIGNATURE";
case PermissionInfo.PROTECTION_SIGNATURE | PermissionInfo.PROTECTION_FLAG_PRIVILEGED:
return "PROTECTION_PRIVILEGED";
case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
return "PROTECTION_SYSTEM";
default:
return "<UNKNOWN>";
}
}
示例3: buildFakePackageInfo
public static PackageInfo buildFakePackageInfo (PackageInfo info) {
info.requestedPermissions = new String[]{Manifest.permission.VIBRATE,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.GET_TASKS,
Manifest.permission.INTERNET,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.ACCESS_WIFI_STATE,
info.packageName + ".permission.MIPUSH_RECEIVE"};
PermissionInfo permissionInfo = new PermissionInfo();
permissionInfo.protectionLevel = PermissionInfo.PROTECTION_SIGNATURE;
permissionInfo.name = info.packageName + ".permission.MIPUSH_RECEIVE";
info.permissions = new PermissionInfo[]{permissionInfo};
return info;
}
示例4: getProtectionLevel
private ProtectionLevelView.ProtectionLevel getProtectionLevel(int level) {
switch (level) {
case PermissionInfo.PROTECTION_NORMAL:
return ProtectionLevelView.ProtectionLevel.NORMAL;
case PermissionInfo.PROTECTION_DANGEROUS:
return ProtectionLevelView.ProtectionLevel.DANGEROUS;
case PermissionInfo.PROTECTION_SIGNATURE:
return ProtectionLevelView.ProtectionLevel.SIGNATURE;
default:
throw new IllegalArgumentException("No protection level for " + level);
}
}
示例5: canReadLabels
/**
* Check if the installed Gmail app supports querying for label information.
*
* @param c an application Context
* @return true if it's safe to make label API queries
*/
public static boolean canReadLabels(Context c) {
boolean supported = false;
try {
final PackageInfo info = c.getPackageManager().getPackageInfo(PACKAGE,
PackageManager.GET_PROVIDERS | PackageManager.GET_PERMISSIONS);
boolean allowRead = false;
if (info.permissions != null) {
for (int i = 0, len = info.permissions.length; i < len; i++) {
final PermissionInfo perm = info.permissions[i];
if (PERMISSION.equals(perm.name)
&& perm.protectionLevel < PermissionInfo.PROTECTION_SIGNATURE) {
allowRead = true;
break;
}
}
}
if (allowRead && info.providers != null) {
for (int i = 0, len = info.providers.length; i < len; i++) {
final ProviderInfo provider = info.providers[i];
if (AUTHORITY.equals(provider.authority) &&
TextUtils.equals(PERMISSION, provider.readPermission)) {
supported = true;
}
}
}
} catch (NameNotFoundException e) {
// Gmail app not found
}
return supported;
}
示例6: 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;
}
示例7: BasePermission
BasePermission(String _name, String _sourcePackage, int _type)
{
name = _name;
sourcePackage = _sourcePackage;
type = _type;
// Default to most conservative protection level.
protectionLevel = PermissionInfo.PROTECTION_SIGNATURE;
}
示例8: 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;
}
示例9: 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();
}
示例10: isSignature
@Override
public boolean isSignature() {
int baseProtection = mSystemPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
return
baseProtection == PermissionInfo.PROTECTION_SIGNATURE ||
baseProtection == PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM;
}
示例11: canReadLabels
/**
* Check if the installed Gmail app supports querying for label information.
*
* @param c
* an application Context
* @return true if it's safe to make label API queries
*/
public static boolean canReadLabels(Context c) {
boolean supported = false;
try {
final PackageInfo info = c.getPackageManager().getPackageInfo(
PACKAGE,
PackageManager.GET_PROVIDERS
| PackageManager.GET_PERMISSIONS);
boolean allowRead = false;
if (info.permissions != null) {
for (int i = 0, len = info.permissions.length; i < len; i++) {
final PermissionInfo perm = info.permissions[i];
if (PERMISSION.equals(perm.name)
&& perm.protectionLevel < PermissionInfo.PROTECTION_SIGNATURE) {
allowRead = true;
break;
}
}
}
if (allowRead && info.providers != null) {
for (int i = 0, len = info.providers.length; i < len; i++) {
final ProviderInfo provider = info.providers[i];
if (AUTHORITY.equals(provider.authority)
&& TextUtils.equals(PERMISSION,
provider.readPermission)) {
supported = true;
}
}
}
} catch (NameNotFoundException e) {
// Gmail app not found
}
return supported;
}
示例12: 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;
}