Loading packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +36 −3 Original line number Original line Diff line number Diff line Loading @@ -293,8 +293,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { } } /** /** * Verifies that swiping up when the lock pattern is not secure does not consume the scroll * Verifies that swiping up when the lock pattern is not secure dismissed dream and consumes * gesture or expand. * the gesture. */ */ @Test @Test public void testSwipeUp_keyguardNotSecure_doesNotExpand() { public void testSwipeUp_keyguardNotSecure_doesNotExpand() { Loading @@ -314,11 +314,44 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { reset(mScrimController); reset(mScrimController); // Scroll gesture is consumed. assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) .isTrue(); // We should not expand since the keyguard is not secure verify(mScrimController, never()).expand(any()); // Since we are swiping up, we should wake from dreams. verify(mCentralSurfaces).awakenDreams(); } /** * Verifies that swiping down when the lock pattern is not secure does not dismiss the dream. */ @Test public void testSwipeDown_keyguardNotSecure_doesNotExpand() { when(mLockPatternUtils.isSecure(CURRENT_USER_INFO.id)).thenReturn(false); mTouchHandler.onSessionStart(mTouchSession); ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor = ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class); verify(mTouchSession).registerGestureListener(gestureListenerCaptor.capture()); final OnGestureListener gestureListener = gestureListenerCaptor.getValue(); final float distanceY = SCREEN_HEIGHT_PX * 0.3f; // Swiping down near the bottom of the screen where the touch initiation region is. final MotionEvent event1 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, SCREEN_HEIGHT_PX - distanceY, 0); final MotionEvent event2 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, SCREEN_HEIGHT_PX, 0); reset(mScrimController); // Scroll gesture is not consumed. // Scroll gesture is not consumed. assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) .isFalse(); .isTrue(); // We should not expand since the keyguard is not secure // We should not expand since the keyguard is not secure verify(mScrimController, never()).expand(any()); verify(mScrimController, never()).expand(any()); // Since we are swiping down, we should not dismiss the dream. verify(mCentralSurfaces, never()).awakenDreams(); } } private void verifyScroll(float percent, Direction direction, private void verifyScroll(float percent, Direction direction, Loading packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -155,12 +155,12 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { return true; return true; } } // Don't set expansion if the user doesn't have a pin/password set so that no // If scrolling up and keyguard is not locked, dismiss the dream since there's // animations are played we're not transitioning to the bouncer. // no bouncer to show. if (!mLockPatternUtils.isSecure(mUserTracker.getUserId())) { if (e1.getY() > e2.getY() // Return false so the gesture is not consumed, allowing the dream to wake && !mLockPatternUtils.isSecure(mUserTracker.getUserId())) { // if it wants instead of doing nothing. mCentralSurfaces.get().awakenDreams(); return false; return true; } } // For consistency, we adopt the expansion definition found in the // For consistency, we adopt the expansion definition found in the Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +36 −3 Original line number Original line Diff line number Diff line Loading @@ -293,8 +293,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { } } /** /** * Verifies that swiping up when the lock pattern is not secure does not consume the scroll * Verifies that swiping up when the lock pattern is not secure dismissed dream and consumes * gesture or expand. * the gesture. */ */ @Test @Test public void testSwipeUp_keyguardNotSecure_doesNotExpand() { public void testSwipeUp_keyguardNotSecure_doesNotExpand() { Loading @@ -314,11 +314,44 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { reset(mScrimController); reset(mScrimController); // Scroll gesture is consumed. assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) .isTrue(); // We should not expand since the keyguard is not secure verify(mScrimController, never()).expand(any()); // Since we are swiping up, we should wake from dreams. verify(mCentralSurfaces).awakenDreams(); } /** * Verifies that swiping down when the lock pattern is not secure does not dismiss the dream. */ @Test public void testSwipeDown_keyguardNotSecure_doesNotExpand() { when(mLockPatternUtils.isSecure(CURRENT_USER_INFO.id)).thenReturn(false); mTouchHandler.onSessionStart(mTouchSession); ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor = ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class); verify(mTouchSession).registerGestureListener(gestureListenerCaptor.capture()); final OnGestureListener gestureListener = gestureListenerCaptor.getValue(); final float distanceY = SCREEN_HEIGHT_PX * 0.3f; // Swiping down near the bottom of the screen where the touch initiation region is. final MotionEvent event1 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, SCREEN_HEIGHT_PX - distanceY, 0); final MotionEvent event2 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, SCREEN_HEIGHT_PX, 0); reset(mScrimController); // Scroll gesture is not consumed. // Scroll gesture is not consumed. assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) .isFalse(); .isTrue(); // We should not expand since the keyguard is not secure // We should not expand since the keyguard is not secure verify(mScrimController, never()).expand(any()); verify(mScrimController, never()).expand(any()); // Since we are swiping down, we should not dismiss the dream. verify(mCentralSurfaces, never()).awakenDreams(); } } private void verifyScroll(float percent, Direction direction, private void verifyScroll(float percent, Direction direction, Loading
packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -155,12 +155,12 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { return true; return true; } } // Don't set expansion if the user doesn't have a pin/password set so that no // If scrolling up and keyguard is not locked, dismiss the dream since there's // animations are played we're not transitioning to the bouncer. // no bouncer to show. if (!mLockPatternUtils.isSecure(mUserTracker.getUserId())) { if (e1.getY() > e2.getY() // Return false so the gesture is not consumed, allowing the dream to wake && !mLockPatternUtils.isSecure(mUserTracker.getUserId())) { // if it wants instead of doing nothing. mCentralSurfaces.get().awakenDreams(); return false; return true; } } // For consistency, we adopt the expansion definition found in the // For consistency, we adopt the expansion definition found in the Loading