• 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.provider.DocumentsContract.Root;
21 
22 import java.io.FileNotFoundException;
23 
24 /**
25  * Test provider that provides different kinds of broken behaviors DocumentsUI may encounter.
26  */
27 public class BrokenProvider extends TestRootProvider {
28 
29     // Root information for a root that throws when querying its root document
30     private static final String BROKEN_ROOT_DOCUMENT_ID = "BROKEN_ROOT_DOCUMENT";
31     private static final String BROKEN_ROOT_DOCUMENT_TITLE = "Broken Root Doc";
32 
33     @Override
onCreate()34     public boolean onCreate() {
35         return true;
36     }
37 
BrokenProvider()38     public BrokenProvider() {
39         super(
40                 BROKEN_ROOT_DOCUMENT_TITLE,
41                 BROKEN_ROOT_DOCUMENT_ID,
42                 Root.FLAG_SUPPORTS_CREATE,
43                 BROKEN_ROOT_DOCUMENT_ID);
44     }
45 
46     @Override
queryDocument(String documentId, String[] projection)47     public Cursor queryDocument(String documentId, String[] projection)
48             throws FileNotFoundException {
49         if (BROKEN_ROOT_DOCUMENT_ID.equals(documentId)) {
50             throw new FileNotFoundException();
51         }
52 
53         return null;
54     }
55 
56     @Override
queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder)57     public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
58             String sortOrder) throws FileNotFoundException {
59         throw new UnsupportedOperationException();
60     }
61 }
62