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

Commit ddb13c39 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Revert "Route dream touch handling to scene container"

This reverts commit fb1033cb.

Reason for revert: test failures b/375308919

Change-Id: Ib4f0d61cc5f309815a7c9d0b73a795ed5bdcc5fb
parent fb1033cb
Loading
Loading
Loading
Loading
+3 −64
Original line number Diff line number Diff line
@@ -20,9 +20,7 @@ import static com.google.common.truth.Truth.assertThat;

import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -31,12 +29,11 @@ import android.content.pm.UserInfo;
import android.graphics.Rect;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.FlagsParameterization;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.VelocityTracker;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.internal.logging.UiEventLogger;
@@ -45,12 +42,9 @@ 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.communal.ui.viewmodel.CommunalViewModel;
import com.android.systemui.flags.SceneContainerFlagParameterizationKt;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.scene.domain.interactor.SceneInteractor;
import com.android.systemui.scene.ui.view.WindowRootView;
import com.android.systemui.shared.system.InputChannelCompat;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
@@ -64,14 +58,10 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.List;
import java.util.Optional;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

@SmallTest
@RunWith(ParameterizedAndroidJunit4.class)
@RunWith(AndroidJUnit4.class)
@EnableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
@DisableFlags(Flags.FLAG_COMMUNAL_BOUNCER_DO_NOT_MODIFY_PLUGIN_OPEN)
public class BouncerFullscreenSwipeTouchHandlerTest extends SysuiTestCase {
@@ -124,11 +114,6 @@ public class BouncerFullscreenSwipeTouchHandlerTest extends SysuiTestCase {
    @Mock
    KeyguardInteractor mKeyguardInteractor;

    @Mock
    WindowRootView mWindowRootView;

    private SceneInteractor mSceneInteractor;

    private static final float TOUCH_REGION = .3f;
    private static final float MIN_BOUNCER_HEIGHT = .05f;

@@ -139,21 +124,9 @@ public class BouncerFullscreenSwipeTouchHandlerTest extends SysuiTestCase {
            /* flags= */ 0
    );

    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return SceneContainerFlagParameterizationKt.parameterizeSceneContainerFlag();
    }

    public BouncerFullscreenSwipeTouchHandlerTest(FlagsParameterization flags) {
        super();
        mSetFlagsRule.setFlagsParameterization(flags);
    }

    @Before
    public void setup() {
        mKosmos = new KosmosJavaAdapter(this);
        mSceneInteractor = spy(mKosmos.getSceneInteractor());

        MockitoAnnotations.initMocks(this);
        mTouchHandler = new BouncerSwipeTouchHandler(
                mKosmos.getTestScope(),
@@ -169,9 +142,7 @@ public class BouncerFullscreenSwipeTouchHandlerTest extends SysuiTestCase {
                MIN_BOUNCER_HEIGHT,
                mUiEventLogger,
                mActivityStarter,
                mKeyguardInteractor,
                mSceneInteractor,
                Optional.of(() -> mWindowRootView));
                mKeyguardInteractor);

        when(mScrimManager.getCurrentController()).thenReturn(mScrimController);
        when(mValueAnimatorCreator.create(anyFloat(), anyFloat())).thenReturn(mValueAnimator);
@@ -181,38 +152,6 @@ public class BouncerFullscreenSwipeTouchHandlerTest extends SysuiTestCase {
        when(mKeyguardInteractor.isKeyguardDismissible()).thenReturn(MutableStateFlow(false));
    }

    /**
     * Makes sure that touches go to the scene container when the flag is on.
     */
    @Test
    @EnableFlags(Flags.FLAG_SCENE_CONTAINER)
    public void testSwipeUp_sendsTouchesToWindowRootView() {
        mTouchHandler.onGlanceableTouchAvailable(true);
        mTouchHandler.onSessionStart(mTouchSession);
        ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor =
                ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class);
        verify(mTouchSession).registerGestureListener(gestureListenerCaptor.capture());

        final OnGestureListener gestureListener = gestureListenerCaptor.getValue();

        final int screenHeight = 100;
        final float distanceY = screenHeight * 0.42f;

        final MotionEvent event1 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE,
                0, screenHeight, 0);
        final MotionEvent event2 = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE,
                0, screenHeight - distanceY, 0);

        assertThat(gestureListener.onScroll(event1, event2, 0,
                distanceY))
                .isTrue();

        // Ensure only called once
        verify(mSceneInteractor).onRemoteUserInputStarted(any());
        verify(mWindowRootView).dispatchTouchEvent(event1);
        verify(mWindowRootView).dispatchTouchEvent(event2);
    }

    /**
     * Ensures expansion does not happen for full vertical swipes when touch is not available.
     */
