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

Commit 13aa7104 authored by Robin Lee's avatar Robin Lee Committed by Automerger Merge Worker
Browse files

Merge changes from topic "keyguard-occlude-race-transitions" into udc-dev am: a3bd224e

parents 1f8576f5 a3bd224e
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.flags.SystemPropertiesHelper;
import com.android.systemui.keyguard.dagger.KeyguardModule;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.navigationbar.NavigationModeController;
@@ -538,6 +539,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

    private CentralSurfaces mCentralSurfaces;

    private IRemoteAnimationFinishedCallback mUnoccludeFromDreamFinishedCallback;

    private final DeviceConfig.OnPropertiesChangedListener mOnPropertiesChangedListener =
            new DeviceConfig.OnPropertiesChangedListener() {
            @Override
@@ -1164,6 +1167,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                            getRemoteSurfaceAlphaApplier().accept(0.0f);
                            mDreamingToLockscreenTransitionViewModel.get()
                                    .startTransition();
                            mUnoccludeFromDreamFinishedCallback = finishedCallback;
                            return;
                        }

@@ -1243,6 +1247,19 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        };
    }

    private Consumer<TransitionStep> getFinishedCallbackConsumer() {
        return (TransitionStep step) -> {
            if (mUnoccludeFromDreamFinishedCallback == null) return;
            try {
                mUnoccludeFromDreamFinishedCallback.onAnimationFinished();
                mUnoccludeFromDreamFinishedCallback = null;
            } catch (RemoteException e) {
                Log.e(TAG, "Wasn't able to callback", e);
            }
            mInteractionJankMonitor.end(CUJ_LOCKSCREEN_OCCLUSION);
        };
    }

    private DeviceConfigProxy mDeviceConfig;
    private DozeParameters mDozeParameters;

@@ -1502,6 +1519,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                collectFlow(viewRootImpl.getView(),
                        mDreamingToLockscreenTransitionViewModel.get().getDreamOverlayAlpha(),
                        getRemoteSurfaceAlphaApplier(), mMainDispatcher);
                collectFlow(viewRootImpl.getView(),
                        mDreamingToLockscreenTransitionViewModel.get().getTransitionEnded(),
                        getFinishedCallbackConsumer(), mMainDispatcher);
            }
        }
        // Most services aren't available until the system reaches the ready state, so we
