Permissive { public static String[] filterPermissions(Context context, String[] permissions, int filter) { final ArrayList<String> filtered = new ArrayList<>(); for (String permission : permissions) { if (checkPermissionInt(context, permission) == filter) { filtered.add(permission); } } return filtered.toArray(new String[filtered.size()]); } private  Permissive(); static void registerGlobalRationale(String permission, Rationale rationale); static boolean checkPermission(Context context, String permission); static String[] filterPermissions(Context context, String[] permissions, int filter); static boolean hasPendingActions(); static final String PERMISSIVE_FRAGMENT_TAG; }
@Test public void testPermissionsFiltering() { String[] result = Permissive.filterPermissions(mockContext, new String[]{TEST_DENIED_PERMISSION, TEST_GRANTED_PERMISSION}, PackageManager.PERMISSION_GRANTED); assertArrayEquals(result, new String[]{TEST_GRANTED_PERMISSION}); result = Permissive.filterPermissions(mockContext, new String[]{TEST_DENIED_PERMISSION, TEST_GRANTED_PERMISSION}, PackageManager.PERMISSION_DENIED); assertArrayEquals(result, new String[]{TEST_DENIED_PERMISSION}); }