summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZemiao Zhu <zemiao@google.com>2020-06-27 00:28:00 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-27 00:28:00 +0000
commit68e7535895d42ee227258751be68f38323707075 (patch)
tree3cc9d1aad6ce0379acdb2612b2f94ce355432af1
parent932f32d2c36da32d23c86f7ef6637fe3d98cd3b7 (diff)
parentf4f1e72435bd331b5ab3e5db5487b5023e5f3479 (diff)
downloadDocumentsUI-68e7535895d42ee227258751be68f38323707075.tar.gz
Fix cannot open archive file from external storage. am: f4f1e72435
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/DocumentsUI/+/12010470 Change-Id: Ie99a347715572789f6a179d1dcfc431a77b7fa10
-rw-r--r--src/com/android/documentsui/ActivityConfig.java5
-rw-r--r--src/com/android/documentsui/archives/ArchivesProvider.java22
2 files changed, 18 insertions, 9 deletions
diff --git a/src/com/android/documentsui/ActivityConfig.java b/src/com/android/documentsui/ActivityConfig.java
index 6b0fa23f2..d176ceb91 100644
--- a/src/com/android/documentsui/ActivityConfig.java
+++ b/src/com/android/documentsui/ActivityConfig.java
@@ -37,8 +37,9 @@ public abstract class ActivityConfig {
}
/**
- * When managed mode is enabled, active downloads will be visible in the UI.
- * Presumably this should only be true when in the downloads directory.
+ * When managed mode is enabled, there will be special UI behaviors:
+ * 1) active downloads will be visible in the UI.
+ * 2) Android/[data|obb|sandbox] directories will not be hidden.
*/
public boolean managedModeEnabled(DocumentStack stack) {
return false;
diff --git a/src/com/android/documentsui/archives/ArchivesProvider.java b/src/com/android/documentsui/archives/ArchivesProvider.java
index 826f4c593..3406cd708 100644
--- a/src/com/android/documentsui/archives/ArchivesProvider.java
+++ b/src/com/android/documentsui/archives/ArchivesProvider.java
@@ -25,18 +25,18 @@ import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.os.CancellationSignal;
+import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
-import androidx.annotation.Nullable;
import android.util.Log;
-import com.android.documentsui.R;
import androidx.annotation.GuardedBy;
+import androidx.annotation.Nullable;
-import android.os.FileUtils;
+import com.android.documentsui.R;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -56,9 +56,9 @@ import java.util.Set;
public class ArchivesProvider extends DocumentsProvider {
public static final String AUTHORITY = "com.android.documentsui.archives";
- private static final String[] DEFAULT_ROOTS_PROJECTION = new String[] {
+ private static final String[] DEFAULT_ROOTS_PROJECTION = new String[]{
Root.COLUMN_ROOT_ID, Root.COLUMN_DOCUMENT_ID, Root.COLUMN_TITLE, Root.COLUMN_FLAGS,
- Root.COLUMN_ICON };
+ Root.COLUMN_ICON};
private static final String TAG = "ArchivesProvider";
private static final String METHOD_ACQUIRE_ARCHIVE = "acquireArchive";
private static final String METHOD_RELEASE_ARCHIVE = "releaseArchive";
@@ -129,6 +129,14 @@ public class ArchivesProvider extends DocumentsProvider {
return cursor;
}
+ /** Overrides a hidden API. */
+ public Cursor queryChildDocumentsForManage(String parentDocumentId,
+ @Nullable String[] projection, @Nullable String sortOrder)
+ throws FileNotFoundException {
+ // No special handling of Archives in managed mode.
+ return queryChildDocuments(parentDocumentId, projection, sortOrder);
+ }
+
@Override
public String getDocumentType(String documentId) throws FileNotFoundException {
final ArchiveId archiveId = ArchiveId.fromDocumentId(documentId);
@@ -179,7 +187,7 @@ public class ArchivesProvider extends DocumentsProvider {
if (archiveId.mPath.equals("/")) {
try (final Cursor archiveCursor = getContext().getContentResolver().query(
archiveId.mArchiveUri,
- new String[] { Document.COLUMN_DISPLAY_NAME },
+ new String[]{Document.COLUMN_DISPLAY_NAME},
null, null, null, null)) {
if (archiveCursor == null || !archiveCursor.moveToFirst()) {
throw new FileNotFoundException(
@@ -349,7 +357,7 @@ public class ArchivesProvider extends DocumentsProvider {
return false;
}
return archiveUri.equals(((Key) other).archiveUri) &&
- accessMode == ((Key) other).accessMode;
+ accessMode == ((Key) other).accessMode;
}
@Override