1 /*
2  * Copyright (C) 2024 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 android.healthconnect.tests.documentproviderapp2;
18 
19 import android.database.Cursor;
20 import android.healthconnect.tests.documentprovider.utils.FakeDocumentProviderRoots;
21 import android.os.CancellationSignal;
22 import android.os.ParcelFileDescriptor;
23 import android.provider.DocumentsProvider;
24 
25 /** Document provider used for tests. Configured by {@link FakeDocumentProviderRoots}. */
26 public final class TestDocumentProvider extends DocumentsProvider {
27     @Override
onCreate()28     public boolean onCreate() {
29         return true;
30     }
31 
32     @Override
openDocument( String documentId, String mode, CancellationSignal signal)33     public ParcelFileDescriptor openDocument(
34             String documentId, String mode, CancellationSignal signal) {
35         throw new UnsupportedOperationException("Open document isn't supported");
36     }
37 
38     @Override
queryChildDocuments( String parentDocumentId, String[] projection, String sortOrder)39     public Cursor queryChildDocuments(
40             String parentDocumentId, String[] projection, String sortOrder) {
41         throw new UnsupportedOperationException("Query child documents isn't supported");
42     }
43 
44     @Override
queryDocument(String documentId, String[] projection)45     public Cursor queryDocument(String documentId, String[] projection) {
46         throw new UnsupportedOperationException("Query document isn't supported");
47     }
48 
49     @Override
queryRoots(String[] projection)50     public Cursor queryRoots(String[] projection) {
51         return FakeDocumentProviderRoots.INSTANCE.getCursor();
52     }
53 }
54