android.content.pm.PermissionGroupInfo Java Examples

The following examples show how to use android.content.pm.PermissionGroupInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IPackageManagerHookHandle.java    From DroidPlugin with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: IApkManagerImpl.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: Permissions.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
private PermissionGroupInfo getPermissionGroupInfo(PermissionInfo permissionInfo) {
    PermissionGroupInfo permissionGroupInfo;
    if (null == permissionInfo.group) {
        permissionGroupInfo = getFakePermissionGroupInfo(permissionInfo.packageName);
    } else {
        try {
            permissionGroupInfo = pm.getPermissionGroupInfo(permissionInfo.group, 0);
        } catch (PackageManager.NameNotFoundException e) {
            permissionGroupInfo = getFakePermissionGroupInfo(permissionInfo.packageName);
        }
    }
    if (permissionGroupInfo.icon == 0) {
        permissionGroupInfo.icon = R.drawable.ic_permission_android;
    }
    return permissionGroupInfo;
}
 
Example #4
Source File: Permissions.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
private PermissionGroupInfo getFakePermissionGroupInfo(String packageName) {
    PermissionGroupInfo permissionGroupInfo = new PermissionGroupInfo();
    switch (packageName) {
        case "android":
            permissionGroupInfo.icon = R.drawable.ic_permission_android;
            permissionGroupInfo.name = "android";
            break;
        case "com.google.android.gsf":
        case "com.android.vending":
            permissionGroupInfo.icon = R.drawable.ic_permission_google;
            permissionGroupInfo.name = "google";
            break;
        default:
            permissionGroupInfo.icon = R.drawable.ic_permission_unknown;
            permissionGroupInfo.name = "unknown";
            break;
    }
    return permissionGroupInfo;

}
 
Example #5
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public PermissionGroupInfo getPermissionGroupInfo(String name,
        int flags) throws NameNotFoundException {
    try {
        PermissionGroupInfo pgi = mPM.getPermissionGroupInfo(name, flags);
        if (pgi != null) {
            return pgi;
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(name);
}
 
Example #6
Source File: ApkManager.java    From letv with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: ApkManager.java    From letv with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: IApkManagerImpl.java    From letv with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #9
Source File: GetPermissionsUtils.java    From Collection-Android with MIT License 5 votes vote down vote up
public static String  getAllPermissons(Context context){

        StringBuffer stringBuffer=new StringBuffer();
        try {
            PackageManager pm = context.getPackageManager();
            PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
            //得到自己的包名
            String pkgName = pi.packageName;

            PermissionGroupInfo pgi;
            PackageInfo pkgInfo = pm.getPackageInfo(pkgName, PackageManager.GET_PERMISSIONS);
            String sharedPkgList[] = pkgInfo.requestedPermissions;
            LogUtils.error("权限",sharedPkgList.length+"");

            for(int i=0;i<sharedPkgList.length;i++){
                String permName = sharedPkgList[i];

                PermissionInfo tmpPermInfo = pm.getPermissionInfo(permName, 0);

                stringBuffer.append("========"+permName+"========"+"\n");
                stringBuffer.append(tmpPermInfo.loadLabel(pm).toString()+"\n");
            }


        } catch (PackageManager.NameNotFoundException e) {
            LogUtils.error("权限","报错:"+e);
        }

        return stringBuffer.toString();
    }
 
Example #10
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        ParceledListSlice<PermissionGroupInfo> parceledList =
                mPM.getAllPermissionGroups(flags);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #11
Source File: VPackageManager.java    From container with GNU General Public License v3.0 5 votes vote down vote up
public PermissionGroupInfo getPermissionGroupInfo(String name, int flags) {
	try {
		return getInterface().getPermissionGroupInfo(name, flags);
	} catch (RemoteException e) {
		return VirtualRuntime.crash(e);
	}
}
 
Example #12
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int runListPermissionGroups() throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    final List<PermissionGroupInfo> pgs = mInterface.getAllPermissionGroups(0).getList();

    final int count = pgs.size();
    for (int p = 0; p < count ; p++) {
        final PermissionGroupInfo pgi = pgs.get(p);
        pw.print("permission group:");
        pw.println(pgi.name);
    }
    return 0;
}
 
Example #13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        return mPM.getAllPermissionGroups(flags);
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example #14
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        return mPM.getAllPermissionGroups(flags);
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example #15
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public PermissionGroupInfo getPermissionGroupInfo(String name,
                                                  int flags) throws NameNotFoundException {
    try {
        PermissionGroupInfo pgi = mPM.getPermissionGroupInfo(name, flags);
        if (pgi != null) {
            return pgi;
        }
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }

    throw new NameNotFoundException(name);
}
 
Example #16
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        ParceledListSlice<PermissionGroupInfo> parceledList =
                mPM.getAllPermissionGroups(flags);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #17
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public PermissionGroupInfo getPermissionGroupInfo(String name,
                                                  int flags) throws NameNotFoundException {
    try {
        PermissionGroupInfo pgi = mPM.getPermissionGroupInfo(name, flags);
        if (pgi != null) {
            return pgi;
        }
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }

    throw new NameNotFoundException(name);
}
 
Example #18
Source File: GetPermissionGroupInfo.java    From container with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #19
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        ParceledListSlice<PermissionGroupInfo> parceledList =
                mPM.getAllPermissionGroups(flags);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #20
Source File: VPackageManager.java    From container with GNU General Public License v3.0 5 votes vote down vote up
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
	try {
		return getInterface().getAllPermissionGroups(flags);
	} catch (RemoteException e) {
		return VirtualRuntime.crash(e);
	}
}
 
