• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 com.android.server.uri;
18 
19 import android.content.Intent;
20 import android.content.pm.ProviderInfo;
21 import android.net.Uri;
22 import android.os.IBinder;
23 import android.os.UserHandle;
24 
25 import java.io.PrintWriter;
26 
27 /**
28  * Uri Grants local system service interface.
29  * @hide Only for use within system server
30  */
31 public interface UriGrantsManagerInternal {
onSystemReady()32     void onSystemReady();
onActivityManagerInternalAdded()33     void onActivityManagerInternalAdded();
removeUriPermissionIfNeeded(UriPermission perm)34     void removeUriPermissionIfNeeded(UriPermission perm);
grantUriPermission(int callingUid, String targetPkg, GrantUri grantUri, final int modeFlags, UriPermissionOwner owner, int targetUserId)35     void grantUriPermission(int callingUid, String targetPkg, GrantUri grantUri,
36             final int modeFlags, UriPermissionOwner owner, int targetUserId);
revokeUriPermission(String targetPackage, int callingUid, GrantUri grantUri, final int modeFlags)37     void revokeUriPermission(String targetPackage, int callingUid,
38             GrantUri grantUri, final int modeFlags);
checkUriPermission(GrantUri grantUri, int uid, final int modeFlags)39     boolean checkUriPermission(GrantUri grantUri, int uid, final int modeFlags);
checkGrantUriPermission(int callingUid, String targetPkg, GrantUri grantUri, final int modeFlags, int lastTargetUid)40     int checkGrantUriPermission(int callingUid, String targetPkg, GrantUri grantUri,
41             final int modeFlags, int lastTargetUid);
checkGrantUriPermission( int callingUid, String targetPkg, Uri uri, int modeFlags, int userId)42     int checkGrantUriPermission(
43             int callingUid, String targetPkg, Uri uri, int modeFlags, int userId);
checkGrantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent, int mode, NeededUriGrants needed, int targetUserId)44     NeededUriGrants checkGrantUriPermissionFromIntent(int callingUid,
45             String targetPkg, Intent intent, int mode, NeededUriGrants needed, int targetUserId);
46     /**
47      * Grant Uri permissions from one app to another. This method only extends
48      * permission grants if {@code callingUid} has permission to them.
49      */
grantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent, int targetUserId)50     void grantUriPermissionFromIntent(int callingUid,
51             String targetPkg, Intent intent, int targetUserId);
grantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent, UriPermissionOwner owner, int targetUserId)52     void grantUriPermissionFromIntent(int callingUid,
53             String targetPkg, Intent intent, UriPermissionOwner owner, int targetUserId);
grantUriPermissionUncheckedFromIntent( NeededUriGrants needed, UriPermissionOwner owner)54     void grantUriPermissionUncheckedFromIntent(
55             NeededUriGrants needed, UriPermissionOwner owner);
newUriPermissionOwner(String name)56     IBinder newUriPermissionOwner(String name);
57     /**
58      * Remove any {@link UriPermission} granted <em>from</em> or <em>to</em> the
59      * given package.
60      *
61      * @param packageName Package name to match, or {@code null} to apply to all
62      *            packages.
63      * @param userHandle User to match, or {@link UserHandle#USER_ALL} to apply
64      *            to all users.
65      * @param persistable If persistable grants should be removed.
66      * @param targetOnly When {@code true}, only remove permissions where the app is the target,
67      * not source.
68      */
removeUriPermissionsForPackage( String packageName, int userHandle, boolean persistable, boolean targetOnly)69     void removeUriPermissionsForPackage(
70             String packageName, int userHandle, boolean persistable, boolean targetOnly);
71     /**
72      * @param uri This uri must NOT contain an embedded userId.
73      * @param userId The userId in which the uri is to be resolved.
74      */
revokeUriPermissionFromOwner(IBinder token, Uri uri, int mode, int userId)75     void revokeUriPermissionFromOwner(IBinder token, Uri uri, int mode, int userId);
checkAuthorityGrants( int callingUid, ProviderInfo cpi, int userId, boolean checkUser)76     boolean checkAuthorityGrants(
77             int callingUid, ProviderInfo cpi, int userId, boolean checkUser);
dump(PrintWriter pw, boolean dumpAll, String dumpPackage)78     void dump(PrintWriter pw, boolean dumpAll, String dumpPackage);
79 }
80