Update lock icon location onConfigurationChange

So the location will update on orientation
change.

Test: manually rotate lock screen
Test: atest LockIconViewControllerTest
Fixes: 231903658
Change-Id: I50984988ae785de3c7829afca28ad821c8502d1d
This commit is contained in:
Beverly
2022-05-12 16:19:14 +00:00
parent 56e26a9e4d
commit a4208e619d
2 changed files with 38 additions and 6 deletions

View File

@@ -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();
}
};

View File

@@ -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();
}
}