1 /* 2 * Copyright 2018 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 androidx.slice; 18 19 import static androidx.slice.widget.SliceLiveData.SUPPORTED_SPECS; 20 21 import android.content.Context; 22 import android.content.Intent; 23 import android.net.Uri; 24 25 import androidx.annotation.NonNull; 26 import androidx.annotation.Nullable; 27 import androidx.annotation.RestrictTo; 28 import androidx.slice.compat.SliceProviderCompat; 29 import androidx.slice.widget.SliceLiveData; 30 31 import java.util.Collection; 32 import java.util.List; 33 import java.util.Set; 34 35 36 /** 37 * @hide 38 */ 39 @RestrictTo(RestrictTo.Scope.LIBRARY) 40 class SliceManagerCompat extends SliceManagerBase { 41 42 SliceManagerCompat(Context context) { 43 super(context); 44 } 45 46 @Override 47 public void pinSlice(@NonNull Uri uri) { 48 SliceProviderCompat.pinSlice(mContext, uri, SliceLiveData.SUPPORTED_SPECS); 49 } 50 51 @Override 52 public void unpinSlice(@NonNull Uri uri) { 53 SliceProviderCompat.unpinSlice(mContext, uri, SliceLiveData.SUPPORTED_SPECS); 54 } 55 56 @Override 57 public @NonNull Set<SliceSpec> getPinnedSpecs(@NonNull Uri uri) { 58 return SliceProviderCompat.getPinnedSpecs(mContext, uri); 59 } 60 61 @Nullable 62 @Override 63 public Slice bindSlice(@NonNull Uri uri) { 64 return SliceProviderCompat.bindSlice(mContext, uri, SUPPORTED_SPECS); 65 } 66 67 @Nullable 68 @Override 69 public Slice bindSlice(@NonNull Intent intent) { 70 return SliceProviderCompat.bindSlice(mContext, intent, SUPPORTED_SPECS); 71 } 72 73 @Nullable 74 @Override 75 public Uri mapIntentToUri(@NonNull Intent intent) { 76 return SliceProviderCompat.mapIntentToUri(mContext, intent); 77 } 78 79 @Override 80 public int checkSlicePermission(Uri uri, int pid, int uid) { 81 return SliceProviderCompat.checkSlicePermission(mContext, mContext.getPackageName(), uri, 82 pid, uid); 83 } 84 85 @Override 86 public void grantSlicePermission(String toPackage, Uri uri) { 87 SliceProviderCompat.grantSlicePermission(mContext, mContext.getPackageName(), toPackage, 88 uri); 89 } 90 91 @Override 92 public void revokeSlicePermission(String toPackage, Uri uri) { 93 SliceProviderCompat.revokeSlicePermission(mContext, mContext.getPackageName(), toPackage, 94 uri); 95 } 96 97 @Override 98 public Collection<Uri> getSliceDescendants(Uri uri) { 99 return SliceProviderCompat.getSliceDescendants(mContext, uri); 100 } 101 102 @Override 103 public List<Uri> getPinnedSlices() { 104 return SliceProviderCompat.getPinnedSlices(mContext); 105 } 106 } 107