summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author axfordjc <axfordjc@google.com> 2023-07-04 10:52:16 +0000
committer Jonathon Axford <axfordjc@google.com> 2023-07-07 08:38:29 +0000
commitb4bbfd958ef65c45eb98a2334059e061d7b592df (patch)
treeb3f8b14f5d2f7e7d682cb01b34da2e9dbaa8aa31
parent4321cd2b106aeffa200eadfa51878fa4472fa123 (diff)
key-guard PIN view: Fixed initial posture.
PIN keyguard started in DEVICE_POSTURE_UNKNOWN posture state, now it is synced with getDevicePosture() from DevicePostureController when started. Added tests for initial posture check and posture changed che Fixes: 288886736 Test: KeyguardPINViewControllerTest Change-Id: I748db6ea5317028cca5de9bf6adafa5423e195e7
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java1
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt38
2 files changed, 38 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java
index 3e16d559742d..794e6941c2bb 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java
@@ -77,6 +77,7 @@ public class KeyguardPinViewController
});
}
mPasswordEntry.setUserActivityListener(this::onUserInput);
+ mView.onDevicePostureChanged(mPostureController.getDevicePosture());
mPostureController.addCallback(mPostureCallback);
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
index d3b41902499c..9db267c2c929 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinViewControllerTest.kt
@@ -30,12 +30,16 @@ import com.android.systemui.classifier.FalsingCollectorFake
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.statusbar.policy.DevicePostureController
+import com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_HALF_OPENED
+import com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyString
+import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.any
@@ -79,7 +83,9 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
@Mock lateinit var deleteButton: NumPadButton
@Mock lateinit var enterButton: View
- lateinit var pinViewController: KeyguardPinViewController
+ private lateinit var pinViewController: KeyguardPinViewController
+
+ @Captor lateinit var postureCallbackCaptor: ArgumentCaptor<DevicePostureController.Callback>
@Before
fun setup() {
@@ -97,6 +103,9 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
`when`(keyguardPinView.findViewById<NumPadButton>(R.id.delete_button))
.thenReturn(deleteButton)
`when`(keyguardPinView.findViewById<View>(R.id.key_enter)).thenReturn(enterButton)
+ // For posture tests:
+ `when`(keyguardPinView.buttons).thenReturn(arrayOf())
+
pinViewController =
KeyguardPinViewController(
keyguardPinView,
@@ -115,6 +124,33 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
}
@Test
+ fun onViewAttached_deviceHalfFolded_propagatedToPinView() {
+ `when`(postureController.devicePosture).thenReturn(DEVICE_POSTURE_HALF_OPENED)
+
+ pinViewController.onViewAttached()
+
+ verify(keyguardPinView).onDevicePostureChanged(DEVICE_POSTURE_HALF_OPENED)
+ }
+
+ @Test
+ fun onDevicePostureChanged_deviceHalfFolded_propagatedToPinView() {
+ `when`(postureController.devicePosture).thenReturn(DEVICE_POSTURE_HALF_OPENED)
+
+ // Verify view begins in posture state DEVICE_POSTURE_HALF_OPENED
+ pinViewController.onViewAttached()
+
+ verify(keyguardPinView).onDevicePostureChanged(DEVICE_POSTURE_HALF_OPENED)
+
+ // Simulate posture change to state DEVICE_POSTURE_OPENED with callback
+ verify(postureController).addCallback(postureCallbackCaptor.capture())
+ val postureCallback: DevicePostureController.Callback = postureCallbackCaptor.value
+ postureCallback.onPostureChanged(DEVICE_POSTURE_OPENED)
+
+ // Verify view is now in posture state DEVICE_POSTURE_OPENED
+ verify(keyguardPinView).onDevicePostureChanged(DEVICE_POSTURE_OPENED)
+ }
+
+ @Test
fun startAppearAnimation() {
pinViewController.startAppearAnimation()
verify(keyguardMessageAreaController)