diff options
author | Tomasz Mikolajewski <mtomasz@google.com> | 2015-04-08 19:38:55 +0900 |
---|---|---|
committer | Tomasz Mikolajewski <mtomasz@google.com> | 2015-04-08 19:38:55 +0900 |
commit | 78699be5ffc8c59dbbcc6dc019710f739150d5e9 (patch) | |
tree | c41d5c9d8c1b9710587fdad62a519bba3ac95b46 /packages/DocumentsUI | |
parent | 2c696c4cc6c4cc6523d74e32eb78808531dfb41e (diff) | |
download | frameworks_base-78699be5ffc8c59dbbcc6dc019710f739150d5e9.zip frameworks_base-78699be5ffc8c59dbbcc6dc019710f739150d5e9.tar.gz frameworks_base-78699be5ffc8c59dbbcc6dc019710f739150d5e9.tar.bz2 |
Add StubProvider::isChildDocument().
Change-Id: Ib17df4307c1f658c42468f86e1f66d4469eefe58
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r-- | packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java index 08c36de..6044781 100644 --- a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java +++ b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java @@ -23,6 +23,7 @@ import android.database.MatrixCursor.RowBuilder; import android.database.MatrixCursor; import android.graphics.Point; import android.os.CancellationSignal; +import android.os.FileUtils; import android.os.ParcelFileDescriptor; import android.provider.DocumentsContract.Document; import android.provider.DocumentsContract.Root; @@ -66,7 +67,7 @@ public class StubProvider extends DocumentsProvider { final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION); final RowBuilder row = result.newRow(); row.add(Root.COLUMN_ROOT_ID, MY_ROOT_ID); - row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE); + row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_IS_CHILD); row.add(Root.COLUMN_TITLE, "Foobar SD 4GB"); row.add(Root.COLUMN_DOCUMENT_ID, mRootDocumentId); row.add(Root.COLUMN_AVAILABLE_BYTES, STORAGE_SIZE - mStorageUsedBytes); @@ -85,6 +86,17 @@ public class StubProvider extends DocumentsProvider { } @Override + public boolean isChildDocument(String parentDocId, String docId) { + try { + final File parentFile = getFileForDocumentId(parentDocId).getCanonicalFile(); + final File childFile = getFileForDocumentId(docId).getCanonicalFile(); + return FileUtils.contains(parentFile, childFile); + } catch (IOException e) { + throw new IllegalArgumentException(); + } + } + + @Override public String createDocument(String parentDocumentId, String mimeType, String displayName) throws FileNotFoundException { final File parentFile = mStorage.get(parentDocumentId); @@ -170,6 +182,10 @@ public class StubProvider extends DocumentsProvider { return file.getAbsolutePath(); } + private File getFileForDocumentId(String documentId) { + return new File(documentId); + } + private void removeRecursively(File file) { for (File childFile : file.listFiles()) { if (childFile.isDirectory()) { |