Loading core/java/android/os/UserManager.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -705,7 +705,7 @@ public class UserManager { * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} * can set this restriction using the DevicePolicyManager APIs mentioned below. * can set this restriction using the DevicePolicyManager APIs mentioned below. * * * <p>Default is <code>true</code> for managed profiles and false otherwise. * <p>Default is <code>true</code> for managed and private profiles, false otherwise. * * * <p>When a device upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it * <p>When a device upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it * for all existing managed profiles. * for all existing managed profiles. Loading services/core/java/com/android/server/pm/UserTypeFactory.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -306,7 +306,7 @@ public final class UserTypeFactory { R.color.black) R.color.black) .setDarkThemeBadgeColors( .setDarkThemeBadgeColors( R.color.white) R.color.white) .setDefaultRestrictions(getDefaultProfileRestrictions()) .setDefaultRestrictions(getDefaultPrivateProfileRestrictions()) .setDefaultCrossProfileIntentFilters(getDefaultPrivateCrossProfileIntentFilter()) .setDefaultCrossProfileIntentFilters(getDefaultPrivateCrossProfileIntentFilter()) .setDefaultUserProperties(new UserProperties.Builder() .setDefaultUserProperties(new UserProperties.Builder() .setStartWithParent(true) .setStartWithParent(true) Loading Loading @@ -430,6 +430,13 @@ public final class UserTypeFactory { return restrictions; return restrictions; } } @VisibleForTesting static Bundle getDefaultPrivateProfileRestrictions() { final Bundle restrictions = getDefaultProfileRestrictions(); restrictions.putBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING, true); return restrictions; } private static Bundle getDefaultManagedProfileSecureSettings() { private static Bundle getDefaultManagedProfileSecureSettings() { // Only add String values to the bundle, settings are written as Strings eventually // Only add String values to the bundle, settings are written as Strings eventually final Bundle settings = new Bundle(); final Bundle settings = new Bundle(); Loading services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -1254,6 +1254,30 @@ public final class UserManagerTest { } } } } @MediumTest @Test public void testDefaultUserRestrictionsForPrivateProfile() { assumeTrue(mUserManager.canAddPrivateProfile()); final int currentUserId = ActivityManager.getCurrentUser(); UserInfo privateProfileInfo = null; try { privateProfileInfo = createProfileForUser("Private", UserManager.USER_TYPE_PROFILE_PRIVATE, currentUserId); assertThat(privateProfileInfo).isNotNull(); } catch (Exception e) { fail("Creation of private profile failed due to " + e.getMessage()); } assertDefaultPrivateProfileRestrictions(privateProfileInfo.getUserHandle()); } private void assertDefaultPrivateProfileRestrictions(UserHandle userHandle) { Bundle defaultPrivateProfileRestrictions = UserTypeFactory.getDefaultPrivateProfileRestrictions(); for (String restriction : defaultPrivateProfileRestrictions.keySet()) { assertThat(mUserManager.hasUserRestrictionForUser(restriction, userHandle)).isTrue(); } } @MediumTest @MediumTest @Test @Test public void testAddRestrictedProfile() throws Exception { public void testAddRestrictedProfile() throws Exception { Loading Loading
core/java/android/os/UserManager.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -705,7 +705,7 @@ public class UserManager { * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} * can set this restriction using the DevicePolicyManager APIs mentioned below. * can set this restriction using the DevicePolicyManager APIs mentioned below. * * * <p>Default is <code>true</code> for managed profiles and false otherwise. * <p>Default is <code>true</code> for managed and private profiles, false otherwise. * * * <p>When a device upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it * <p>When a device upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it * for all existing managed profiles. * for all existing managed profiles. Loading
services/core/java/com/android/server/pm/UserTypeFactory.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -306,7 +306,7 @@ public final class UserTypeFactory { R.color.black) R.color.black) .setDarkThemeBadgeColors( .setDarkThemeBadgeColors( R.color.white) R.color.white) .setDefaultRestrictions(getDefaultProfileRestrictions()) .setDefaultRestrictions(getDefaultPrivateProfileRestrictions()) .setDefaultCrossProfileIntentFilters(getDefaultPrivateCrossProfileIntentFilter()) .setDefaultCrossProfileIntentFilters(getDefaultPrivateCrossProfileIntentFilter()) .setDefaultUserProperties(new UserProperties.Builder() .setDefaultUserProperties(new UserProperties.Builder() .setStartWithParent(true) .setStartWithParent(true) Loading Loading @@ -430,6 +430,13 @@ public final class UserTypeFactory { return restrictions; return restrictions; } } @VisibleForTesting static Bundle getDefaultPrivateProfileRestrictions() { final Bundle restrictions = getDefaultProfileRestrictions(); restrictions.putBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING, true); return restrictions; } private static Bundle getDefaultManagedProfileSecureSettings() { private static Bundle getDefaultManagedProfileSecureSettings() { // Only add String values to the bundle, settings are written as Strings eventually // Only add String values to the bundle, settings are written as Strings eventually final Bundle settings = new Bundle(); final Bundle settings = new Bundle(); Loading
services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -1254,6 +1254,30 @@ public final class UserManagerTest { } } } } @MediumTest @Test public void testDefaultUserRestrictionsForPrivateProfile() { assumeTrue(mUserManager.canAddPrivateProfile()); final int currentUserId = ActivityManager.getCurrentUser(); UserInfo privateProfileInfo = null; try { privateProfileInfo = createProfileForUser("Private", UserManager.USER_TYPE_PROFILE_PRIVATE, currentUserId); assertThat(privateProfileInfo).isNotNull(); } catch (Exception e) { fail("Creation of private profile failed due to " + e.getMessage()); } assertDefaultPrivateProfileRestrictions(privateProfileInfo.getUserHandle()); } private void assertDefaultPrivateProfileRestrictions(UserHandle userHandle) { Bundle defaultPrivateProfileRestrictions = UserTypeFactory.getDefaultPrivateProfileRestrictions(); for (String restriction : defaultPrivateProfileRestrictions.keySet()) { assertThat(mUserManager.hasUserRestrictionForUser(restriction, userHandle)).isTrue(); } } @MediumTest @MediumTest @Test @Test public void testAddRestrictedProfile() throws Exception { public void testAddRestrictedProfile() throws Exception { Loading