Created
December 25, 2012 15:47
-
-
Save nxax/4373797 to your computer and use it in GitHub Desktop.
Androidアプリケーションのパーミッション改竄を検知するスニペット
http://visible-true.blogspot.com/2011/12/android.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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