private boolean isPermissionGranted(String permission) {
        if (permission == null) {
            throw new IllegalArgumentException("permission is null");
        }

        if (grantedPermissions.contains(permission)) {
            return true;
        }

        boolean isGranted = context.checkPermission(permission, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED;

        if (isGranted) {
            grantedPermissions.add(permission);
        }

        return isGranted;
    }
Copied from android.support.v4.content.ContextCompat for backwards compatibility
@param permission the permission to check
@return true is granted
rxandroidble/src/main/java/com/polidea/rxandroidble2/internal/util/CheckerPermission.java