Add new column into Root to get the supported query args
DocumentsContract: - Add @Public column Root#COLUMN_QUERY_ARGS - Update java doc DocumentsProvider: - Update java doc FileSystemProvider & ExternalStorageProvider - Add supported query args into Roots Bug: 121234248 Test: manual Change-Id: Ia944200ee1a44d75c9ad683564218e3d0dcef885
This commit is contained in:
@@ -38007,6 +38007,7 @@ package android.provider {
|
||||
field public static final String COLUMN_FLAGS = "flags";
|
||||
field public static final String COLUMN_ICON = "icon";
|
||||
field public static final String COLUMN_MIME_TYPES = "mime_types";
|
||||
field public static final String COLUMN_QUERY_ARGS = "query_args";
|
||||
field public static final String COLUMN_ROOT_ID = "root_id";
|
||||
field public static final String COLUMN_SUMMARY = "summary";
|
||||
field public static final String COLUMN_TITLE = "title";
|
||||
|
||||
@@ -639,6 +639,28 @@ public final class DocumentsContract {
|
||||
*/
|
||||
public static final String COLUMN_MIME_TYPES = "mime_types";
|
||||
|
||||
/**
|
||||
* Query arguments supported by this root. This column is optional
|
||||
* and related to {@link #COLUMN_FLAGS} and {@link #FLAG_SUPPORTS_SEARCH}.
|
||||
* If the flags include {@link #FLAG_SUPPORTS_SEARCH}, and the column is
|
||||
* {@code null}, the root is assumed to support {@link #QUERY_ARG_DISPLAY_NAME}
|
||||
* search of {@link Document#COLUMN_DISPLAY_NAME}. Multiple query arguments
|
||||
* can be separated by a newline. For example, a root supporting
|
||||
* {@link #QUERY_ARG_MIME_TYPES} and {@link #QUERY_ARG_DISPLAY_NAME} might
|
||||
* return "android:query-arg-mime-types\nandroid:query-arg-display-name".
|
||||
* <p>
|
||||
* Type: STRING
|
||||
* @see #COLUMN_FLAGS
|
||||
* @see #FLAG_SUPPORTS_SEARCH
|
||||
* @see #QUERY_ARG_DISPLAY_NAME
|
||||
* @see #QUERY_ARG_FILE_SIZE_OVER
|
||||
* @see #QUERY_ARG_LAST_MODIFIED_AFTER
|
||||
* @see #QUERY_ARG_MIME_TYPES
|
||||
* @see DocumentsProvider#querySearchDocuments(String, String[],
|
||||
* Bundle)
|
||||
*/
|
||||
public static final String COLUMN_QUERY_ARGS = "query_args";
|
||||
|
||||
/**
|
||||
* MIME type for a root.
|
||||
*/
|
||||
@@ -680,6 +702,8 @@ public final class DocumentsContract {
|
||||
* String)
|
||||
* @see DocumentsProvider#querySearchDocuments(String, String,
|
||||
* String[])
|
||||
* @see DocumentsProvider#querySearchDocuments(String, String[],
|
||||
* Bundle)
|
||||
*/
|
||||
public static final int FLAG_SUPPORTS_SEARCH = 1 << 3;
|
||||
|
||||
|
||||
@@ -687,6 +687,7 @@ public abstract class DocumentsProvider extends ContentProvider {
|
||||
* extras {@link Bundle} when any QUERY_ARG_* value was honored
|
||||
* during the preparation of the results.
|
||||
*
|
||||
* @see Root#COLUMN_QUERY_ARGS
|
||||
* @see ContentResolver#EXTRA_HONORED_ARGS
|
||||
* @see DocumentsContract#EXTRA_LOADING
|
||||
* @see DocumentsContract#EXTRA_INFO
|
||||
|
||||
@@ -74,6 +74,16 @@ public abstract class FileSystemProvider extends DocumentsProvider {
|
||||
|
||||
private static final boolean LOG_INOTIFY = false;
|
||||
|
||||
protected static final String SUPPORTED_QUERY_ARGS = joinNewline(
|
||||
DocumentsContract.QUERY_ARG_DISPLAY_NAME,
|
||||
DocumentsContract.QUERY_ARG_FILE_SIZE_OVER,
|
||||
DocumentsContract.QUERY_ARG_LAST_MODIFIED_AFTER,
|
||||
DocumentsContract.QUERY_ARG_MIME_TYPES);
|
||||
|
||||
private static String joinNewline(String... args) {
|
||||
return TextUtils.join("\n", args);
|
||||
}
|
||||
|
||||
private String[] mDefaultProjection;
|
||||
|
||||
@GuardedBy("mObservers")
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ExternalStorageProvider extends FileSystemProvider {
|
||||
|
||||
private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
|
||||
Root.COLUMN_ROOT_ID, Root.COLUMN_FLAGS, Root.COLUMN_ICON, Root.COLUMN_TITLE,
|
||||
Root.COLUMN_DOCUMENT_ID, Root.COLUMN_AVAILABLE_BYTES,
|
||||
Root.COLUMN_DOCUMENT_ID, Root.COLUMN_AVAILABLE_BYTES, Root.COLUMN_QUERY_ARGS
|
||||
};
|
||||
|
||||
private static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[] {
|
||||
@@ -444,6 +444,7 @@ public class ExternalStorageProvider extends FileSystemProvider {
|
||||
row.add(Root.COLUMN_FLAGS, root.flags);
|
||||
row.add(Root.COLUMN_TITLE, root.title);
|
||||
row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
|
||||
row.add(Root.COLUMN_QUERY_ARGS, SUPPORTED_QUERY_ARGS);
|
||||
|
||||
long availableBytes = -1;
|
||||
if (root.reportAvailableBytes) {
|
||||
|
||||
Reference in New Issue
Block a user