1 private void per() { 2 StringBuffer appNameAndPermissions = new StringBuffer(); 3 PackageManager pm = getPackageManager(); 4 List<ApplicationInfo> packages = pm 5 .getInstalledApplications(PackageManager.GET_META_DATA); 6 for (ApplicationInfo applicationInfo : packages) { 7 try { 8 PackageInfo packageInfo = pm.getPackageInfo( 9 applicationInfo.packageName, 10 PackageManager.GET_PERMISSIONS); 11 appNameAndPermissions.append(packageInfo.packageName + "*:\n"); 12 // Get Permissions 13 String[] requestedPermissions = packageInfo.requestedPermissions; 14 if (requestedPermissions != null && requestedPermissions.toString().contains("haodf")) { 15 for (int i = 0; i < requestedPermissions.length; i++) { 16 Log.d("test", requestedPermissions[i]); 17 appNameAndPermissions.append(requestedPermissions[i] 18 + "\n"); 19 } 20 appNameAndPermissions.append("\n"); 21 } 22 } catch (NameNotFoundException e) { 23 e.printStackTrace(); 24 } 25 } 26 }
时间: 2024-10-10 18:14:46