Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0118489d authored by Will Leshner's avatar Will Leshner
Browse files

Fix swiping up on hub when when security is swipe.

If security is set to 'swipe', then swiping up on the hub should dismiss
the hub and the underlying dream and go to launcher.

Bug: 346591916
Flag: com.android.systemui.communal_hub
Test: atest BouncerSwipeTouchHandlerTest

Change-Id: I0e6d1f6ab2f4113131fd988a8cf297d14da1592a
parent f7c8ac59
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -49,6 +50,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.ambient.touch.scrim.ScrimController;
import com.android.systemui.ambient.touch.scrim.ScrimManager;
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.settings.FakeUserTracker;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.shared.system.InputChannelCompat;
@@ -112,6 +114,9 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
    @Mock
    LockPatternUtils mLockPatternUtils;

    @Mock
    ActivityStarter mActivityStarter;

    @Mock
    Region mRegion;

@@ -148,7 +153,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
                mFlingAnimationUtilsClosing,
                TOUCH_REGION,
                MIN_BOUNCER_HEIGHT,
                mUiEventLogger);
                mUiEventLogger,
                mActivityStarter);

        when(mScrimManager.getCurrentController()).thenReturn(mScrimController);
        when(mValueAnimatorCreator.create(anyFloat(), anyFloat())).thenReturn(mValueAnimator);
@@ -397,7 +403,12 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
                .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.

        // Since we are swiping up, we should dismiss the keyguard and wake from dreams.
        ArgumentCaptor<Runnable> dismissKeyguardRunnable = ArgumentCaptor.forClass(Runnable.class);
        verify(mActivityStarter).executeRunnableDismissingKeyguard(
                dismissKeyguardRunnable.capture(), isNull(), eq(true), eq(true), eq(false));
        dismissKeyguardRunnable.getValue().run();
        verify(mCentralSurfaces).awakenDreams();
    }

+14 −5
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.systemui.ambient.touch.dagger.BouncerSwipeModule;
import com.android.systemui.ambient.touch.scrim.ScrimController;
import com.android.systemui.ambient.touch.scrim.ScrimManager;
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.statusbar.NotificationShadeWindowController;
@@ -103,6 +104,8 @@ public class BouncerSwipeTouchHandler implements TouchHandler {

    private final UiEventLogger mUiEventLogger;

    private final ActivityStarter mActivityStarter;

    private final ScrimManager.Callback mScrimManagerCallback = new ScrimManager.Callback() {
        @Override
        public void onScrimControllerChanged(ScrimController controller) {
@@ -149,11 +152,16 @@ public class BouncerSwipeTouchHandler implements TouchHandler {
                        return true;
                    }

                    // If scrolling up and keyguard is not locked, dismiss the dream since there's
                    // no bouncer to show.
                    // If scrolling up and keyguard is not locked, dismiss both keyguard and the
                    // dream since there's no bouncer to show.
                    if (e1.getY() > e2.getY()
                            && !mLockPatternUtils.isSecure(mUserTracker.getUserId())) {
                        mCentralSurfaces.get().awakenDreams();
                        mActivityStarter.executeRunnableDismissingKeyguard(
                                () -> mCentralSurfaces.get().awakenDreams(),
                                /* cancelAction= */ null,
                                /* dismissShade= */ true,
                                /* afterKeyguardGone= */ true,
                                /* deferred= */ false);
                        return true;
                    }

@@ -162,7 +170,6 @@ public class BouncerSwipeTouchHandler implements TouchHandler {
                    // bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer
                    // is fully hidden at full expansion (1) and fully visible when fully collapsed
                    // (0).
                    final float dragDownAmount = e2.getY() - e1.getY();
                    final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY())
                            / mTouchSession.getBounds().height();
                    setPanelExpansion(1 - screenTravelPercentage);
@@ -216,7 +223,8 @@ public class BouncerSwipeTouchHandler implements TouchHandler {
            FlingAnimationUtils flingAnimationUtilsClosing,
            @Named(BouncerSwipeModule.SWIPE_TO_BOUNCER_START_REGION) float swipeRegionPercentage,
            @Named(BouncerSwipeModule.MIN_BOUNCER_ZONE_SCREEN_PERCENTAGE) float minRegionPercentage,
            UiEventLogger uiEventLogger) {
            UiEventLogger uiEventLogger,
            ActivityStarter activityStarter) {
        mCentralSurfaces = centralSurfaces;
        mScrimManager = scrimManager;
        mNotificationShadeWindowController = notificationShadeWindowController;
@@ -229,6 +237,7 @@ public class BouncerSwipeTouchHandler implements TouchHandler {
        mValueAnimatorCreator = valueAnimatorCreator;
        mVelocityTrackerFactory = velocityTrackerFactory;
        mUiEventLogger = uiEventLogger;
        mActivityStarter = activityStarter;
    }

    @Override