private @Nullable EncodedImage getThumbnail(ResizeOptions resizeOptions, long imageId)
      throws IOException {
    int thumbnailKind = getThumbnailKind(resizeOptions);
    if (thumbnailKind == NO_THUMBNAIL) {
      return null;
    }
    @Nullable
    Cursor thumbnailCursor =
        MediaStore.Images.Thumbnails.queryMiniThumbnail(
            mContentResolver, imageId, thumbnailKind, THUMBNAIL_PROJECTION);
    if (thumbnailCursor == null) {
      return null;
    }
    try {
      if (thumbnailCursor.moveToFirst()) {
        final int thumbnailDataColumnIndex =
            thumbnailCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
        if (thumbnailDataColumnIndex >= 0) {
          final String thumbnailUri =
              Preconditions.checkNotNull(thumbnailCursor.getString(thumbnailDataColumnIndex));
          if (FileUtil.exists(thumbnailUri)) {
            return getEncodedImage(new FileInputStream(thumbnailUri), getLength(thumbnailUri));
          }
        }
      }
    } finally {
      thumbnailCursor.close();
    }
    return null;
  }
Wrapper around File operations to enable mocking in tests.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/LocalContentUriThumbnailFetchProducer.java