• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 package com.android.documentsui.base;
17 
18 import android.net.Uri;
19 
20 import com.android.documentsui.archives.ArchivesProvider;
21 
22 import java.util.HashSet;
23 import java.util.Set;
24 
25 /**
26  * Details about various system providers. These all need to be in sync with the
27  * resources in their respective packages.
28  */
29 public final class Providers {
30 
31     public static final String AUTHORITY_STORAGE = "com.android.externalstorage.documents";
32     public static final String ROOT_ID_DEVICE = "primary";
33     public static final String ROOT_ID_HOME = "home";
34 
35     public static final String AUTHORITY_DOWNLOADS = "com.android.providers.downloads.documents";
36     public static final String ROOT_ID_DOWNLOADS = "downloads";
37 
38     public static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
39     public static final String ROOT_ID_IMAGES = "images_root";
40     public static final String ROOT_ID_VIDEOS = "videos_root";
41     public static final String ROOT_ID_AUDIO = "audio_root";
42     public static final String ROOT_ID_DOCUMENTS = "documents_root";
43 
44     public static final String AUTHORITY_MTP = "com.android.mtp.documents";
45     public static final String AUTHORITY_BUGREPORT = "com.android.shell.documents";
46 
47     private static final String DOCSUI_PACKAGE = "com.android.documentsui";
48     private static final Set<String> SYSTEM_AUTHORITIES = new HashSet<String>() {{
49         add(AUTHORITY_STORAGE);
50         add(AUTHORITY_DOWNLOADS);
51         add(AUTHORITY_MEDIA);
52         add(AUTHORITY_MTP);
53     }};
54 
isArchiveUri(Uri uri)55     public static boolean isArchiveUri(Uri uri) {
56         return uri != null && ArchivesProvider.AUTHORITY.equals(uri.getAuthority());
57     }
58 
isSystemProvider(String authority)59     public static boolean isSystemProvider(String authority) {
60         return SYSTEM_AUTHORITIES.contains(authority)
61                 || authority == null  // Recents
62                 || authority.startsWith(DOCSUI_PACKAGE);  // covers internal and test providers
63     }
64 }
65