1 /*
2  * Copyright (C) 2020 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.content.pm;
18 
19 import android.annotation.UserIdInt;
20 import android.os.UserHandle;
21 
22 import java.util.List;
23 
24 /**
25  * Exposes internal methods from {@link com.android.server.pm.CrossProfileAppsServiceImpl} to other
26  * system server classes.
27  *
28  * @hide Only for use within the system server.
29  */
30 public abstract class CrossProfileAppsInternal {
31     /**
32      * Returns whether the package has the necessary permissions to communicate cross-profile.
33      *
34      * <p>This means having at least one of these conditions:
35      * <ul>
36      *     <li>{@code Manifest.permission.INTERACT_ACROSS_USERS_FULL} granted.
37      *     <li>{@code Manifest.permission.INTERACT_ACROSS_USERS} granted.
38      *     <li>{@code Manifest.permission.INTERACT_ACROSS_PROFILES} granted, or the corresponding
39      *     AppOps {@code android:interact_across_profiles} is set to "allow".
40      * </ul>
41      */
verifyPackageHasInteractAcrossProfilePermission(String packageName, @UserIdInt int userId)42     public abstract boolean verifyPackageHasInteractAcrossProfilePermission(String packageName,
43             @UserIdInt int userId) throws PackageManager.NameNotFoundException;
44 
45     /**
46      * Returns whether the package has the necessary permissions to communicate cross-profile.
47      *
48      * <p>This means having at least one of these conditions:
49      * <ul>
50      *     <li>{@code Manifest.permission.INTERACT_ACROSS_USERS_FULL} granted.
51      *     <li>{@code Manifest.permission.INTERACT_ACROSS_USERS} granted.
52      *     <li>{@code Manifest.permission.INTERACT_ACROSS_PROFILES} granted, or the corresponding
53      *     AppOps {@code android:interact_across_profiles} is set to "allow".
54      * </ul>
55      */
verifyUidHasInteractAcrossProfilePermission(String packageName, int uid)56     public abstract boolean verifyUidHasInteractAcrossProfilePermission(String packageName,
57             int uid);
58 
59     /**
60      * Returns the list of target user profiles for the given package on the given user. See {@link
61      * CrossProfileApps#getTargetUserProfiles()}.
62      */
getTargetUserProfiles( String packageName, @UserIdInt int userId)63     public abstract List<UserHandle> getTargetUserProfiles(
64             String packageName, @UserIdInt int userId);
65 }
66