Example #21
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #22
Source File: VPackageManagerService.java    From container with GNU General Public License v3.0 5 votes vote down vote up
@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;
	}
}
 
Example #23
Source File: Permissions.java    From YalpStore with GNU General Public License v2.0 5 votes vote down vote up
private void addPermissionWidgets() {
    PermissionsComparator comparator = new PermissionsComparator(activity);
    Set<String> newPermissions = new HashSet<>();
    if (!comparator.isSame(app)) {
        newPermissions.addAll(comparator.getNewPermissions());
    }
    Map<String, PermissionGroupInfo> groups = new HashMap<>();
    Map<String, Set<PermissionInfo>> permissions = new HashMap<>();
    for (String permissionName: app.getPermissions()) {
        PermissionInfo permissionInfo = getPermissionInfo(permissionName);
        if (null == permissionInfo) {
            continue;
        }
        PermissionGroupInfo permissionGroupInfo = getPermissionGroupInfo(permissionInfo);
        groups.put(permissionGroupInfo.name, permissionGroupInfo);
        if (!permissions.containsKey(permissionGroupInfo.name)) {
            permissions.put(permissionGroupInfo.name, new HashSet<PermissionInfo>());
        }
        permissions.get(permissionGroupInfo.name).add(permissionInfo);
    }
    LinearLayout container = activity.findViewById(R.id.permissions_container_widgets);
    container.removeAllViews();
    List<String> permissionGroupLabels = new ArrayList<>(groups.keySet());
    Collections.sort(permissionGroupLabels);
    for (String permissionGroupLabel: permissionGroupLabels) {
        PermissionGroupInfo groupInfo = groups.get(permissionGroupLabel);
        PermissionGroup widget = new PermissionGroup(activity);
        widget.setPermissionGroupInfo(groupInfo);
        widget.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        widget.setNewPermissions(newPermissions);
        widget.setPermissions(permissions.get(groupInfo.name));
        container.addView(widget);
    }
    activity.findViewById(R.id.permissions_none).setVisibility(permissionGroupLabels.isEmpty() ? View.VISIBLE : View.GONE);
}
 
