Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 906bdbef authored by Sinduran Sivarajan's avatar Sinduran Sivarajan
Browse files

Disable "Developer options" by default for managed profiles.

Bug: 382064697
Test: go/work-profile-creation-developer-access
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:73b54cdf4b70831c4f952d7556274609cb46214e)
Merged-In: Ibe6b721f2552d9e72aba0582a2eed4ba87178c7c
Change-Id: Ibe6b721f2552d9e72aba0582a2eed4ba87178c7c
parent f1764b7f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -273,7 +273,8 @@ public class UserRestrictionsUtils {
     * in settings. So it is handled separately.
     */
    private static final Set<String> DEFAULT_ENABLED_FOR_MANAGED_PROFILES = Sets.newArraySet(
            UserManager.DISALLOW_BLUETOOTH_SHARING
            UserManager.DISALLOW_BLUETOOTH_SHARING,
            UserManager.DISALLOW_DEBUGGING_FEATURES
    );

    /**
+13 −1
Original line number Diff line number Diff line
@@ -8872,7 +8872,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                return false;
            }
            if (isAdb(caller)) {
            boolean isAdb = isAdb(caller);
            if (isAdb) {
                // Log profile owner provisioning was started using adb.
                MetricsLogger.action(mContext, PROVISIONING_ENTRY_POINT_ADB, LOG_TAG_PROFILE_OWNER);
                DevicePolicyEventLogger
@@ -8895,6 +8896,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                            UserRestrictionsUtils.getDefaultEnabledForManagedProfiles());
                    ensureUnknownSourcesRestrictionForProfileOwnerLocked(userHandle, admin,
                            true /* newOwner */);
                    if (isAdb) {
                        // DISALLOW_DEBUGGING_FEATURES is being added to newly-created
                        // work profile by default due to b/382064697 . This would have
                        //  impacted certain CTS test flows when they interact with the
                        // work profile via ADB (for example installing an app into the
                        // work profile). Remove DISALLOW_DEBUGGING_FEATURES here to
                        // reduce the potential impact.
                        admin.ensureUserRestrictions().putBoolean(
                            UserManager.DISALLOW_DEBUGGING_FEATURES, false);
                        saveUserRestrictionsLocked(userHandle);
                    }
                }
                sendOwnerChangedBroadcast(DevicePolicyManager.ACTION_PROFILE_OWNER_CHANGED,
                        userHandle);
+3 −1
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase {
        // Check that default restrictions were applied.
        DpmTestUtils.assertRestrictions(
                DpmTestUtils.newRestrictions(
                        UserManager.DISALLOW_DEBUGGING_FEATURES,
                        UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
                        UserManager.DISALLOW_BLUETOOTH_SHARING
                ),
@@ -138,8 +139,9 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase {

        final Set<String> alreadySet =
                dpms.getProfileOwnerAdminLocked(10).defaultEnabledRestrictionsAlreadySet;
        assertThat(alreadySet).hasSize(1);
        assertThat(alreadySet).hasSize(2);
        assertThat(alreadySet.contains(UserManager.DISALLOW_BLUETOOTH_SHARING)).isTrue();
        assertThat(alreadySet.contains(UserManager.DISALLOW_DEBUGGING_FEATURES)).isTrue();
    }

    @SmallTest