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