Example #24
Source File: PermissionGroup.java    From YalpStore with GNU General Public License v2.0 5 votes vote down vote up
private Drawable getPermissionGroupIcon(PermissionGroupInfo permissionGroupInfo) {
    try {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
            ? getContext().getResources().getDrawable(permissionGroupInfo.icon, getContext().getTheme())
            : getContext().getResources().getDrawable(permissionGroupInfo.icon)
        ;
    } catch (Resources.NotFoundException e) {
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
            ? permissionGroupInfo.loadUnbadgedIcon(pm)
            : permissionGroupInfo.loadIcon(pm)
        ;
    }
}
 
Example #25
Source File: PermissionCheck.java    From libcommon with Apache License 2.0 5 votes vote down vote up
public static final void dumpPermissions(@Nullable final Context context) {
   	if (context == null) return;
	try {
		final PackageManager pm = context.getPackageManager();
		final List<PermissionGroupInfo> list = pm.getAllPermissionGroups(PackageManager.GET_META_DATA);
		for (final PermissionGroupInfo info : list) {
			Log.d("PermissionCheck", info.name);
		}
	} catch (final Exception e) {
		Log.w("", e);
	}
}
 
Example #26
Source File: PermissionsActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public static ArrayList<ApkPermission> permissions(Context context, ArrayList<String> permissionArray) {
    PackageManager pm = context.getPackageManager();

    CharSequence csPermissionGroupLabel;
    CharSequence csPermissionLabel;
    List<PermissionGroupInfo> lstGroups = pm.getAllPermissionGroups(0);
    ArrayList<ApkPermission> list = new ArrayList<>();

    if (permissionArray != null) {
        for (int i = 0; i != permissionArray.size(); i++) {
            String permission = permissionArray.get(i);

            for (PermissionGroupInfo pgi : lstGroups) {
                try {
                    List<PermissionInfo> lstPermissions = pm.queryPermissionsByGroup(pgi.name, 0);
                    for (PermissionInfo pi : lstPermissions) {
                        if (pi.name.equals(permission)) {
                            csPermissionLabel = pi.loadLabel(pm);
                            csPermissionGroupLabel = pgi.loadLabel(pm);
                            list.add(new ApkPermission(csPermissionGroupLabel.toString(), csPermissionLabel.toString()));
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
        Collections.sort(list, new Comparator<ApkPermission>() {
            @Override
            public int compare(ApkPermission lhs, ApkPermission rhs) {
                return lhs.getName().compareTo(rhs.getName());
            }
        });
    }

    return list;
}
 
Example #27
Source File: PermissionManager.java    From QuickDevFramework with Apache License 2.0 5 votes vote down vote up
/**
 * 获取权限所属权限组的名称
 * <p>在需要显示某个权限所属的一组权限的名称时使用</p>
 */
public static String getPermissionGroupName(Context context, String permission) {
    PackageManager packageManager = context.getPackageManager();
    try {
        PermissionInfo permissionInfo = packageManager.getPermissionInfo(permission, 0);
        PermissionGroupInfo permissionGroupInfo = packageManager.getPermissionGroupInfo(permissionInfo.group, 0);
        return permissionGroupInfo.loadDescription(packageManager).toString();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return permission;
}
 
Example #28
Source File: PackageParserApi15.java    From DroidPlugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PermissionGroupInfo generatePermissionGroupInfo(
        Object permissionGroup, int flags) throws Exception {
    /*   public static final PermissionGroupInfo generatePermissionGroupInfo(
        PermissionGroup pg, int flags) */
    return super.generatePermissionGroupInfo(permissionGroup, flags);

}
 
Example #29
Source File: PackageParserApi16.java    From DroidPlugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PermissionGroupInfo generatePermissionGroupInfo(
        Object permissionGroup, int flags) throws Exception {
    /*     public static final PermissionGroupInfo generatePermissionGroupInfo(
        PermissionGroup pg, int flags) */
    return super.generatePermissionGroupInfo(permissionGroup, flags);

}
 
Example #30
Source File: PackageParserApi21.java    From DroidPlugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);

}