获取apk文件的权限信息

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

    public static List<PermissionInfo> getApkPermissions(String apkFile, PackageManager pm){  
      
         if(DEBUG) Log.i(TAG, "PackageUtils.getApkPermissions");  
      
         List<PermissionInfo> permissionInfos = new ArrayList<PermissionInfo>();  
      
         PackageInfo packageInfo =  pm.getPackageArchiveInfo(apkFile, PackageManager.GET_PERMISSIONS);  
      
         String[] permissions = packageInfo.requestedPermissions;  
      
         for(String permName : permissions ){  
      
             try {  
                 PermissionInfo permissionInfo = pm.getPermissionInfo(permName, 0);  
                 permissionInfos.add(permissionInfo);  
      
             } catch (PackageManager.NameNotFoundException e) {  
                 e.printStackTrace();  
             }  
         }  
      
         return permissionInfos;  
     }