summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)