+3 −65
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ 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.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@@ -38,12 +37,12 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.FlagsParameterization;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.VelocityTracker;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.internal.logging.UiEventLogger;
@@ -53,12 +52,9 @@ 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.communal.ui.viewmodel.CommunalViewModel;
import com.android.systemui.flags.SceneContainerFlagParameterizationKt;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.scene.domain.interactor.SceneInteractor;
import com.android.systemui.scene.ui.view.WindowRootView;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.shared.system.InputChannelCompat;
import com.android.systemui.statusbar.NotificationShadeWindowController;
@@ -74,14 +70,10 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.List;
import java.util.Optional;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

@SmallTest
@RunWith(ParameterizedAndroidJunit4.class)
@RunWith(AndroidJUnit4.class)
@DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
    private KosmosJavaAdapter mKosmos;
@@ -129,9 +121,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
    @Mock
    Region mRegion;

    @Mock
    WindowRootView mWindowRootView;

    @Mock
    CommunalViewModel mCommunalViewModel;

@@ -141,8 +130,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
    @Captor
    ArgumentCaptor<Rect> mRectCaptor;

    private SceneInteractor mSceneInteractor;

    private static final float TOUCH_REGION = .3f;
    private static final int SCREEN_WIDTH_PX = 1024;
    private static final int SCREEN_HEIGHT_PX = 100;
@@ -155,21 +142,9 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
            /* flags= */ 0
    );

    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return SceneContainerFlagParameterizationKt.parameterizeSceneContainerFlag();
    }

    public BouncerSwipeTouchHandlerTest(FlagsParameterization flags) {
        super();
        mSetFlagsRule.setFlagsParameterization(flags);
    }

    @Before
    public void setup() {
        mKosmos = new KosmosJavaAdapter(this);
        mSceneInteractor = spy(mKosmos.getSceneInteractor());

        MockitoAnnotations.initMocks(this);
        mTouchHandler = new BouncerSwipeTouchHandler(
                mKosmos.getTestScope(),
@@ -185,10 +160,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
                MIN_BOUNCER_HEIGHT,
                mUiEventLogger,
                mActivityStarter,
                mKeyguardInteractor,
                mSceneInteractor,
                Optional.of(() -> mWindowRootView)
        );
                mKeyguardInteractor);

        when(mScrimManager.getCurrentController()).thenReturn(mScrimController);
        when(mValueAnimatorCreator.create(anyFloat(), anyFloat())).thenReturn(mValueAnimator);
