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

Commit 39e011d0 authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

Merge "Cleans up any stray instances of KeyguardUpdateMonitor that might still...

Merge "Cleans up any stray instances of KeyguardUpdateMonitor that might still have listeners attached to system services." into tm-qpr-dev am: d5d35fb2 am: afc70ab7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19967845



Change-Id: Ib7e5986da16cbfee5869bd00fffd590a79e925cd
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c6324249 afc70ab7
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -329,8 +329,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    @After
    public void tearDown() {
        mMockitoSession.finishMocking();
        mKeyguardUpdateMonitor.removeCallback(mTestCallback);
        mKeyguardUpdateMonitor.destroy();
        cleanupKeyguardUpdateMonitor();
    }

    @Test
@@ -352,6 +351,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {

    @Test
    public void testSimStateInitialized() {
        cleanupKeyguardUpdateMonitor();
        final int subId = 3;
        final int state = TelephonyManager.SIM_STATE_ABSENT;

@@ -1206,7 +1206,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {

    @Test
    public void testShouldListenForFace_whenFaceManagerNotAvailable_returnsFalse() {
        mFaceManager = null;
        cleanupKeyguardUpdateMonitor();
        mSpiedContext.addMockSystemService(FaceManager.class, null);
        when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(false);
        mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);

        assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
@@ -1259,6 +1261,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {

    @Test
    public void testShouldListenForFace_whenUserIsNotPrimary_returnsFalse() throws RemoteException {
        cleanupKeyguardUpdateMonitor();
        // This disables face auth
        when(mUserManager.isPrimaryUser()).thenReturn(false);
        mKeyguardUpdateMonitor =
@@ -1588,9 +1591,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {

    @Test
    public void testFingerAcquired_wakesUpPowerManager() {
        mContext.getOrCreateTestableResources().addOverride(
        cleanupKeyguardUpdateMonitor();
        mSpiedContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.bool.kg_wake_on_acquire_start, true);
        mSpiedContext = spy(mContext);
        mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
        fingerprintAcquireStart();

@@ -1599,15 +1602,23 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {

    @Test
    public void testFingerAcquired_doesNotWakeUpPowerManager() {
        mContext.getOrCreateTestableResources().addOverride(
        cleanupKeyguardUpdateMonitor();
        mSpiedContext.getOrCreateTestableResources().addOverride(
                com.android.internal.R.bool.kg_wake_on_acquire_start, false);
        mSpiedContext = spy(mContext);
        mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
        fingerprintAcquireStart();

        verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
    }

    private void cleanupKeyguardUpdateMonitor() {
        if (mKeyguardUpdateMonitor != null) {
            mKeyguardUpdateMonitor.removeCallback(mTestCallback);
            mKeyguardUpdateMonitor.destroy();
            mKeyguardUpdateMonitor = null;
        }
    }

    private void faceAuthLockedOut() {
        mKeyguardUpdateMonitor.mFaceAuthenticationCallback
                .onAuthenticationError(FaceManager.FACE_ERROR_LOCKOUT_PERMANENT, "");