code: private boolean checkPermission(String permission) {
          int res = ctx.checkCallingOrSelfPermission(permission);
          return (res == PackageManager.PERMISSION_GRANTED);
      }
docs: Check whether the application has been granted a certain permission.
  
  @param permission Permission as a string
  @return true if permissions is granted