Loading src/com/android/documentsui/CopyService.java +3 −10 Original line number Diff line number Diff line Loading @@ -502,11 +502,6 @@ public class CopyService extends IntentService { // If the file is virtual, but can be converted to another format, then try to copy it // as such format. Also, append an extension for the target mime type (if known). if (srcInfo.isVirtualDocument()) { if (!srcInfo.isTypedDocument()) { // Impossible to copy a file which is virtual, but not typed. mFailedFiles.add(srcInfo); return false; } final String[] streamTypes = getContentResolver().getStreamTypes( srcInfo.derivedUri, "*/*"); if (streamTypes != null && streamTypes.length > 0) { Loading @@ -516,8 +511,7 @@ public class CopyService extends IntentService { dstDisplayName = srcInfo.displayName + (extension != null ? "." + extension : srcInfo.displayName); } else { // The provider says that it supports typed documents, but doesn't say // anything about available formats. // The virtual file is not available as any alternative streamable format. // TODO: Log failures. b/26192412 mFailedFiles.add(srcInfo); return false; Loading Loading @@ -640,9 +634,8 @@ public class CopyService extends IntentService { boolean success = true; try { // If the file is virtual, but can be converted to another format, then try to copy it // as such format. if (srcInfo.isVirtualDocument() && srcInfo.isTypedDocument()) { // If the file is virtual, then try to copy it as an alternative format. if (srcInfo.isVirtualDocument()) { final AssetFileDescriptor srcFileAsAsset = mSrcClient.openTypedAssetFileDescriptor( srcInfo.derivedUri, mimeType, null, canceller); Loading src/com/android/documentsui/model/DocumentInfo.java +0 −4 Original line number Diff line number Diff line Loading @@ -255,10 +255,6 @@ public class DocumentInfo implements Durable, Parcelable { return (flags & Document.FLAG_VIRTUAL_DOCUMENT) != 0; } public boolean isTypedDocument() { return (flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) != 0; } public int hashCode() { return derivedUri.hashCode() + mimeType.hashCode(); } Loading tests/src/com/android/documentsui/CopyServiceTest.java +1 −3 Original line number Diff line number Diff line Loading @@ -311,10 +311,8 @@ public class CopyServiceTest extends ServiceTestCase<CopyService> { public void testCopyVirtualNonTypedFile() throws Exception { String srcPath = "/non-typed.sth"; // Empty stream types causes the FLAG_SUPPORTS_TYPED_DOCUMENT to be not set. ArrayList<String> streamTypes = new ArrayList<>(); Uri testFile = mStorage.createVirtualFile(SRC_ROOT, srcPath, "virtual/mime-type", streamTypes, "I love Tokyo!".getBytes()); null /* streamTypes */, "I love Tokyo!".getBytes()); Intent intent = createCopyIntent(Lists.newArrayList(testFile)); startService(intent); Loading tests/src/com/android/documentsui/StubProvider.java +4 −10 Original line number Diff line number Diff line Loading @@ -316,12 +316,9 @@ public class StubProvider extends DocumentsProvider { String documentId, String mimeTypeFilter, Bundle opts, CancellationSignal signal) throws FileNotFoundException { final StubDocument document = mStorage.get(documentId); if (document == null || !document.file.isFile()) { if (document == null || !document.file.isFile() || document.streamTypes == null) { throw new FileNotFoundException(); } if ((document.flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) == 0) { throw new IllegalStateException("Tried to open a non-typed document as typed."); } for (final String mimeType : document.streamTypes) { // Strict compare won't accept wildcards, but that's OK for tests, as DocumentsUI // doesn't use them for getStreamTypes nor openTypedDocument. Loading Loading @@ -349,13 +346,13 @@ public class StubProvider extends DocumentsProvider { throw new IllegalArgumentException( "The provided Uri is incorrect, or the file is gone."); } if ((document.flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) == 0) { return null; } if (!"*/*".equals(mimeTypeFilter)) { // Not used by DocumentsUI, so don't bother implementing it. throw new UnsupportedOperationException(); } if (document.streamTypes == null) { return null; } return document.streamTypes.toArray(new String[document.streamTypes.size()]); } Loading Loading @@ -628,9 +625,6 @@ public class StubProvider extends DocumentsProvider { File file, String mimeType, List<String> streamTypes, StubDocument parent) { int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE | Document.FLAG_VIRTUAL_DOCUMENT; if (streamTypes.size() > 0) { flags |= Document.FLAG_SUPPORTS_TYPED_DOCUMENT; } return new StubDocument(file, mimeType, streamTypes, flags, parent); } Loading Loading
src/com/android/documentsui/CopyService.java +3 −10 Original line number Diff line number Diff line Loading @@ -502,11 +502,6 @@ public class CopyService extends IntentService { // If the file is virtual, but can be converted to another format, then try to copy it // as such format. Also, append an extension for the target mime type (if known). if (srcInfo.isVirtualDocument()) { if (!srcInfo.isTypedDocument()) { // Impossible to copy a file which is virtual, but not typed. mFailedFiles.add(srcInfo); return false; } final String[] streamTypes = getContentResolver().getStreamTypes( srcInfo.derivedUri, "*/*"); if (streamTypes != null && streamTypes.length > 0) { Loading @@ -516,8 +511,7 @@ public class CopyService extends IntentService { dstDisplayName = srcInfo.displayName + (extension != null ? "." + extension : srcInfo.displayName); } else { // The provider says that it supports typed documents, but doesn't say // anything about available formats. // The virtual file is not available as any alternative streamable format. // TODO: Log failures. b/26192412 mFailedFiles.add(srcInfo); return false; Loading Loading @@ -640,9 +634,8 @@ public class CopyService extends IntentService { boolean success = true; try { // If the file is virtual, but can be converted to another format, then try to copy it // as such format. if (srcInfo.isVirtualDocument() && srcInfo.isTypedDocument()) { // If the file is virtual, then try to copy it as an alternative format. if (srcInfo.isVirtualDocument()) { final AssetFileDescriptor srcFileAsAsset = mSrcClient.openTypedAssetFileDescriptor( srcInfo.derivedUri, mimeType, null, canceller); Loading
src/com/android/documentsui/model/DocumentInfo.java +0 −4 Original line number Diff line number Diff line Loading @@ -255,10 +255,6 @@ public class DocumentInfo implements Durable, Parcelable { return (flags & Document.FLAG_VIRTUAL_DOCUMENT) != 0; } public boolean isTypedDocument() { return (flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) != 0; } public int hashCode() { return derivedUri.hashCode() + mimeType.hashCode(); } Loading
tests/src/com/android/documentsui/CopyServiceTest.java +1 −3 Original line number Diff line number Diff line Loading @@ -311,10 +311,8 @@ public class CopyServiceTest extends ServiceTestCase<CopyService> { public void testCopyVirtualNonTypedFile() throws Exception { String srcPath = "/non-typed.sth"; // Empty stream types causes the FLAG_SUPPORTS_TYPED_DOCUMENT to be not set. ArrayList<String> streamTypes = new ArrayList<>(); Uri testFile = mStorage.createVirtualFile(SRC_ROOT, srcPath, "virtual/mime-type", streamTypes, "I love Tokyo!".getBytes()); null /* streamTypes */, "I love Tokyo!".getBytes()); Intent intent = createCopyIntent(Lists.newArrayList(testFile)); startService(intent); Loading
tests/src/com/android/documentsui/StubProvider.java +4 −10 Original line number Diff line number Diff line Loading @@ -316,12 +316,9 @@ public class StubProvider extends DocumentsProvider { String documentId, String mimeTypeFilter, Bundle opts, CancellationSignal signal) throws FileNotFoundException { final StubDocument document = mStorage.get(documentId); if (document == null || !document.file.isFile()) { if (document == null || !document.file.isFile() || document.streamTypes == null) { throw new FileNotFoundException(); } if ((document.flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) == 0) { throw new IllegalStateException("Tried to open a non-typed document as typed."); } for (final String mimeType : document.streamTypes) { // Strict compare won't accept wildcards, but that's OK for tests, as DocumentsUI // doesn't use them for getStreamTypes nor openTypedDocument. Loading Loading @@ -349,13 +346,13 @@ public class StubProvider extends DocumentsProvider { throw new IllegalArgumentException( "The provided Uri is incorrect, or the file is gone."); } if ((document.flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) == 0) { return null; } if (!"*/*".equals(mimeTypeFilter)) { // Not used by DocumentsUI, so don't bother implementing it. throw new UnsupportedOperationException(); } if (document.streamTypes == null) { return null; } return document.streamTypes.toArray(new String[document.streamTypes.size()]); } Loading Loading @@ -628,9 +625,6 @@ public class StubProvider extends DocumentsProvider { File file, String mimeType, List<String> streamTypes, StubDocument parent) { int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE | Document.FLAG_VIRTUAL_DOCUMENT; if (streamTypes.size() > 0) { flags |= Document.FLAG_SUPPORTS_TYPED_DOCUMENT; } return new StubDocument(file, mimeType, streamTypes, flags, parent); } Loading