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

Commit cde50eaa authored by Sinduran Sivarajan's avatar Sinduran Sivarajan Committed by Automerger Merge Worker
Browse files

Merge "Disable "Developer options" by default for managed profiles." into tm-dev am: 863a3808

parents 5b381318 863a3808
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -273,7 +273,8 @@ public class UserRestrictionsUtils {
     * in settings. So it is handled separately.
     * in settings. So it is handled separately.
     */
     */
    private static final Set<String> DEFAULT_ENABLED_FOR_MANAGED_PROFILES = Sets.newArraySet(
    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 Original line Diff line number Diff line
@@ -8868,7 +8868,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                return false;
                return false;
            }
            }
            if (isAdb(caller)) {
            boolean isAdb = isAdb(caller);
            if (isAdb) {
                // Log profile owner provisioning was started using adb.
                // Log profile owner provisioning was started using adb.
                MetricsLogger.action(mContext, PROVISIONING_ENTRY_POINT_ADB, LOG_TAG_PROFILE_OWNER);
                MetricsLogger.action(mContext, PROVISIONING_ENTRY_POINT_ADB, LOG_TAG_PROFILE_OWNER);
                DevicePolicyEventLogger
                DevicePolicyEventLogger
@@ -8891,6 +8892,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                            UserRestrictionsUtils.getDefaultEnabledForManagedProfiles());
                            UserRestrictionsUtils.getDefaultEnabledForManagedProfiles());
                    ensureUnknownSourcesRestrictionForProfileOwnerLocked(userHandle, admin,
                    ensureUnknownSourcesRestrictionForProfileOwnerLocked(userHandle, admin,
                            true /* newOwner */);
                            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,
                sendOwnerChangedBroadcast(DevicePolicyManager.ACTION_PROFILE_OWNER_CHANGED,
                        userHandle);
                        userHandle);
+3 −1
Original line number Original line Diff line number Diff line
@@ -131,6 +131,7 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase {
        // Check that default restrictions were applied.
        // Check that default restrictions were applied.
        DpmTestUtils.assertRestrictions(
        DpmTestUtils.assertRestrictions(
                DpmTestUtils.newRestrictions(
                DpmTestUtils.newRestrictions(
                        UserManager.DISALLOW_DEBUGGING_FEATURES,
                        UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
                        UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
                        UserManager.DISALLOW_BLUETOOTH_SHARING
                        UserManager.DISALLOW_BLUETOOTH_SHARING
                ),
                ),
@@ -138,8 +139,9 @@ public class DevicePolicyManagerServiceMigrationTest extends DpmTestBase {


        final Set<String> alreadySet =
        final Set<String> alreadySet =
                dpms.getProfileOwnerAdminLocked(10).defaultEnabledRestrictionsAlreadySet;
                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_BLUETOOTH_SHARING)).isTrue();
        assertThat(alreadySet.contains(UserManager.DISALLOW_DEBUGGING_FEATURES)).isTrue();
    }
    }


    @SmallTest
    @SmallTest