Skip to content

Instantly share code, notes, and snippets.

@nxax
Created December 25, 2012 15:47
Show Gist options
  • Save nxax/4373797 to your computer and use it in GitHub Desktop.
Save nxax/4373797 to your computer and use it in GitHub Desktop.
Androidアプリケーションのパーミッション改竄を検知するスニペット http://visible-true.blogspot.com/2011/12/android.html
private static List<String> missingPermissions(Context context, String[] expectations) {
return missingPermissions(context, new ArrayList<String>(Arrays.asList(expectations)));
}
private static List<String> missingPermissions(Context context, List<String> expectations){
if (context == null || expectations == null) {
return null;
}
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS);
String[] info = pi.requestedPermissions;
if (info != null) {
for (String i : info) {
expectations.remove(i);
}
}
return expectations;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment