@Test @RequiresApi(19) public void testMmapNullPfd() { if (Build.VERSION.SDK_INT < 19) { return; } final Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT) .authority(MockFontProvider.AUTHORITY).build(); final Uri fileUri = ContentUris.withAppendedId(uri, MockFontProvider.INVALID_FONT_FILE_ID); TypefaceCompatUtil.mmap(mContext, null, fileUri); }
@Nullable @RequiresApi(19) private static ByteBuffer mmap(File file) { try (FileInputStream fis = new FileInputStream(file)) { FileChannel channel = fis.getChannel(); final long size = channel.size(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, size); } catch (IOException e) { return null; } }
TypefaceCompatUtil { @Nullable @RequiresApi(19) private static ByteBuffer mmap(File file) { try (FileInputStream fis = new FileInputStream(file)) { FileChannel channel = fis.getChannel(); final long size = channel.size(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, size); } catch (IOException e) { return null; } } }
TypefaceCompatUtil { @Nullable @RequiresApi(19) private static ByteBuffer mmap(File file) { try (FileInputStream fis = new FileInputStream(file)) { FileChannel channel = fis.getChannel(); final long size = channel.size(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, size); } catch (IOException e) { return null; } } private  TypefaceCompatUtil(); }
TypefaceCompatUtil { @Nullable @RequiresApi(19) private static ByteBuffer mmap(File file) { try (FileInputStream fis = new FileInputStream(file)) { FileChannel channel = fis.getChannel(); final long size = channel.size(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, size); } catch (IOException e) { return null; } } private  TypefaceCompatUtil(); @Nullable static File getTempFile(Context context); @Nullable @RequiresApi(19) static ByteBuffer mmap(Context context, CancellationSignal cancellationSignal, Uri uri); @Nullable @RequiresApi(19) static ByteBuffer copyToDirectBuffer(Context context, Resources res, int id); static boolean copyToFile(File file, InputStream is); static boolean copyToFile(File file, Resources res, int id); static void closeQuietly(Closeable c); }
TypefaceCompatUtil { @Nullable @RequiresApi(19) private static ByteBuffer mmap(File file) { try (FileInputStream fis = new FileInputStream(file)) { FileChannel channel = fis.getChannel(); final long size = channel.size(); return channel.map(FileChannel.MapMode.READ_ONLY, 0, size); } catch (IOException e) { return null; } } private  TypefaceCompatUtil(); @Nullable static File getTempFile(Context context); @Nullable @RequiresApi(19) static ByteBuffer mmap(Context context, CancellationSignal cancellationSignal, Uri uri); @Nullable @RequiresApi(19) static ByteBuffer copyToDirectBuffer(Context context, Resources res, int id); static boolean copyToFile(File file, InputStream is); static boolean copyToFile(File file, Resources res, int id); static void closeQuietly(Closeable c);  }