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 43 public static final String AUTHORITY_MTP = "com.android.mtp.documents"; 44 45 private static final String DOCSUI_PACKAGE = "com.android.documentsui"; 46 private static final Set<String> SYSTEM_AUTHORITIES = new HashSet<String>() {{ 47 add(AUTHORITY_STORAGE); 48 add(AUTHORITY_DOWNLOADS); 49 add(AUTHORITY_MEDIA); 50 add(AUTHORITY_MTP); 51 }}; 52 isArchiveUri(Uri uri)53 public static boolean isArchiveUri(Uri uri) { 54 return uri != null && ArchivesProvider.AUTHORITY.equals(uri.getAuthority()); 55 } 56 isSystemProvider(String authority)57 public static boolean isSystemProvider(String authority) { 58 return SYSTEM_AUTHORITIES.contains(authority) 59 || authority == null // Recents 60 || authority.startsWith(DOCSUI_PACKAGE); // covers internal and test providers 61 } 62 } 63