+6 −2
Original line number Diff line number Diff line
@@ -49,11 +49,15 @@ constructor(
) {
    /** (any)->GONE transition information */
    val anyStateToGoneTransition: Flow<TransitionStep> =
        repository.transitions.filter { step -> step.to == KeyguardState.GONE }
        repository.transitions.filter { step -> step.to == GONE }

    /** (any)->AOD transition information */
    val anyStateToAodTransition: Flow<TransitionStep> =
        repository.transitions.filter { step -> step.to == KeyguardState.AOD }
        repository.transitions.filter { step -> step.to == AOD }

    /** DREAMING->(any) transition information. */
    val fromDreamingTransition: Flow<TransitionStep> =
        repository.transitions.filter { step -> step.from == DREAMING }

    /** AOD->LOCKSCREEN transition information. */
    val aodToLockscreenTransition: Flow<TransitionStep> = repository.transition(AOD, LOCKSCREEN)
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ constructor(
        )

    val transitionEnded =
        keyguardTransitionInteractor.dreamingToLockscreenTransition.filter { step ->
        keyguardTransitionInteractor.fromDreamingTransition.filter { step ->
            step.transitionState == TransitionState.FINISHED ||
                step.transitionState == TransitionState.CANCELED
        }
+2 −0
Original line number Diff line number Diff line
@@ -186,6 +186,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        when(mStatusBarKeyguardViewManager.getViewRootImpl()).thenReturn(testViewRoot);
        when(mDreamingToLockscreenTransitionViewModel.getDreamOverlayAlpha())
                .thenReturn(mock(Flow.class));
        when(mDreamingToLockscreenTransitionViewModel.getTransitionEnded())
                .thenReturn(mock(Flow.class));
        mNotificationShadeWindowController = new NotificationShadeWindowControllerImpl(mContext,
                mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
                mConfigurationController, mViewMediator, mKeyguardBypassController,
+50 −11
Original line number Diff line number Diff line
@@ -22,8 +22,16 @@ import com.android.systemui.RoboPilotTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING
import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionState.CANCELED
import com.android.systemui.keyguard.shared.model.TransitionState.FINISHED
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.util.mockito.mock
import com.google.common.collect.Range
@@ -60,7 +68,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
            val job =
                underTest.dreamOverlayTranslationY(pixels).onEach { values.add(it) }.launchIn(this)

            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            repository.sendTransitionStep(step(0f, STARTED))
            repository.sendTransitionStep(step(0f))
            repository.sendTransitionStep(step(0.3f))
            repository.sendTransitionStep(step(0.5f))
@@ -82,7 +90,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
            val job = underTest.dreamOverlayAlpha.onEach { values.add(it) }.launchIn(this)

            // Should start running here...
            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            repository.sendTransitionStep(step(0f, STARTED))
            repository.sendTransitionStep(step(0f))
            repository.sendTransitionStep(step(0.1f))
            repository.sendTransitionStep(step(0.5f))
@@ -104,7 +112,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {

            val job = underTest.lockscreenAlpha.onEach { values.add(it) }.launchIn(this)

            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            repository.sendTransitionStep(step(0f, STARTED))
            repository.sendTransitionStep(step(0f))
            repository.sendTransitionStep(step(0.1f))
            repository.sendTransitionStep(step(0.2f))
@@ -126,7 +134,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
            val job =
                underTest.lockscreenTranslationY(pixels).onEach { values.add(it) }.launchIn(this)

            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            repository.sendTransitionStep(step(0f, STARTED))
            repository.sendTransitionStep(step(0f))
            repository.sendTransitionStep(step(0.3f))
            repository.sendTransitionStep(step(0.5f))
@@ -138,13 +146,44 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
            job.cancel()
        }

    private fun step(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
    ): TransitionStep {
    @Test
    fun transitionEnded() =
        runTest(UnconfinedTestDispatcher()) {
            val values = mutableListOf<TransitionStep>()

            val job = underTest.transitionEnded.onEach { values.add(it) }.launchIn(this)

            repository.sendTransitionStep(TransitionStep(DOZING, DREAMING, 0.0f, STARTED))
            repository.sendTransitionStep(TransitionStep(DOZING, DREAMING, 1.0f, FINISHED))

            repository.sendTransitionStep(TransitionStep(DREAMING, LOCKSCREEN, 0.0f, STARTED))
            repository.sendTransitionStep(TransitionStep(DREAMING, LOCKSCREEN, 0.1f, RUNNING))
            repository.sendTransitionStep(TransitionStep(DREAMING, LOCKSCREEN, 1.0f, FINISHED))

            repository.sendTransitionStep(TransitionStep(LOCKSCREEN, DREAMING, 0.0f, STARTED))
            repository.sendTransitionStep(TransitionStep(LOCKSCREEN, DREAMING, 0.5f, RUNNING))
            repository.sendTransitionStep(TransitionStep(LOCKSCREEN, DREAMING, 1.0f, FINISHED))

            repository.sendTransitionStep(TransitionStep(DREAMING, GONE, 0.0f, STARTED))
            repository.sendTransitionStep(TransitionStep(DREAMING, GONE, 0.5f, RUNNING))
            repository.sendTransitionStep(TransitionStep(DREAMING, GONE, 1.0f, CANCELED))

            repository.sendTransitionStep(TransitionStep(DREAMING, AOD, 0.0f, STARTED))
            repository.sendTransitionStep(TransitionStep(DREAMING, AOD, 1.0f, FINISHED))

            assertThat(values.size).isEqualTo(3)
            values.forEach {
                assertThat(it.transitionState == FINISHED || it.transitionState == CANCELED)
                    .isTrue()
            }

            job.cancel()
        }

    private fun step(value: Float, state: TransitionState = RUNNING): TransitionStep {
        return TransitionStep(
            from = KeyguardState.DREAMING,
            to = KeyguardState.LOCKSCREEN,
            from = DREAMING,
            to = LOCKSCREEN,
            value = value,
            transitionState = state,
            ownerName = "DreamingToLockscreenTransitionViewModelTest"
Loading