public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) throws RemoteException { waitForReadyInner(); try { enforcePluginFileExists(); if (shouldNotBlockOtherInfo()) { for (PluginPackageParser pluginPackageParser : this.mPluginCache.values()) { for (PermissionGroupInfo permissionGroupInfo : pluginPackageParser.getPermissionGroups()) { if (TextUtils.equals(permissionGroupInfo.name, name)) { return permissionGroupInfo; } } } } List<String> pkgs = this.mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid()); for (PluginPackageParser pluginPackageParser2 : this.mPluginCache.values()) { for (PermissionGroupInfo permissionGroupInfo2 : pluginPackageParser2.getPermissionGroups()) { if (TextUtils.equals(permissionGroupInfo2.name, name) && pkgs.contains(permissionGroupInfo2.packageName)) { return permissionGroupInfo2; } } } } catch (Exception e) { handleException(e); } return null; }
@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 PermissionGroupInfo getPermissionGroupInfo(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 name = (String) args[index0]; int flags = (Integer) args[index1]; PermissionGroupInfo permissionInfo = PluginManager.getInstance().getPermissionGroupInfo(name, flags); if (permissionInfo != null) { setFakedResult(permissionInfo); return true; } } } return super.beforeInvoke(receiver, method, args); }
@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<PermissionGroupInfo> getAllPermissionGroups(int flags) throws RemoteException;*/ if (args != null && invokeResult instanceof List) { final int index = 0; if (args.length > index && args[index] instanceof Integer) { int flags = (Integer) args[index]; List<PermissionGroupInfo> infos = PluginManager.getInstance().getAllPermissionGroups(flags); if (infos != null && infos.size() > 0) { List old = (List) invokeResult; old.addAll(infos); } } } super.afterInvoke(receiver, method, args, invokeResult); }
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); } }
public List<PermissionInfo> getAll() { if (allPerms == null) { allPerms = new ArrayList<PermissionInfo>(); List<PermissionGroupInfo> permGroups = getAllGroups(); permGroups.add(null); for (PermissionGroupInfo pgi : permGroups) { List<PermissionInfo> perms; try { perms = getByGroup(pgi == null ? null : pgi.name); } catch (NameNotFoundException e) { throw new AssertionError(); } allPerms.addAll(perms); } Collections.sort(allPerms, PermissionComparator.getInstance()); } return Collections.unmodifiableList(allPerms); }
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) throws RemoteException { waitForReadyInner(); try { enforcePluginFileExists(); List<PermissionGroupInfo> list = new ArrayList(); if (shouldNotBlockOtherInfo()) { for (PluginPackageParser pluginPackageParser : this.mPluginCache.values()) { for (PermissionGroupInfo permissionGroupInfo : pluginPackageParser.getPermissionGroups()) { if (!list.contains(permissionGroupInfo)) { list.add(permissionGroupInfo); } } } return list; } List<String> pkgs = this.mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid()); for (PluginPackageParser pluginPackageParser2 : this.mPluginCache.values()) { for (PermissionGroupInfo permissionGroupInfo2 : pluginPackageParser2.getPermissionGroups()) { if (!list.contains(permissionGroupInfo2) && pkgs.contains(permissionGroupInfo2.packageName)) { list.add(permissionGroupInfo2); } } } return list; } catch (Exception e) { handleException(e); return null; } }
public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) throws RemoteException { try { if (!(this.mApkManager == null || name == null)) { return this.mApkManager.getPermissionGroupInfo(name, flags); } } catch (RemoteException e) { JLog.log("wuxinrong", "获取PermissionGroupInfo 失败 e=" + e.getMessage()); throw e; } catch (Exception e2) { JLog.log("wuxinrong", "获取PermissionGroupInfo 失败 e=" + e2.getMessage()); } return null; }
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) throws RemoteException { try { if (this.mApkManager != null) { return this.mApkManager.getAllPermissionGroups(flags); } } catch (RemoteException e) { JLog.log("wuxinrong", "获取PermissionGroupInfo列表 失败 e=" + e.getMessage()); throw e; } catch (Exception e2) { JLog.log("wuxinrong", "获取PermissionGroupInfo列表 失败 e=" + e2.getMessage()); } return null; }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { String name = (String) args[0]; int flags = (int) args[1]; PermissionGroupInfo info = VPackageManager.get().getPermissionGroupInfo(name, flags); if (info != null) { return info; } return super.call(who, method, args); }
public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) { try { return getInterface().getPermissionGroupInfo(name, flags); } catch (RemoteException e) { return VirtualRuntime.crash(e); } }
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { try { return getInterface().getAllPermissionGroups(flags); } catch (RemoteException e) { return VirtualRuntime.crash(e); } }
public static PermissionGroupInfo generatePermissionGroupInfo( VPackage.PermissionGroupComponent pg, int flags) { if (pg == null) return null; if ((flags & PackageManager.GET_META_DATA) == 0) { return pg.info; } PermissionGroupInfo pgi = new PermissionGroupInfo(pg.info); pgi.metaData = pg.metaData; return pgi; }
@Override public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) { synchronized (mPackages) { VPackage.PermissionGroupComponent p = mPermissionGroups.get(name); if (p != null) { return new PermissionGroupInfo(p.info); } } return null; }
@Override public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { synchronized (mPackages) { final int N = mPermissionGroups.size(); ArrayList<PermissionGroupInfo> out = new ArrayList<>(N); for (VPackage.PermissionGroupComponent pg : mPermissionGroups.values()) { out.add(new PermissionGroupInfo(pg.info)); } return out; } }
private PermissionGroupInfo getPermissionGroupInfo(PackageManager packageManager, String group) { if (TextUtils.isEmpty(group)) { return null; } try { return packageManager.getPermissionGroupInfo(group, 0); } catch (PackageManager.NameNotFoundException e) { UILog.w("Can't find permission group " + group, e); return null; } }
@Override public PermissionGroupInfo generatePermissionGroupInfo( Object permissionGroup, int flags) throws Exception { /* public static final PermissionGroupInfo generatePermissionGroupInfo( PermissionGroup pg, int flags) */ return super.generatePermissionGroupInfo(permissionGroup, flags); }
public PermissionGroupInfo getPermissionGroupInfo(ComponentName className, int flags) throws Exception { Object data; synchronized (mPermissionGroupObjCache) { data = mPermissionGroupObjCache.get(className); } if (data != null) { return mParser.generatePermissionGroupInfo(data, flags); } return null; }
@Override public PermissionGroupInfo generatePermissionGroupInfo( Object permissionGroup, int flags) throws Exception { /* public static final PermissionGroupInfo generatePermissionGroupInfo( PermissionGroup pg, int flags)*/ Method method = MethodUtils.getAccessibleMethod(sPackageParserClass, "generatePermissionGroupInfo", sPermissionGroupClass, int.class); return (PermissionGroupInfo) method.invoke(null, permissionGroup, flags); }
@Override public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) { synchronized (mPackages) { PackageParser.PermissionGroup p = mPermissionGroups.get(name); if (p != null) { return new PermissionGroupInfo(p.info); } } return null; }
@Override public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { synchronized (mPackages) { final int N = mPermissionGroups.size(); ArrayList<PermissionGroupInfo> out = new ArrayList<>(N); for (PackageParser.PermissionGroup pg : mPermissionGroups.values()) { out.add(new PermissionGroupInfo(pg.info)); } return out; } }