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

Commit ad1648d9 authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Update lock icon location onConfigurationChange" into tm-dev am: 97bbf580

parents 1f828de0 97bbf580
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -188,7 +188,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
    protected void onViewAttached() {
        updateIsUdfpsEnrolled();
        updateConfiguration();
        updateLockIconLocation();
        updateKeyguardShowing();
        mUserUnlockedWithBiometric = false;

@@ -347,6 +346,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
                R.string.accessibility_unlock_button);
        mLockedLabel = mView.getContext()
                .getResources().getString(R.string.accessibility_lock_icon);
        updateLockIconLocation();
    }

    private void updateLockIconLocation() {
@@ -691,7 +691,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        mExecutor.execute(() -> {
            updateIsUdfpsEnrolled();
            updateConfiguration();
            updateLockIconLocation();
        });
    }

@@ -708,7 +707,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme

        @Override
        public void onUdfpsLocationChanged() {
            updateLockIconLocation();
            updateUdfpsConfig();
        }
    };

+36 −3
Original line number Diff line number Diff line
@@ -135,8 +135,7 @@ public class LockIconViewControllerTest extends SysuiTestCase {
                .startMocking();
        MockitoAnnotations.initMocks(this);

        when(mLockIconView.getResources()).thenReturn(mResources);
        when(mLockIconView.getContext()).thenReturn(mContext);
        setupLockIconViewMocks();
        when(mContext.getResources()).thenReturn(mResources);
        when(mContext.getSystemService(WindowManager.class)).thenReturn(mWindowManager);
        Rect windowBounds = new Rect(0, 0, 800, 1200);
@@ -206,13 +205,14 @@ public class LockIconViewControllerTest extends SysuiTestCase {
    }

    @Test
    public void testUpdateFingerprintLocationOnAuthenticatorsRegistered() {
    public void testUpdateLockIconLocationOnAuthenticatorsRegistered() {
        // GIVEN fp sensor location is not available pre-init
        when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(false);
        when(mAuthController.getFingerprintSensorLocation()).thenReturn(null);
        mLockIconViewController.init();
        captureAttachListener();
        mAttachListener.onViewAttachedToWindow(mLockIconView);
        resetLockIconView(); // reset any method call counts for when we verify method calls later

        // GIVEN fp sensor location is available post-attached
        captureAuthControllerCallback();
@@ -227,6 +227,29 @@ public class LockIconViewControllerTest extends SysuiTestCase {
                eq(PADDING));
    }

    @Test
    public void testUpdateLockIconLocationOnUdfpsLocationChanged() {
        // GIVEN fp sensor location is not available pre-init
        when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(false);
        when(mAuthController.getFingerprintSensorLocation()).thenReturn(null);
        mLockIconViewController.init();
        captureAttachListener();
        mAttachListener.onViewAttachedToWindow(mLockIconView);
        resetLockIconView(); // reset any method call counts for when we verify method calls later

        // GIVEN fp sensor location is available post-attached
        captureAuthControllerCallback();
        Pair<Float, PointF> udfps = setupUdfps();

        // WHEN udfps location changes
        mAuthControllerCallback.onUdfpsLocationChanged();
        mDelayableExecutor.runAllReady();

        // THEN lock icon view location is updated with the same coordinates as auth controller vals
        verify(mLockIconView).setCenterLocation(eq(udfps.second), eq(udfps.first),
                eq(PADDING));
    }

    @Test
    public void testLockIconViewBackgroundEnabledWhenUdfpsIsSupported() {
        // GIVEN Udpfs sensor location is available
@@ -440,4 +463,14 @@ public class LockIconViewControllerTest extends SysuiTestCase {
                mKeyguardUpdateMonitorCallbackCaptor.capture());
        mKeyguardUpdateMonitorCallback = mKeyguardUpdateMonitorCallbackCaptor.getValue();
    }

    private void setupLockIconViewMocks() {
        when(mLockIconView.getResources()).thenReturn(mResources);
        when(mLockIconView.getContext()).thenReturn(mContext);
    }

    private void resetLockIconView() {
        reset(mLockIconView);
        setupLockIconViewMocks();
    }
}