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

Commit 078904e0 authored by Grace Cheng's avatar Grace Cheng
Browse files

Fix CTS test failures

Fixes CTS test failures caused by CE storage remaining locked after AuthenticationPolicyManagerTest

Flag: android.security.secure_lock_device
Bug: 401645997
Fixes: 440141959
Fixes: 441298465
Test: atest AuthenticationPolicyManagerTest
Test: atest SecureLockDeviceServiceTest
Change-Id: Ib700f84b2ede8b79230ecb2fb9d902eb3623bc20
parent 84a5b7ba
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -540,7 +540,7 @@ public class AuthenticationPolicyService extends SystemService {
            try {
                boolean authenticationComplete =
                        mSecureLockDeviceService.hasUserCompletedTwoFactorAuthentication(user);
                Slog.d("SecureLockDeviceService", "Disabling secure lock device: "
                Slog.d(TAG, "Disabling secure lock device: "
                        + "user " + user + ", authenticationComplete " + authenticationComplete);
                return mSecureLockDeviceService.disableSecureLockDevice(user, params,
                        /* authenticationComplete = */ authenticationComplete);
+16 −3
Original line number Diff line number Diff line
@@ -119,6 +119,10 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
    // to disable secure lock. Will be null if no user is currently authenticated.
    private UserHandle mUserAuthenticatedWithStrongBiometric = null;

    // Whether test mode is enabled, meaning components of the feature that interfere with testing
    // should be disabled (i.e. disabling USB connections, ADB, etc)
    private boolean mSkipSecurityFeaturesForTest;

    SecureLockDeviceService(@NonNull Context context,
            @NonNull SecureLockDeviceSettingsManager settingsManager,
            @Nullable BiometricManager biometricManager,
@@ -511,9 +515,17 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
            return ERROR_NOT_AUTHORIZED;
        }

        // Clears strong auth flags
        if (mSkipSecurityFeaturesForTest) {
            // 1) Clears strong auth flags and 2) unlocks user. authenticationComplete must be true
            // for tests in order to prevent relocking CE storage, which interferes with tests
            mLockSettingsInternal.disableSecureLockDevice(secureLockDeviceClientId,
                    /* authenticationComplete =*/ true);
        } else {
            // 1) Clears strong auth flags and 2) unlocks user if two-factor authentication is
            // complete, or locks user if two-factor authentication is incomplete
            mLockSettingsInternal.disableSecureLockDevice(secureLockDeviceClientId,
                    authenticationComplete);
        }
        disableSecurityFeatures(secureLockDeviceClientId);

        mStore.storeSecureLockDeviceDisabled();
@@ -708,6 +720,7 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
        if (DEBUG) {
            Slog.d(TAG, "setSecureLockDeviceTestStatus(isTestMode = " + isTestMode + ")");
        }
        mSkipSecurityFeaturesForTest = isTestMode;
        mSecureLockDeviceSettingsManager.setSkipSecurityFeaturesForTest(isTestMode);
    }

+2 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
@@ -494,7 +495,7 @@ public class SecureLockDeviceServiceTest {

        disableSecureLockDevice(mUser);

        verify(mLockSettingsInternal).disableSecureLockDevice(eq(TEST_USER_ID), eq(false));
        verify(mLockSettingsInternal).disableSecureLockDevice(eq(TEST_USER_ID), anyBoolean());
    }

    @Test