• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.documentsui;
18 
19 import android.database.Cursor;
20 import android.database.MatrixCursor;
21 import android.os.Bundle;
22 import android.provider.DocumentsContract;
23 
24 import java.io.FileNotFoundException;
25 
26 /**
27  * Provides data view that has files with FLAG_SUPPORTS_SETTINGS but nothing set to receive
28  * the ACTION_DOCUMENT_SETTINGS intent.
29  * <p>
30  * Do not use this provider for automated testing.
31  */
32 public class BrokenSettingsEnabledProvider extends TestRootProvider {
33 
34     private static final String ROOT_ID = "broken-settings-enabled-root";
35     private static final String ROOT_DOC_ID = "root0";
36 
BrokenSettingsEnabledProvider()37     public BrokenSettingsEnabledProvider() {
38         super("Broken Settings Enabled Root", ROOT_ID, 0, ROOT_DOC_ID);
39     }
40 
41     @Override
queryDocument(String documentId, String[] projection)42     public Cursor queryDocument(String documentId, String[] projection)
43             throws FileNotFoundException {
44         MatrixCursor c = createDocCursor(projection);
45         Bundle extras = c.getExtras();
46         extras.putString(
47                 DocumentsContract.EXTRA_INFO,
48                 "This provider is for feature demos only. Do not use from automated tests.");
49         addFolder(c, documentId);
50         return c;
51     }
52 
53     @Override
queryChildDocuments( String parentDocumentId, String[] projection, String sortOrder)54     public Cursor queryChildDocuments(
55             String parentDocumentId, String[] projection, String sortOrder)
56             throws FileNotFoundException {
57         MatrixCursor c = createDocCursor(projection);
58         addFile(c, "fred-dog.jpg", DocumentsContract.Document.FLAG_SUPPORTS_SETTINGS);
59         return c;
60     }
61 }
62