Loading packages/DocumentsUI/src/com/android/documentsui/CopyService.java +20 −2 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.app.PendingIntent; import android.content.ContentProviderClient; import android.content.ContentProviderClient; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.content.res.Resources; import android.content.res.Resources; import android.database.Cursor; import android.database.Cursor; import android.net.Uri; import android.net.Uri; Loading Loading @@ -592,9 +593,26 @@ public class CopyService extends IntentService { IOException copyError = null; IOException copyError = null; try { 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()) { final String[] streamTypes = mSrcClient.getStreamTypes(srcInfo.derivedUri, "*/*"); if (streamTypes.length > 0) { // Pick the first streamable format. final AssetFileDescriptor srcFileAsAsset = mSrcClient.openTypedAssetFileDescriptor( srcInfo.derivedUri, streamTypes[0], null, canceller); srcFile = srcFileAsAsset.getParcelFileDescriptor(); src = new AssetFileDescriptor.AutoCloseInputStream(srcFileAsAsset); } else { // TODO: Log failures. b/26192412 mFailedFiles.add(srcInfo); } } else { srcFile = mSrcClient.openFile(srcInfo.derivedUri, "r", canceller); srcFile = mSrcClient.openFile(srcInfo.derivedUri, "r", canceller); dstFile = mDstClient.openFile(dstInfo.derivedUri, "w", canceller); src = new ParcelFileDescriptor.AutoCloseInputStream(srcFile); src = new ParcelFileDescriptor.AutoCloseInputStream(srcFile); } dstFile = mDstClient.openFile(dstInfo.derivedUri, "w", canceller); dst = new ParcelFileDescriptor.AutoCloseOutputStream(dstFile); dst = new ParcelFileDescriptor.AutoCloseOutputStream(dstFile); byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192]; Loading packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -251,6 +251,14 @@ public class DocumentInfo implements Durable, Parcelable { return isDirectory() || isArchive(); return isDirectory() || isArchive(); } } public boolean isVirtualDocument() { return (flags & Document.FLAG_VIRTUAL_DOCUMENT) != 0; } public boolean isTypedDocument() { return (flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) != 0; } public int hashCode() { public int hashCode() { return derivedUri.hashCode() + mimeType.hashCode(); return derivedUri.hashCode() + mimeType.hashCode(); } } Loading Loading
packages/DocumentsUI/src/com/android/documentsui/CopyService.java +20 −2 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.app.PendingIntent; import android.content.ContentProviderClient; import android.content.ContentProviderClient; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.content.res.Resources; import android.content.res.Resources; import android.database.Cursor; import android.database.Cursor; import android.net.Uri; import android.net.Uri; Loading Loading @@ -592,9 +593,26 @@ public class CopyService extends IntentService { IOException copyError = null; IOException copyError = null; try { 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()) { final String[] streamTypes = mSrcClient.getStreamTypes(srcInfo.derivedUri, "*/*"); if (streamTypes.length > 0) { // Pick the first streamable format. final AssetFileDescriptor srcFileAsAsset = mSrcClient.openTypedAssetFileDescriptor( srcInfo.derivedUri, streamTypes[0], null, canceller); srcFile = srcFileAsAsset.getParcelFileDescriptor(); src = new AssetFileDescriptor.AutoCloseInputStream(srcFileAsAsset); } else { // TODO: Log failures. b/26192412 mFailedFiles.add(srcInfo); } } else { srcFile = mSrcClient.openFile(srcInfo.derivedUri, "r", canceller); srcFile = mSrcClient.openFile(srcInfo.derivedUri, "r", canceller); dstFile = mDstClient.openFile(dstInfo.derivedUri, "w", canceller); src = new ParcelFileDescriptor.AutoCloseInputStream(srcFile); src = new ParcelFileDescriptor.AutoCloseInputStream(srcFile); } dstFile = mDstClient.openFile(dstInfo.derivedUri, "w", canceller); dst = new ParcelFileDescriptor.AutoCloseOutputStream(dstFile); dst = new ParcelFileDescriptor.AutoCloseOutputStream(dstFile); byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192]; Loading
packages/DocumentsUI/src/com/android/documentsui/model/DocumentInfo.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -251,6 +251,14 @@ public class DocumentInfo implements Durable, Parcelable { return isDirectory() || isArchive(); return isDirectory() || isArchive(); } } public boolean isVirtualDocument() { return (flags & Document.FLAG_VIRTUAL_DOCUMENT) != 0; } public boolean isTypedDocument() { return (flags & Document.FLAG_SUPPORTS_TYPED_DOCUMENT) != 0; } public int hashCode() { public int hashCode() { return derivedUri.hashCode() + mimeType.hashCode(); return derivedUri.hashCode() + mimeType.hashCode(); } } Loading