@@ -395,7 +367,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
     * Makes sure the expansion amount is proportional to (1 - scroll).
     */
    @Test
    @DisableFlags(Flags.FLAG_SCENE_CONTAINER)
    public void testSwipeUp_setsCorrectExpansionAmount() {
        mTouchHandler.onSessionStart(mTouchSession);
        ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor =
@@ -408,36 +379,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        verifyScroll(.7f, gestureListener);
    }

    /**
     * Makes sure that touches go to the scene container when the flag is on.
     */
    @Test
    @EnableFlags(Flags.FLAG_SCENE_CONTAINER)
    public void testSwipeUp_sendsTouchesToWindowRootView() {
        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.42f;

        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);

        assertThat(gestureListener.onScroll(event1, event2, 0,
                distanceY))
                .isTrue();

        // Ensure only called once
        verify(mSceneInteractor).onRemoteUserInputStarted(any());
        verify(mWindowRootView).dispatchTouchEvent(event1);
        verify(mWindowRootView).dispatchTouchEvent(event2);
    }

    /**
     * Verifies that swiping up when the lock pattern is not secure dismissed dream and consumes
     * the gesture.
@@ -535,7 +476,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
     * Tests that ending an upward swipe before the set threshold leads to bouncer collapsing down.
     */
    @Test
    @DisableFlags(Flags.FLAG_SCENE_CONTAINER)
    public void testSwipeUpPositionBelowThreshold_collapsesBouncer() {
        final float swipeUpPercentage = .3f;
        final float expansion = 1 - swipeUpPercentage;
@@ -559,7 +499,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
     * Tests that ending an upward swipe above the set threshold will continue the expansion.
     */
    @Test
    @DisableFlags(Flags.FLAG_SCENE_CONTAINER)
    public void testSwipeUpPositionAboveThreshold_expandsBouncer() {
        final float swipeUpPercentage = .7f;
        final float expansion = 1 - swipeUpPercentage;
@@ -589,7 +528,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
     * Tests that swiping up with a speed above the set threshold will continue the expansion.
     */
    @Test
    @DisableFlags(Flags.FLAG_SCENE_CONTAINER)
    public void testSwipeUpVelocityAboveMin_expandsBouncer() {
        when(mFlingAnimationUtils.getMinVelocityPxPerSecond()).thenReturn((float) 0);

+10 −75
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@ package com.android.systemui.ambient.touch
import android.app.DreamManager
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.view.GestureDetector
import android.view.MotionEvent
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
@@ -28,20 +28,14 @@ import com.android.systemui.ambient.touch.TouchHandler.TouchSession
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.andSceneContainer
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.data.repository.sceneContainerRepository
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.ui.view.WindowRootView
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shared.system.InputChannelCompat
import com.android.systemui.statusbar.phone.CentralSurfaces
import com.android.systemui.testKosmos
import com.google.common.truth.Truth
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import javax.inject.Provider
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -53,29 +47,22 @@ import org.mockito.kotlin.never
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters

@SmallTest
@RunWith(ParameterizedAndroidJunit4::class)
class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {
@RunWith(AndroidJUnit4::class)
class ShadeTouchHandlerTest : SysuiTestCase() {
    private var kosmos = testKosmos()
    private var mCentralSurfaces = mock<CentralSurfaces>()
    private var mShadeViewController = mock<ShadeViewController>()
    private var mDreamManager = mock<DreamManager>()
    private var mTouchSession = mock<TouchSession>()
    private var communalViewModel = mock<CommunalViewModel>()
    private var windowRootView = mock<WindowRootView>()

    private lateinit var mTouchHandler: ShadeTouchHandler

    private var mGestureListenerCaptor = argumentCaptor<GestureDetector.OnGestureListener>()
    private var mInputListenerCaptor = argumentCaptor<InputChannelCompat.InputEventListener>()

    init {
        mSetFlagsRule.setFlagsParameterization(flags)
    }

    @Before
    fun setup() {
        mTouchHandler =
@@ -86,9 +73,7 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {
                mDreamManager,
                communalViewModel,
                kosmos.communalSettingsInteractor,
                kosmos.sceneInteractor,
                Optional.of(Provider<WindowRootView> { windowRootView }),
                TOUCH_HEIGHT,
                TOUCH_HEIGHT
            )
    }

@@ -112,7 +97,7 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {

    // Verifies that a swipe down forwards captured touches to central surfaces for handling.
    @Test
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX, Flags.FLAG_SCENE_CONTAINER)
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    fun testSwipeDown_communalEnabled_sentToCentralSurfaces() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)
@@ -125,11 +110,7 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {

    // Verifies that a swipe down forwards captured touches to the shade view for handling.
    @Test
    @DisableFlags(
        Flags.FLAG_COMMUNAL_HUB,
        Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX,
        Flags.FLAG_SCENE_CONTAINER,
    )
    @DisableFlags(Flags.FLAG_COMMUNAL_HUB, Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    fun testSwipeDown_communalDisabled_sentToShadeView() {
        swipe(Direction.DOWN)

@@ -140,7 +121,7 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {
    // Verifies that a swipe down while dreaming forwards captured touches to the shade view for
    // handling.
    @Test
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX, Flags.FLAG_SCENE_CONTAINER)
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    fun testSwipeDown_dreaming_sentToShadeView() {
        whenever(mDreamManager.isDreaming).thenReturn(true)
        swipe(Direction.DOWN)
@@ -149,34 +130,9 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {
        verify(mShadeViewController, times(2)).handleExternalTouch(any())
    }

    // Verifies that a swipe down forwards captured touches to the window root view for handling.
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB, Flags.FLAG_SCENE_CONTAINER)
    fun testSwipeDown_sceneContainerEnabled_sentToWindowRootView() {
        swipe(Direction.DOWN)

        // Both motion events are sent for central surfaces to process.
        assertThat(kosmos.sceneContainerRepository.isRemoteUserInputOngoing.value).isTrue()
        verify(windowRootView, times(2)).dispatchTouchEvent(any())
    }

    // Verifies that a swipe down while dreaming forwards captured touches to the window root view
    // for handling.
    @Test
    @EnableFlags(Flags.FLAG_SCENE_CONTAINER)
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    fun testSwipeDown_dreaming_sentToWindowRootView() {
        whenever(mDreamManager.isDreaming).thenReturn(true)
        swipe(Direction.DOWN)

        // Both motion events are sent for the shade view to process.
        assertThat(kosmos.sceneContainerRepository.isRemoteUserInputOngoing.value).isTrue()
        verify(windowRootView, times(2)).dispatchTouchEvent(any())
    }

    // Verifies that a swipe up is not forwarded to central surfaces.
    @Test
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX, Flags.FLAG_SCENE_CONTAINER)
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB)
    fun testSwipeUp_communalEnabled_touchesNotSent() {
        kosmos.fakeFeatureFlagsClassic.set(COMMUNAL_SERVICE_ENABLED, true)
@@ -190,11 +146,7 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {

    // Verifies that a swipe up is not forwarded to the shade view.
    @Test
    @DisableFlags(
        Flags.FLAG_COMMUNAL_HUB,
        Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX,
        Flags.FLAG_SCENE_CONTAINER,
    )
    @DisableFlags(Flags.FLAG_COMMUNAL_HUB, Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    fun testSwipeUp_communalDisabled_touchesNotSent() {
        swipe(Direction.UP)

@@ -203,17 +155,6 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {
        verify(mShadeViewController, never()).handleExternalTouch(any())
    }

    // Verifies that a swipe up is not forwarded to the window root view.
    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_HUB, Flags.FLAG_SCENE_CONTAINER)
    fun testSwipeUp_sceneContainerEnabled_touchesNotSent() {
        swipe(Direction.UP)

        // Motion events are not sent for window root view to process as the swipe is going in the
        // wrong direction.
        verify(windowRootView, never()).dispatchTouchEvent(any())
    }

    @Test
    @DisableFlags(Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX)
    fun testCancelMotionEvent_popsTouchSession() {
@@ -302,16 +243,10 @@ class ShadeTouchHandlerTest(flags: FlagsParameterization) : SysuiTestCase() {

    private enum class Direction {
        DOWN,
        UP,
        UP
    }

    companion object {
        private const val TOUCH_HEIGHT = 20

        @JvmStatic
        @Parameters(name = "{0}")
        fun getParams(): List<FlagsParameterization> {
            return FlagsParameterization.allCombinationsOf().andSceneContainer()
        }
    }
}
+14 −34
Original line number Diff line number Diff line
@@ -38,9 +38,6 @@ import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.ui.view.WindowRootView
import com.android.systemui.shade.ShadeExpansionChangeEvent
import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.statusbar.phone.CentralSurfaces
@@ -48,7 +45,6 @@ import com.android.wm.shell.animation.FlingAnimationUtils
import java.util.Optional
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Provider
import kotlin.math.abs
import kotlin.math.hypot
import kotlin.math.max
@@ -78,8 +74,6 @@ constructor(
    private val uiEventLogger: UiEventLogger,
    private val activityStarter: ActivityStarter,
    private val keyguardInteractor: KeyguardInteractor,
    private val sceneInteractor: SceneInteractor,
    private val windowRootViewProvider: Optional<Provider<WindowRootView>>,
) : TouchHandler {
    /** An interface for creating ValueAnimators. */
    interface ValueAnimatorCreator {
@@ -106,8 +100,6 @@ constructor(
            currentScrimController = controller
        }

    private val windowRootView by lazy { windowRootViewProvider.get().get() }

    /** Determines whether the touch handler should process touches in fullscreen swiping mode */
    private var touchAvailable = false

@@ -117,7 +109,7 @@ constructor(
                e1: MotionEvent?,
                e2: MotionEvent,
                distanceX: Float,
                distanceY: Float,
                distanceY: Float
            ): Boolean {
                if (capture == null) {
                    capture =
@@ -136,11 +128,6 @@ constructor(
                        expanded = false
                        // Since the user is dragging the bouncer up, set scrimmed to false.
                        currentScrimController?.show()

                        if (SceneContainerFlag.isEnabled) {
                            sceneInteractor.onRemoteUserInputStarted("bouncer touch handler")
                            e1?.apply { windowRootView.dispatchTouchEvent(e1) }
                        }
                    }
                }
                if (capture != true) {
@@ -165,29 +152,22 @@ constructor(
                            /* cancelAction= */ null,
                            /* dismissShade= */ true,
                            /* afterKeyguardGone= */ true,
                            /* deferred= */ false,
                            /* deferred= */ false
                        )
                        return true
                    }

                    if (SceneContainerFlag.isEnabled) {
                        windowRootView.dispatchTouchEvent(e2)
                    } else {
                    // 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
                        // is fully hidden at full expansion (1) and fully visible when fully
                        // collapsed
                    // 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).
                    touchSession?.apply {
                        val screenTravelPercentage =
                                (abs((this@outer.y - e2.y).toDouble()) / getBounds().height())
                                    .toFloat()
                            (abs((this@outer.y - e2.y).toDouble()) / getBounds().height()).toFloat()
                        setPanelExpansion(1 - screenTravelPercentage)
                    }
                }
                }

                return true
            }
@@ -214,7 +194,7 @@ constructor(
            ShadeExpansionChangeEvent(
                /* fraction= */ currentExpansion,
                /* expanded= */ expanded,
                /* tracking= */ true,
                /* tracking= */ true
            )
        currentScrimController?.expand(event)
    }
@@ -367,7 +347,7 @@ constructor(
                    currentHeight,
                    targetHeight,
                    velocity,
                    viewHeight,
                    viewHeight
                )
            } else {
                // Shows the bouncer, i.e., fully collapses the space above the bouncer.
@@ -376,7 +356,7 @@ constructor(
                    currentHeight,
                    targetHeight,
                    velocity,
                    viewHeight,
                    viewHeight
                )
            }
            animator.start()
+3 −20

File changed.

Preview size limit exceeded, changes collapsed.

Loading