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


Java PermissionInfo类代码示例

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


PermissionInfo类属于android.content.pm包,在下文中一共展示了PermissionInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPermissionInfo

import android.content.pm.PermissionInfo; //导入依赖的package包/类
/**
 * Returns information string about permission
 **/
@Nullable
private static String getPermissionInfo(@NonNull Context context, @NonNull String permission) {
    context = context.getApplicationContext();
    PackageManager pm = context.getPackageManager();
    PermissionInfo info = null;
    try {
        info = pm.getPermissionInfo(permission, PackageManager.GET_META_DATA);
    } catch (PackageManager.NameNotFoundException ex) {
        Log.w(TAG, ex);
    }

    if (info != null) {
        CharSequence label = info.loadLabel(pm);
        if (label == null) {
            label = info.nonLocalizedLabel;
        }
        return label.toString();
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:25,代码来源:Permissions.java

示例2: isDisplayablePermission

import android.content.pm.PermissionInfo; //导入依赖的package包/类
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,代码行数:21,代码来源:AppSecurityPermissions.java

示例3: getPermissionInfo

import android.content.pm.PermissionInfo; //导入依赖的package包/类
public PermissionInfo getPermissionInfo(String name, int flags) throws RemoteException {
    waitForReadyInner();
    try {
        enforcePluginFileExists();
        if (shouldNotBlockOtherInfo()) {
            for (PluginPackageParser pluginPackageParser : this.mPluginCache.values()) {
                for (PermissionInfo permissionInfo : pluginPackageParser.getPermissions()) {
                    if (TextUtils.equals(permissionInfo.name, name)) {
                        return permissionInfo;
                    }
                }
            }
        }
        List<String> pkgs = this.mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
        for (PluginPackageParser pluginPackageParser2 : this.mPluginCache.values()) {
            for (PermissionInfo permissionInfo2 : pluginPackageParser2.getPermissions()) {
                if (TextUtils.equals(permissionInfo2.name, name) && pkgs.contains(permissionInfo2.packageName)) {
                    return permissionInfo2;
                }
            }
        }
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:IApkManagerImpl.java

示例4: initUi

import android.content.pm.PermissionInfo; //导入依赖的package包/类
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,代码行数:21,代码来源:PermissionExplanationDialogPresenter.java

示例5: beforeInvoke

import android.content.pm.PermissionInfo; //导入依赖的package包/类
@Override
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
    //API 2.3, 4.01_r1, 4.0.3_r1, 4.1.1_r1, 4.2_r1, 4.3_r1, 4.4_r1, 5.0.2_r1
      /*public PermissionInfo getPermissionInfo(String name, int flags) throws RemoteException;*/
    if (args != null) {
        final int index0 = 0, index1 = 1;
        if (args.length > 1 && args[index0] instanceof String && args[index1] instanceof Integer) {
            String packageName = (String) args[index0];
            int flags = (Integer) args[index1];
            PermissionInfo permissionInfo = PluginManager.getInstance().getPermissionInfo(packageName, flags);
            if (permissionInfo != null) {
                setFakedResult(permissionInfo);
                return true;
            }
        }
    }

    return super.beforeInvoke(receiver, method, args);
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:20,代码来源:IPackageManagerHookHandle.java

示例6: afterInvoke

import android.content.pm.PermissionInfo; //导入依赖的package包/类
@Override
protected void afterInvoke(Object receiver, Method method, Object[] args, Object invokeResult) throws Throwable {
    //API 2.3, 4.01_r1, 4.0.3_r1, 4.1.1_r1, 4.2_r1, 4.3_r1, 4.4_r1, 5.0.2_r1
    /*public List<PermissionInfo> queryPermissionsByGroup(String group, int flags) throws RemoteException;*/
    if (args != null && invokeResult instanceof List) {
        final int index0 = 0, index1 = 1;
        if (args.length > 1 && args[index0] instanceof String && args[index1] instanceof Integer) {
            String group = (String) args[index0];
            int flags = (Integer) args[index1];
            List<PermissionInfo> infos = PluginManager.getInstance().queryPermissionsByGroup(group, flags);
            if (infos != null && infos.size() > 0) {
                List old = (List) invokeResult;
                old.addAll(infos);
            }
        }
    }
    super.afterInvoke(receiver, method, args, invokeResult);
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:19,代码来源:IPackageManagerHookHandle.java

示例7: getPermissions

import android.content.pm.PermissionInfo; //导入依赖的package包/类
/**
 * use for get {@link PermissionInfo} of all @param required
 *
 * @param context
 * @param required
 * @return
 */
private static List<PermissionInfo> getPermissions(Context context, List<String> required) {

    List<PermissionInfo> permissionInfoList = new ArrayList<>();

    PackageManager pm = context.getPackageManager();
    for (String permission : required) {
        PermissionInfo pinfo = null;
        try {
            pinfo = pm.getPermissionInfo(permission, PackageManager.GET_META_DATA);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            continue;
        }

        permissionInfoList.add(pinfo);
    }
    return permissionInfoList;
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:26,代码来源:PermissionsHelper.java

示例8: joinOpEntryInfo

import android.content.pm.PermissionInfo; //导入依赖的package包/类
private static void joinOpEntryInfo(OpEntryInfo opEntryInfo,Context context){
  String groupS = FAKE_PERMS_GROUP.get(opEntryInfo.opName);

  try {
    if (groupS == null && opEntryInfo.opPermsName != null) {
      PermissionInfo permissionInfo = context.getPackageManager()
          .getPermissionInfo(opEntryInfo.opPermsName, PackageManager.GET_META_DATA);
      groupS = permissionInfo.group;
    }
  } catch (Exception e) {
    //ignore
  }

  PermGroupInfo permGroupInfo = null;
  if (groupS != null) {
    permGroupInfo = PERMS_GROUPS.get(groupS);
  }

  if (permGroupInfo == null) {
    permGroupInfo = OTHER_PERM_INFO;
  }

  opEntryInfo.icon = permGroupInfo.icon;
  opEntryInfo.groupName = permGroupInfo.group;

}
 
开发者ID:8enet,项目名称:AppOpsX,代码行数:27,代码来源:Helper.java

示例9: createPmPermissionInfo

import android.content.pm.PermissionInfo; //导入依赖的package包/类
/**
 * 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,代码行数:35,代码来源:PackageInfoAssembler.java

示例10: getAppPermissions

import android.content.pm.PermissionInfo; //导入依赖的package包/类
@Nullable public static List<PermissionsView> getAppPermissions(@NonNull Context context, String packageName) {
    try {
        List<PermissionsView> permissionsViews = new ArrayList<>();
        PackageInfo info = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
        for (String permission : info.requestedPermissions) {
            PermissionInfo permissionInfo = getPermissionInfo(context, permission);
            if (!InputHelper.isEmpty(permission) && permissionInfo != null &&
                    !InputHelper.isEmpty(permissionInfo.loadDescription(context.getPackageManager()))) {
                permissionsViews.add(PermissionsView.getInstance(permission));
            }
        }
        return permissionsViews;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:k0shk0sh,项目名称:NewKam,代码行数:18,代码来源:ApkHelper.java

示例11: doPermissionCheck

import android.content.pm.PermissionInfo; //导入依赖的package包/类
private void doPermissionCheck(Context context, ResultCollector collector, final String permission) {
    PackageManager pm = context.getPackageManager();
    try {
        PermissionInfo info = pm.getPermissionInfo(permission, 0);
        PermissionGroupInfo groupInfo = info.group != null ? pm.getPermissionGroupInfo(info.group, 0) : null;
        CharSequence permLabel = info.loadLabel(pm);
        CharSequence groupLabel = groupInfo != null ? groupInfo.loadLabel(pm) : permLabel;
        collector.addResult(context.getString(R.string.self_check_name_permission, permLabel),
                context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED ? Positive : Negative,
                context.getString(R.string.self_check_resolution_permission, groupLabel),
                new SelfCheckGroup.CheckResolver() {

                    @Override
                    public void tryResolve(Fragment fragment) {
                        fragment.requestPermissions(new String[]{permission}, 0);
                    }
                });
    } catch (PackageManager.NameNotFoundException e) {
        Log.w(TAG, e);
    }
}
 
开发者ID:microg,项目名称:android_external_MicroGUiTools,代码行数:22,代码来源:PermissionCheckGroup.java

示例12: isDisplayablePermission

import android.content.pm.PermissionInfo; //导入依赖的package包/类
@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,代码行数:20,代码来源:AppSecurityPermissions.java

示例13: getHumanReadablePermissionString

import android.content.pm.PermissionInfo; //导入依赖的package包/类
private static String getHumanReadablePermissionString(String paramString)
{
  try
  {
    PermissionInfo localPermissionInfo = FinskyApp.get().getPackageManager().getPermissionInfo(paramString, 0);
    if (localPermissionInfo != null)
    {
      CharSequence localCharSequence = localPermissionInfo.loadLabel(FinskyApp.get().getPackageManager());
      if (localCharSequence == null) {
        return null;
      }
      String str = localCharSequence.toString();
      return str;
    }
  }
  catch (PackageManager.NameNotFoundException localNameNotFoundException) {}
  return null;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:19,代码来源:PermissionsBucketer.java

示例14: isDangerousPlatformDefinedPermission

import android.content.pm.PermissionInfo; //导入依赖的package包/类
private static boolean isDangerousPlatformDefinedPermission(String paramString)
{
  try
  {
    PermissionInfo localPermissionInfo = FinskyApp.get().getPackageManager().getPermissionInfo(paramString, 0);
    if (localPermissionInfo != null)
    {
      int i = localPermissionInfo.protectionLevel;
      if (i == 1) {
        return true;
      }
    }
  }
  catch (PackageManager.NameNotFoundException localNameNotFoundException) {}
  return false;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:17,代码来源:PermissionsBucketer.java

示例15: bindData

import android.content.pm.PermissionInfo; //导入依赖的package包/类
@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,代码行数:25,代码来源:PermissionRecyclerItem.java


注:本文中的android.content.pm.PermissionInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。