diff options
| author | Pierre Barbier de Reuille <pbdr@google.com> | 2020-01-10 15:59:59 +0000 |
|---|---|---|
| committer | Pierre Barbier de Reuille <pbdr@google.com> | 2020-02-12 07:44:23 +0000 |
| commit | 1858482e491ee9e2c80126a0354f09ce2b4c7eb5 (patch) | |
| tree | 3a47dc155aa9c923dc02f17a93f4501e139c00b2 /core/java | |
| parent | 725becc7fe3cd8792ed5ccc7420218d170bd2443 (diff) | |
Add manifest broadcasts for profile (un-)available.
This mean both switch on/off and add/remove profiles.
The broadcasts already exists for registered receivers, this adds them
for manifest receivers with INTERACT_ACROSS_PROFILES permission and
crossProfile attribute.
The MANAGED_PROFILE_REMOVED broadcast is sent to all application with
android:crossProfile="true". Any cross profile app may be impacted, and
there is no possible transfer of information as the account is already
deleted at the time the signal is emitted.
Change-Id: I17fb9a01b70b28845c5d6aacdcdd497a82391474
Fix: 145135525, 145598120
Test: Demo-app using Digital Wellbeing (automated test underway).
Test: atest com.android.cts.devicepolicy.CrossProfileAppsPermissionHostSideTest
Test: atest 'com.android.cts.devicepolicy.QuietModeHostsideTest#testBroadcastManagedProfileAvailable_withCrossProfileAppsOp'
Test: atest 'com.android.cts.devicepolicy.QuietModeHostsideTest#testBroadcastManagedProfileAvailable_withoutCrossProfileAppsOp'
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/admin/DevicePolicyManagerInternal.java | 18 | ||||
| -rw-r--r-- | core/java/android/content/pm/CrossProfileAppsInternal.java | 55 |
2 files changed, 73 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java index e6c89d9071e6..80fa87152d78 100644 --- a/core/java/android/app/admin/DevicePolicyManagerInternal.java +++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java @@ -187,4 +187,22 @@ public abstract class DevicePolicyManagerInternal { * @hide */ public abstract List<String> getAllCrossProfilePackages(); + + /** + * Sends the {@code intent} to the packages with cross profile capabilities. + * + * <p>This means the application must have the {@code crossProfile} property and the + * corresponding permissions, defined by + * {@link + * android.content.pm.CrossProfileAppsInternal#verifyPackageHasInteractAcrossProfilePermission}. + * + * <p>Note: This method doesn't modify {@code intent} but copies it before use. + * + * @param intent Template for the intent sent to the package. + * @param parentHandle Handle of the user that will receive the intents. + * @param requiresPermission If false, all packages with the {@code crossProfile} property + * will receive the intent. + */ + public abstract void broadcastIntentToCrossProfileManifestReceiversAsUser(Intent intent, + UserHandle parentHandle, boolean requiresPermission); } diff --git a/core/java/android/content/pm/CrossProfileAppsInternal.java b/core/java/android/content/pm/CrossProfileAppsInternal.java new file mode 100644 index 000000000000..9ff441741bed --- /dev/null +++ b/core/java/android/content/pm/CrossProfileAppsInternal.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.content.pm; + +import android.annotation.UserIdInt; + +/** + * Exposes internal methods from {@link com.android.server.pm.CrossProfileAppsServiceImpl} to other + * system server classes. + * + * @hide Only for use within the system server. + */ +public abstract class CrossProfileAppsInternal { + /** + * Returns whether the package has the necessary permissions to communicate cross-profile. + * + * <p>This means having at least one of these conditions: + * <ul> + * <li>{@code Manifest.permission.INTERACT_ACROSS_USERS_FULL} granted. + * <li>{@code Manifest.permission.INTERACT_ACROSS_USERS} granted. + * <li>{@code Manifest.permission.INTERACT_ACROSS_PROFILES} granted, or the corresponding + * AppOps {@code android:interact_across_profiles} is set to "allow". + * </ul> + */ + public abstract boolean verifyPackageHasInteractAcrossProfilePermission(String packageName, + @UserIdInt int userId) throws PackageManager.NameNotFoundException; + + /** + * Returns whether the package has the necessary permissions to communicate cross-profile. + * + * <p>This means having at least one of these conditions: + * <ul> + * <li>{@code Manifest.permission.INTERACT_ACROSS_USERS_FULL} granted. + * <li>{@code Manifest.permission.INTERACT_ACROSS_USERS} granted. + * <li>{@code Manifest.permission.INTERACT_ACROSS_PROFILES} granted, or the corresponding + * AppOps {@code android:interact_across_profiles} is set to "allow". + * </ul> + */ + public abstract boolean verifyUidHasInteractAcrossProfilePermission(String packageName, + int uid); +} |
