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

Commit 5c889892 authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Android (Google) Code Review
Browse files

Merge "Allow forceUpdateUserSetupComplete on user builds" into sc-dev

parents 3798c06e 3c4b8141
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11838,7 +11838,7 @@ public class DevicePolicyManager {
    /**
     * @hide
     * Force update user setup completed status. This API has no effect on user build.
     * Force update user setup completed status.
     * @throws {@link SecurityException} if the caller has no
     *         {@code android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS} or the caller is
     *         not {@link UserHandle#SYSTEM_USER}
+0 −4
Original line number Diff line number Diff line
@@ -14215,10 +14215,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                hasCallingOrSelfPermission(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS));
        enforceCallerSystemUserHandle();
        // no effect if it's called from user build
        if (!mInjector.isBuildDebuggable()) {
            return;
        }
        final int userId = UserHandle.USER_SYSTEM;
        boolean isUserCompleted = mInjector.settingsSecureGetIntForUser(
                Settings.Secure.USER_SETUP_COMPLETE, 0, userId) != 0;
+1 −29
Original line number Diff line number Diff line
@@ -3875,7 +3875,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }

    @Test
    public void testForceUpdateUserSetupComplete_userbuild() {
    public void testForceUpdateUserSetupComplete_forcesUpdate() {
        mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;

@@ -3888,34 +3888,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        userData.mUserSetupComplete = true;
        dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);

        // GIVEN it's user build
        getServices().buildMock.isDebuggable = false;

        assertThat(dpms.hasUserSetupCompleted()).isTrue();

        dpm.forceUpdateUserSetupComplete();

        // THEN the state in dpms is not changed
        assertThat(dpms.hasUserSetupCompleted()).isTrue();
    }

    @Test
    public void testForceUpdateUserSetupComplete_userDebugbuild() {
        mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;

        final int userId = UserHandle.USER_SYSTEM;
        // GIVEN userComplete is false in SettingsProvider
        setUserSetupCompleteForUser(false, userId);

        // GIVEN userComplete is true in DPM
        DevicePolicyData userData = new DevicePolicyData(userId);
        userData.mUserSetupComplete = true;
        dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);

        // GIVEN it's userdebug build
        getServices().buildMock.isDebuggable = true;

        assertThat(dpms.hasUserSetupCompleted()).isTrue();

        dpm.forceUpdateUserSetupComplete();