當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。