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


Java PermissionInfo.PROTECTION_DANGEROUS属性代码示例

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


在下文中一共展示了PermissionInfo.PROTECTION_DANGEROUS属性的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: initUi

private void initUi() {
  view.showPermissionStatus(permissionWasGrantedForApp(), permissionCanBeRevoked());

  if (permissionWasGrantedForApp()) {

    if (PermissionInfo.PROTECTION_NORMAL == permission.protectionLevel()) {
      view.showHint(stringProvider.getString(R.string.permission_status_normal));
    }

    if (PermissionInfo.PROTECTION_DANGEROUS == permission.protectionLevel()) {
      if (permissionCanBeRevoked()) {
        view.showHint(stringProvider.getString(R.string.permission_status_revokable));
      } else {
        view.showHint(stringProvider.getString(R.string.permission_status_no_runtime_permissions, Build.VERSION.RELEASE));
      }
    }
  } else {
    view.showHint(stringProvider.getString(R.string.permission_status_no_usage, app.label()));
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:20,代码来源:PermissionExplanationDialogPresenter.java

示例3: createPmPermissionInfo

/**
 * Returns page-entry for each defined permission in the app (the passed activity belongs to).
 * <p>
 * See {@link DefaultProperties#createSectionRuntimePermissions(Activity, List)} for more details
 *
 * @param context                  must not be null and must be instance of activity (needed for getting the state)
 * @param packageInfo              from {@link PackageManager#getPackageInfo(String, int)} requiring {@link PackageManager#GET_PERMISSIONS} flag
 * @param onlyDangerousPermissions only include permissions with flag PROTECTION_DANGEROUS (ie. have to be granted by the user)
 * @return list of page-entries
 */
@SuppressLint("NewApi")
public static List<PageEntry<?>> createPmPermissionInfo(final @NonNull Context context, @NonNull PackageInfo packageInfo, boolean onlyDangerousPermissions) {

    if (!(context instanceof Activity)) {
        throw new IllegalArgumentException("context must be of type activity - needed for getting current permission state");
    }

    List<PageEntry<?>> entries = new ArrayList<>();
    if (packageInfo.requestedPermissions != null && packageInfo.requestedPermissions.length > 0) {
        List<String> permissionNames = new ArrayList<>();
        for (int i = 0; i < packageInfo.requestedPermissions.length; i++) {
            if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1
                    || !onlyDangerousPermissions
                    || packageInfo.requestedPermissionsFlags[i] == PermissionInfo.PROTECTION_DANGEROUS) {
                permissionNames.add(packageInfo.requestedPermissions[i]);
            }
        }
        Collections.sort(permissionNames);

        return DefaultProperties.createSectionRuntimePermissions(((Activity) context), permissionNames).removeHeader().asEntryList();
    }

    return entries;
}
 
开发者ID:patrickfav,项目名称:under-the-hood,代码行数:34,代码来源:PackageInfoAssembler.java

示例4: 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

示例5: 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

示例6: 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>";
    }
}
 
开发者ID:shkschneider,项目名称:android_RuntimePermissionsCompat,代码行数:17,代码来源:Permission.java

示例7: 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

示例8: permissionCanBeRevoked

public boolean permissionCanBeRevoked() {
  if (canBeRevoked == null) {
    canBeRevoked = permission.protectionLevel() == PermissionInfo.PROTECTION_DANGEROUS
        && deviceFeatures.supportsRuntimePermissions()
        && permissionWasGrantedForApp();
  }

  return canBeRevoked;
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:9,代码来源:PermissionExplanationDialogPresenter.java

示例9: 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);
  }
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:12,代码来源:PermissionExplanationDialog.java

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例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_DANGEROUS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。