Don't handle bouncer swipes on dream if keyguard is not secure
This avoids us animating the complications upwards if the bouncer is not going to show. Fixes: 285429536 Test: atest BouncerSwipeTouchHandlerTest Change-Id: Iada72221f1d1ae073a16647553a65ca3e2a543ef
This commit is contained in:
@@ -35,9 +35,11 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.UiEvent;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
|
||||
import com.android.systemui.dreams.touch.scrim.ScrimController;
|
||||
import com.android.systemui.dreams.touch.scrim.ScrimManager;
|
||||
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.shade.ShadeExpansionChangeEvent;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
||||
@@ -76,6 +78,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
||||
|
||||
private static final String TAG = "BouncerSwipeTouchHandler";
|
||||
private final NotificationShadeWindowController mNotificationShadeWindowController;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final UserTracker mUserTracker;
|
||||
private final float mBouncerZoneScreenPercentage;
|
||||
|
||||
private final ScrimManager mScrimManager;
|
||||
@@ -151,6 +155,11 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't set expansion if the user doesn't have a pin/password set.
|
||||
if (!mLockPatternUtils.isSecure(mUserTracker.getUserId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// For consistency, we adopt the expansion definition found in the
|
||||
// PanelViewController. In this case, expansion refers to the view above the
|
||||
// bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer
|
||||
@@ -204,6 +213,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
||||
NotificationShadeWindowController notificationShadeWindowController,
|
||||
ValueAnimatorCreator valueAnimatorCreator,
|
||||
VelocityTrackerFactory velocityTrackerFactory,
|
||||
LockPatternUtils lockPatternUtils,
|
||||
UserTracker userTracker,
|
||||
@Named(SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_OPENING)
|
||||
FlingAnimationUtils flingAnimationUtils,
|
||||
@Named(SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_CLOSING)
|
||||
@@ -213,6 +224,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
||||
mCentralSurfaces = centralSurfaces;
|
||||
mScrimManager = scrimManager;
|
||||
mNotificationShadeWindowController = notificationShadeWindowController;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
mUserTracker = userTracker;
|
||||
mBouncerZoneScreenPercentage = swipeRegionPercentage;
|
||||
mFlingAnimationUtils = flingAnimationUtils;
|
||||
mFlingAnimationUtilsClosing = flingAnimationUtilsClosing;
|
||||
@@ -347,6 +360,11 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't set expansion if the user doesn't have a pin/password set.
|
||||
if (!mLockPatternUtils.isSecure(mUserTracker.getUserId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The animation utils deal in pixel units, rather than expansion height.
|
||||
final float viewHeight = mTouchSession.getBounds().height();
|
||||
final float currentHeight = viewHeight * mCurrentExpansion;
|
||||
|
||||
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
@@ -39,10 +40,12 @@ import android.view.VelocityTracker;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
|
||||
import com.android.systemui.dreams.touch.scrim.ScrimController;
|
||||
import com.android.systemui.dreams.touch.scrim.ScrimManager;
|
||||
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
|
||||
import com.android.systemui.settings.FakeUserTracker;
|
||||
import com.android.systemui.shade.ShadeExpansionChangeEvent;
|
||||
import com.android.systemui.shared.system.InputChannelCompat;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
@@ -57,6 +60,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
@SmallTest
|
||||
@@ -100,21 +104,34 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
UiEventLogger mUiEventLogger;
|
||||
|
||||
@Mock
|
||||
LockPatternUtils mLockPatternUtils;
|
||||
|
||||
FakeUserTracker mUserTracker;
|
||||
|
||||
private static final float TOUCH_REGION = .3f;
|
||||
private static final int SCREEN_WIDTH_PX = 1024;
|
||||
private static final int SCREEN_HEIGHT_PX = 100;
|
||||
|
||||
private static final Rect SCREEN_BOUNDS = new Rect(0, 0, 1024, 100);
|
||||
private static final UserInfo CURRENT_USER_INFO = new UserInfo(
|
||||
10,
|
||||
/* name= */ "user10",
|
||||
/* flags= */ 0
|
||||
);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mUserTracker = new FakeUserTracker();
|
||||
mTouchHandler = new BouncerSwipeTouchHandler(
|
||||
mScrimManager,
|
||||
Optional.of(mCentralSurfaces),
|
||||
mNotificationShadeWindowController,
|
||||
mValueAnimatorCreator,
|
||||
mVelocityTrackerFactory,
|
||||
mLockPatternUtils,
|
||||
mUserTracker,
|
||||
mFlingAnimationUtils,
|
||||
mFlingAnimationUtilsClosing,
|
||||
TOUCH_REGION,
|
||||
@@ -126,6 +143,9 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
|
||||
when(mVelocityTrackerFactory.obtain()).thenReturn(mVelocityTracker);
|
||||
when(mFlingAnimationUtils.getMinVelocityPxPerSecond()).thenReturn(Float.MAX_VALUE);
|
||||
when(mTouchSession.getBounds()).thenReturn(SCREEN_BOUNDS);
|
||||
when(mLockPatternUtils.isSecure(CURRENT_USER_INFO.id)).thenReturn(true);
|
||||
|
||||
mUserTracker.set(Collections.singletonList(CURRENT_USER_INFO), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,6 +285,32 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
|
||||
verifyScroll(.7f, Direction.DOWN, true, gestureListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure the expansion amount is proportional to (1 - scroll).
|
||||
*/
|
||||
@Test
|
||||
public void testSwipeUp_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;
|
||||
final MotionEvent event1 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE,
|
||||
0, SCREEN_HEIGHT_PX, 0);
|
||||
final MotionEvent event2 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE,
|
||||
0, SCREEN_HEIGHT_PX - distanceY, 0);
|
||||
|
||||
reset(mScrimController);
|
||||
assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
|
||||
.isTrue();
|
||||
// We should not expand since the keyguard is not secure
|
||||
verify(mScrimController, never()).expand(any());
|
||||
}
|
||||
|
||||
private void verifyScroll(float percent, Direction direction,
|
||||
boolean isBouncerInitiallyShowing, GestureDetector.OnGestureListener gestureListener) {
|
||||
final float distanceY = SCREEN_HEIGHT_PX * percent;
|
||||
|
||||
Reference in New Issue
Block a user