android.content.pm.PermissionGroupInfo源码实例Demo

类android.content.pm.PermissionGroupInfo源码实例Demo

下面列出了android.content.pm.PermissionGroupInfo 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: letv   文件: IApkManagerImpl.java
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;
}
 
源代码2 项目: YalpStore   文件: Permissions.java
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;
}
 
源代码3 项目: YalpStore   文件: Permissions.java
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;

}
 
源代码4 项目: DroidPlugin   文件: IPackageManagerHookHandle.java
@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
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);
}
 
@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();
    }
}
 
@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);
}
 
@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();
    }
}
 
@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);
}
 
@Override
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        return mPM.getAllPermissionGroups(flags);
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
@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);
}
 
@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();
    }
}
 
@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);
}
 
@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();
    }
}
 
@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);
}
 
@Override
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        return mPM.getAllPermissionGroups(flags);
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
@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);
}
 
@Override
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        return mPM.getAllPermissionGroups(flags);
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
@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();
    }
}
 
@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);
}
 
@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();
    }
}
 
@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);
}
 
@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();
    }
}
 
private PermissionGroupInfo getPermissionGroupInfo(String groupName, int flags,
        int callingUid) {
    if (mPackageManagerInt.getInstantAppPackageName(callingUid) != null) {
        return null;
    }
    synchronized (mLock) {
        return PackageParser.generatePermissionGroupInfo(
                mSettings.mPermissionGroups.get(groupName), flags);
    }
}
 
private List<PermissionGroupInfo> getAllPermissionGroups(int flags, int callingUid) {
    if (mPackageManagerInt.getInstantAppPackageName(callingUid) != null) {
        return null;
    }
    synchronized (mLock) {
        final int N = mSettings.mPermissionGroups.size();
        final ArrayList<PermissionGroupInfo> out
                = new ArrayList<PermissionGroupInfo>(N);
        for (PackageParser.PermissionGroup pg : mSettings.mPermissionGroups.values()) {
            out.add(PackageParser.generatePermissionGroupInfo(pg, flags));
        }
        return out;
    }
}
 
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;
}
 
@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);
}
 
@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();
    }
}
 
源代码29 项目: Collection-Android   文件: GetPermissionsUtils.java
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();
    }
 
源代码30 项目: letv   文件: IApkManagerImpl.java
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;
    }
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 类方法
 同包方法