diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-11-06 09:16:22 -0800 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2015-11-09 17:00:56 -0800 |
commit | 49eddaad7cb5a6e83943064d27d5cf9f86f0fcf1 (patch) | |
tree | 004f10ce5fb32e5f6a7d536a06cad0b0342c8675 | |
parent | 14083582a3fd306ce28ab2be46d61cd4d299b01c (diff) | |
download | frameworks_base-49eddaad7cb5a6e83943064d27d5cf9f86f0fcf1.zip frameworks_base-49eddaad7cb5a6e83943064d27d5cf9f86f0fcf1.tar.gz frameworks_base-49eddaad7cb5a6e83943064d27d5cf9f86f0fcf1.tar.bz2 |
Block directory selection in openable modes.
When picking documents to return to apps requesting CATEGORY_OPENABLE
we can't let the user select directories.
Bug: 25455200
Change-Id: I8076883ee5b019eab4d2adb841952865f21e413e
-rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index 006f6e9..0d326ec 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -19,7 +19,10 @@ package com.android.documentsui; import static com.android.documentsui.BaseActivity.State.ACTION_BROWSE; import static com.android.documentsui.BaseActivity.State.ACTION_BROWSE_ALL; import static com.android.documentsui.BaseActivity.State.ACTION_CREATE; +import static com.android.documentsui.BaseActivity.State.ACTION_GET_CONTENT; import static com.android.documentsui.BaseActivity.State.ACTION_MANAGE; +import static com.android.documentsui.BaseActivity.State.ACTION_OPEN; +import static com.android.documentsui.BaseActivity.State.ACTION_OPEN_TREE; import static com.android.documentsui.BaseActivity.State.MODE_GRID; import static com.android.documentsui.BaseActivity.State.MODE_LIST; import static com.android.documentsui.BaseActivity.State.MODE_UNKNOWN; @@ -578,11 +581,23 @@ public class DirectoryFragment extends Fragment { // Directories and footer items cannot be checked boolean valid = false; + final State state = getDisplayState(DirectoryFragment.this); final Cursor cursor = mAdapter.getItem(position); if (cursor != null) { final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE); final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS); - valid = isDocumentEnabled(docMimeType, docFlags); + switch (state.action) { + case ACTION_OPEN: + case ACTION_CREATE: + case ACTION_GET_CONTENT: + case ACTION_OPEN_TREE: + valid = isDocumentEnabled(docMimeType, docFlags) + && !Document.MIME_TYPE_DIR.equals(docMimeType); + break; + default: + valid = isDocumentEnabled(docMimeType, docFlags); + break; + } } if (!valid) { |