summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Beverly <beverlyt@google.com> 2022-05-12 16:19:14 +0000
committer Beverly <beverlyt@google.com> 2022-05-12 18:39:24 +0000
commita4208e619dad57c54fe83d4cbd28a66da8bd04ac (patch)
tree6843af81c29107590534868faa5b7a2bac3aa500
parent56e26a9e4d0263f300076a379f66a0be0ee8dd5c (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/keyguard/LockIconViewController.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java39
2 files changed, 38 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
index ab831be0f8e0..680b8bd70837 100644
--- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
@@ -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();
}
};
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java
index c532ed5ab651..24d051508fde 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java
@@ -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();
@@ -228,6 +228,29 @@ public class LockIconViewControllerTest extends SysuiTestCase {
}
@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
setupUdfps();
@@ -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();
+ }
}