Loading packages/ExternalStorageProvider/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ 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 Loading packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +30 −1 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.provider.DocumentsContract.Document; import android.provider.DocumentsContract.Root; import android.provider.DocumentsProvider; import android.provider.MediaStore; import android.support.provider.DocumentArchiveHelper; import android.text.TextUtils; import android.util.ArrayMap; import android.util.DebugUtils; Loading Loading @@ -93,6 +94,7 @@ public class ExternalStorageProvider extends DocumentsProvider { private StorageManager mStorageManager; private Handler mHandler; private DocumentArchiveHelper mArchiveHelper; private final Object mRootsLock = new Object(); Loading @@ -106,6 +108,7 @@ 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; Loading Loading @@ -321,8 +324,12 @@ public class ExternalStorageProvider extends DocumentsProvider { } } final String displayName = file.getName(); 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; } Loading @@ -333,6 +340,7 @@ 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(); Loading Loading @@ -361,6 +369,10 @@ public class ExternalStorageProvider extends DocumentsProvider { @Override public boolean isChildDocument(String parentDocId, String docId) { try { if (mArchiveHelper.isArchivedDocument(docId)) { return mArchiveHelper.isChildDocument(parentDocId, docId); } final File parent = getFileForDocId(parentDocId).getCanonicalFile(); final File doc = getFileForDocId(docId).getCanonicalFile(); return FileUtils.contains(parent, doc); Loading Loading @@ -468,6 +480,10 @@ 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; Loading @@ -477,6 +493,11 @@ 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); Loading Loading @@ -514,6 +535,10 @@ 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); } Loading @@ -522,6 +547,10 @@ 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); Loading Loading
packages/ExternalStorageProvider/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ 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 Loading
packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +30 −1 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.provider.DocumentsContract.Document; import android.provider.DocumentsContract.Root; import android.provider.DocumentsProvider; import android.provider.MediaStore; import android.support.provider.DocumentArchiveHelper; import android.text.TextUtils; import android.util.ArrayMap; import android.util.DebugUtils; Loading Loading @@ -93,6 +94,7 @@ public class ExternalStorageProvider extends DocumentsProvider { private StorageManager mStorageManager; private Handler mHandler; private DocumentArchiveHelper mArchiveHelper; private final Object mRootsLock = new Object(); Loading @@ -106,6 +108,7 @@ 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; Loading Loading @@ -321,8 +324,12 @@ public class ExternalStorageProvider extends DocumentsProvider { } } final String displayName = file.getName(); 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; } Loading @@ -333,6 +340,7 @@ 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(); Loading Loading @@ -361,6 +369,10 @@ public class ExternalStorageProvider extends DocumentsProvider { @Override public boolean isChildDocument(String parentDocId, String docId) { try { if (mArchiveHelper.isArchivedDocument(docId)) { return mArchiveHelper.isChildDocument(parentDocId, docId); } final File parent = getFileForDocId(parentDocId).getCanonicalFile(); final File doc = getFileForDocId(docId).getCanonicalFile(); return FileUtils.contains(parent, doc); Loading Loading @@ -468,6 +480,10 @@ 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; Loading @@ -477,6 +493,11 @@ 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); Loading Loading @@ -514,6 +535,10 @@ 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); } Loading @@ -522,6 +547,10 @@ 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); Loading