• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.scopedstorage.cts.device;
18 
19 import android.content.ContentResolver;
20 import android.database.Cursor;
21 import android.os.Bundle;
22 import android.provider.MediaStore;
23 
24 import org.junit.rules.ExternalResource;
25 
26 /**
27  * Introduces a few owned items and a few other app items.
28  */
29 public class OwnedAndOtherFilesRule extends ExternalResource {
30     private final ContentResolver mContentResolver;
31 
32     private final OwnedFilesRule mOwnedFilesRule;
33 
34     private final OtherAppFilesRule mOtherAppFilesRule;
35 
OwnedAndOtherFilesRule(ContentResolver contentResolver)36     public OwnedAndOtherFilesRule(ContentResolver contentResolver) {
37         this.mContentResolver = contentResolver;
38         mOwnedFilesRule = new OwnedFilesRule(mContentResolver);
39         mOtherAppFilesRule = new OtherAppFilesRule(mContentResolver);
40     }
41 
42     @Override
before()43     public void before() throws Exception {
44         mOwnedFilesRule.before();
45         mOtherAppFilesRule.before();
46     }
47 
48     @Override
after()49     public void after() {
50         mOwnedFilesRule.after();
51         mOtherAppFilesRule.after();
52     }
53 
getResultForFilesQuery(ContentResolver contentResolver, Bundle queryArgs)54     protected static Cursor getResultForFilesQuery(ContentResolver contentResolver,
55             Bundle queryArgs) {
56         return contentResolver.query(
57                 MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
58                 null,
59                 queryArgs,
60                 null);
61     }
62 }
63