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

Commit f526a696 authored by Rubin Xu's avatar Rubin Xu
Browse files

Fix LockSettingsService unit test long wait

The mock fingerprint manager and face manager did not call the
removal callback, resulting in long delay in the LockSettingsService
side.

Bug: 142314731
Test: atest com.android.server.locksettings
Change-Id: I228e47c601deb90c90fd3aca3a40dbc8b22ec7e5
parent 712d0f7d
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@ import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.hardware.authsecret.V1_0.IAuthSecret;
import android.hardware.face.Face;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.os.FileUtils;
import android.os.IProgressListener;
@@ -249,11 +251,32 @@ public abstract class BaseLockSettingsServiceTests extends AndroidTestCase {
        when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
        when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
        when(mFingerprintManager.hasEnrolledFingerprints(userId)).thenReturn(true);
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Fingerprint fp = (Fingerprint) invocation.getArguments()[0];
                FingerprintManager.RemovalCallback callback =
                        (FingerprintManager.RemovalCallback) invocation.getArguments()[2];
                callback.onRemovalSucceeded(fp, 0);
                return null;
            }
        }).when(mFingerprintManager).remove(any(), eq(userId), any());


        // Hardware must be detected and templates must be enrolled
        when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
        when(mFaceManager.isHardwareDetected()).thenReturn(true);
        when(mFaceManager.hasEnrolledTemplates(userId)).thenReturn(true);
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Face face = (Face) invocation.getArguments()[0];
                FaceManager.RemovalCallback callback =
                        (FaceManager.RemovalCallback) invocation.getArguments()[2];
                callback.onRemovalSucceeded(face, 0);
                return null;
            }
        }).when(mFaceManager).remove(any(), eq(userId), any());
    }

    @Override