diff options
| author | Rubin Xu <rubinxu@google.com> | 2018-01-02 20:37:35 +0000 |
|---|---|---|
| committer | Rubin Xu <rubinxu@google.com> | 2018-01-12 19:01:40 +0000 |
| commit | cc391c2c13b30c494908309659509f8426af48ea (patch) | |
| tree | cd3f44778ab171e0a48b33eebba95cdb2c658b71 /core/java | |
| parent | 79131f7a227eb5f2bbd4e6ea29e14d834c634101 (diff) | |
Implement DISALLOW_SHARE_INTO_MANAGED_PROFILE
Add a user restriction to allow profile owners to enforce a stronger
isolation of managed profile by preventing users sharing data into
the profile. This is achieved by disabling a subset of built-in cross
profile intent filters added by ManagedProvisioning during profile
inflation.
Implementation wise, DevicePolicyManagerService listens for the restriction
change and notifies ManagedProvisioning to modify the built-in intent
filters. This is needed since ManagedProvisioning has ground truth of all
built-in intent filters and manages them. It also has the advantage that
ManagedProvisioning only needs to run when a policy change happens.
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.ManagedProfileTest#testDisallowSharingIntoProfileFromPersonal
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.ManagedProfileTest#testDisallowSharingIntoProfileFromProfile
Bug: 63911046
Change-Id: Ia6d12a5086627d1280325cd19d6e3a0752dae633
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 27 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 21 |
2 files changed, 48 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index ab85fdce6ce8..10539d19d563 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -1254,6 +1254,26 @@ public class DevicePolicyManager { = "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED"; /** + * Broadcast action to notify ManagedProvisioning that + * {@link UserManager#DISALLOW_SHARE_INTO_MANAGED_PROFILE} restriction has changed. + * @hide + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_DATA_SHARING_RESTRICTION_CHANGED = + "android.app.action.DATA_SHARING_RESTRICTION_CHANGED"; + + /** + * Broadcast action from ManagedProvisioning to notify that the latest change to + * {@link UserManager#DISALLOW_SHARE_INTO_MANAGED_PROFILE} restriction has been successfully + * applied (cross profile intent filters updated). Only usesd for CTS tests. + * @hide + */ + @TestApi + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_DATA_SHARING_RESTRICTION_APPLIED = + "android.app.action.DATA_SHARING_RESTRICTION_APPLIED"; + + /** * Permission policy to prompt user for new permission requests for runtime permissions. * Already granted or denied permissions are not affected by this. */ @@ -6057,6 +6077,13 @@ public class DevicePolicyManager { * Called by a profile owner of a managed profile to remove the cross-profile intent filters * that go from the managed profile to the parent, or from the parent to the managed profile. * Only removes those that have been set by the profile owner. + * <p> + * <em>Note</em>: A list of default cross profile intent filters are set up by the system when + * the profile is created, some of them ensure the proper functioning of the profile, while + * others enable sharing of data from the parent to the managed profile for user convenience. + * These default intent filters are not cleared when this API is called. If the default cross + * profile data sharing is not desired, they can be disabled with + * {@link UserManager#DISALLOW_SHARE_INTO_MANAGED_PROFILE}. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @throws SecurityException if {@code admin} is not a device or profile owner. diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 4e94c321e0a5..bb55afb2c4f7 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -892,6 +892,27 @@ public class UserManager { public static final String DISALLOW_USER_SWITCH = "no_user_switch"; /** + * Specifies whether the user can share file / picture / data from the primary user into the + * managed profile, either by sending them from the primary side, or by picking up data within + * an app in the managed profile. + * <p> + * When a managed profile is created, the system allows the user to send data from the primary + * side to the profile by setting up certain default cross profile intent filters. If + * this is undesired, this restriction can be set to disallow it. Note that this restriction + * will not block any sharing allowed by explicit + * {@link DevicePolicyManager#addCrossProfileIntentFilter} calls by the profile owner. + * <p> + * This restriction is only meaningful when set by profile owner. When it is set by device + * owner, it does not have any effect. + * <p> + * The default value is <code>false</code>. + * + * @see DevicePolicyManager#addUserRestriction(ComponentName, String) + * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) + * @see #getUserRestrictions() + */ + public static final String DISALLOW_SHARE_INTO_MANAGED_PROFILE = "no_sharing_into_profile"; + /** * Application restriction key that is used to indicate the pending arrival * of real restrictions for the app. * |
