From c7ec678d7ca56d1b1a5205ba8552d40222942f50 Mon Sep 17 00:00:00 2001 From: Tomasz Mikolajewski Date: Fri, 18 Dec 2015 11:29:48 +0900 Subject: [PATCH] Cleanup StubProvider a little. Change-Id: I1d9f1c978850f466ff204bff97a152ba7919a096 --- .../com/android/documentsui/StubProvider.java | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java index 63a519f4f2a11..2c311a7cc1928 100644 --- a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java +++ b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java @@ -492,30 +492,6 @@ public class StubProvider extends DocumentsProvider { } } - @VisibleForTesting - public File createFile(String rootId, String path, String mimeType, byte[] content) - throws FileNotFoundException, IOException { - Log.d(TAG, "Creating test file " + rootId + ":" + path); - StubDocument root = mRoots.get(rootId).document; - if (root == null) { - throw new FileNotFoundException("No roots with the ID " + rootId + " were found"); - } - final File file = new File(root.file, path.substring(1)); - if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) { - if (!file.mkdirs()) { - throw new FileNotFoundException("Couldn't create directory " + file.getPath()); - } - } else { - if (!file.createNewFile()) { - throw new FileNotFoundException("Couldn't create file " + file.getPath()); - } - try (final FileOutputStream fout = new FileOutputStream(file)) { - fout.write(content); - } - } - return file; - } - @VisibleForTesting public Uri createRegularFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { @@ -560,6 +536,29 @@ public class StubProvider extends DocumentsProvider { return found.file; } + private File createFile(String rootId, String path, String mimeType, byte[] content) + throws FileNotFoundException, IOException { + Log.d(TAG, "Creating test file " + rootId + ":" + path); + StubDocument root = mRoots.get(rootId).document; + if (root == null) { + throw new FileNotFoundException("No roots with the ID " + rootId + " were found"); + } + final File file = new File(root.file, path.substring(1)); + if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) { + if (!file.mkdirs()) { + throw new FileNotFoundException("Couldn't create directory " + file.getPath()); + } + } else { + if (!file.createNewFile()) { + throw new FileNotFoundException("Couldn't create file " + file.getPath()); + } + try (final FileOutputStream fout = new FileOutputStream(file)) { + fout.write(content); + } + } + return file; + } + final static class RootInfo { public final String name; public final StubDocument document;