Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d25cf29e authored by Tomasz Mikolajewski's avatar Tomasz Mikolajewski Committed by Android (Google) Code Review
Browse files

Merge "Remove support for archives from External and Bugreport providers."

parents ca58352b 219fa882
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_STATIC_JAVA_LIBRARIES := android-support-documents-archive
LOCAL_PACKAGE_NAME := ExternalStorageProvider
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
+0 −37
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
import android.provider.MediaStore;
import android.provider.Settings;
import android.support.provider.DocumentArchiveHelper;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.DebugUtils;
@@ -101,7 +100,6 @@ public class ExternalStorageProvider extends DocumentsProvider {

    private StorageManager mStorageManager;
    private Handler mHandler;
    private DocumentArchiveHelper mArchiveHelper;

    private final Object mRootsLock = new Object();

@@ -115,7 +113,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
    public boolean onCreate() {
        mStorageManager = (StorageManager) getContext().getSystemService(Context.STORAGE_SERVICE);
        mHandler = new Handler();
        mArchiveHelper = new DocumentArchiveHelper(this, (char) 0);

        updateVolumes();
        return true;
@@ -377,10 +374,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
        }

        final String mimeType = getTypeForFile(file);
        if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
            flags |= Document.FLAG_ARCHIVE;
        }

        final String displayName = file.getName();
        if (mimeType.startsWith("image/")) {
            flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
@@ -392,7 +385,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
        row.add(Document.COLUMN_SIZE, file.length());
        row.add(Document.COLUMN_MIME_TYPE, mimeType);
        row.add(Document.COLUMN_FLAGS, flags);
        row.add(DocumentArchiveHelper.COLUMN_LOCAL_FILE_PATH, file.getPath());

        // Only publish dates reasonably after epoch
        long lastModified = file.lastModified();
@@ -421,14 +413,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
    @Override
    public boolean isChildDocument(String parentDocId, String docId) {
        try {
            if (mArchiveHelper.isArchivedDocument(docId)) {
                return mArchiveHelper.isChildDocument(parentDocId, docId);
            }
            // Archives do not contain regular files.
            if (mArchiveHelper.isArchivedDocument(parentDocId)) {
                return false;
            }

            final File parent = getFileForDocId(parentDocId).getCanonicalFile();
            final File doc = getFileForDocId(docId).getCanonicalFile();
            return FileUtils.contains(parent, doc);
@@ -538,10 +522,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
    @Override
    public Cursor queryDocument(String documentId, String[] projection)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(documentId)) {
            return mArchiveHelper.queryDocument(documentId, projection);
        }

        final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
        includeFile(result, documentId, null);
        return result;
@@ -551,11 +531,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
    public Cursor queryChildDocuments(
            String parentDocumentId, String[] projection, String sortOrder)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(parentDocumentId) ||
                mArchiveHelper.isSupportedArchiveType(getDocumentType(parentDocumentId))) {
            return mArchiveHelper.queryChildDocuments(parentDocumentId, projection, sortOrder);
        }

        final File parent = getFileForDocId(parentDocumentId);
        final MatrixCursor result = new DirectoryCursor(
                resolveDocumentProjection(projection), parentDocumentId, parent);
@@ -612,10 +587,6 @@ public class ExternalStorageProvider extends DocumentsProvider {

    @Override
    public String getDocumentType(String documentId) throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(documentId)) {
            return mArchiveHelper.getDocumentType(documentId);
        }

        final File file = getFileForDocId(documentId);
        return getTypeForFile(file);
    }
@@ -624,10 +595,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
    public ParcelFileDescriptor openDocument(
            String documentId, String mode, CancellationSignal signal)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(documentId)) {
            return mArchiveHelper.openDocument(documentId, mode, signal);
        }

        final File file = getFileForDocId(documentId);
        final File visibleFile = getFileForDocId(documentId, true);

@@ -656,10 +623,6 @@ public class ExternalStorageProvider extends DocumentsProvider {
    public AssetFileDescriptor openDocumentThumbnail(
            String documentId, Point sizeHint, CancellationSignal signal)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(documentId)) {
            return mArchiveHelper.openDocumentThumbnail(documentId, sizeHint, signal);
        }

        final File file = getFileForDocId(documentId);
        return DocumentsContract.openImageThumbnail(file);
    }
+1 −2
Original line number Diff line number Diff line
@@ -5,8 +5,7 @@ LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 \
        android-support-documents-archive
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4

LOCAL_PACKAGE_NAME := Shell
LOCAL_CERTIFICATE := platform
+0 −20
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
import android.support.provider.DocumentArchiveHelper;
import android.webkit.MimeTypeMap;

import java.io.File;
@@ -48,12 +47,10 @@ public class BugreportStorageProvider extends DocumentsProvider {
    };

    private File mRoot;
    private DocumentArchiveHelper mArchiveHelper;

    @Override
    public boolean onCreate() {
        mRoot = new File(getContext().getFilesDir(), "bugreports");
        mArchiveHelper = new DocumentArchiveHelper(this, (char) 0);
        return true;
    }

@@ -72,10 +69,6 @@ public class BugreportStorageProvider extends DocumentsProvider {
    @Override
    public Cursor queryDocument(String documentId, String[] projection)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(documentId)) {
            return mArchiveHelper.queryDocument(documentId, projection);
        }

        final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
        if (DOC_ID_ROOT.equals(documentId)) {
            final RowBuilder row = result.newRow();
@@ -94,11 +87,6 @@ public class BugreportStorageProvider extends DocumentsProvider {
    public Cursor queryChildDocuments(
            String parentDocumentId, String[] projection, String sortOrder)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(parentDocumentId) ||
                mArchiveHelper.isSupportedArchiveType(getDocumentType(parentDocumentId))) {
            return mArchiveHelper.queryChildDocuments(parentDocumentId, projection, sortOrder);
        }

        final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
        if (DOC_ID_ROOT.equals(parentDocumentId)) {
            final File[] files = mRoot.listFiles();
@@ -116,10 +104,6 @@ public class BugreportStorageProvider extends DocumentsProvider {
    public ParcelFileDescriptor openDocument(
            String documentId, String mode, CancellationSignal signal)
            throws FileNotFoundException {
        if (mArchiveHelper.isArchivedDocument(documentId)) {
            return mArchiveHelper.openDocument(documentId, mode, signal);
        }

        if (ParcelFileDescriptor.parseMode(mode) != ParcelFileDescriptor.MODE_READ_ONLY) {
            throw new FileNotFoundException("Failed to open: " + documentId + ", mode = " + mode);
        }
@@ -182,10 +166,6 @@ public class BugreportStorageProvider extends DocumentsProvider {
    private void addFileRow(MatrixCursor result, File file) {
        String mimeType = getTypeForName(file.getName());
        int flags = Document.FLAG_SUPPORTS_DELETE;
        if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
            flags |= Document.FLAG_ARCHIVE;
        }

        final RowBuilder row = result.newRow();
        row.add(Document.COLUMN_DOCUMENT_ID, getDocIdForFile(file));
        row.add(Document.COLUMN_MIME_TYPE, mimeType);