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

Commit 98a3a75f authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Flexiglass: visual stability on lockscreen

Pre-Flexiglass, the notion of "panel expanded" included when the stack
was visible on the lockscreen but the shade wasn't actually expanded.

Under Flexiglass, "panel expanded" means, literally, that the panel is
expanded, and is therefore *false* on the lockscreen.

Unfortunately, VisualStabilityCoordinator was relying on that as a
signal for when to enforce stability. Therefore, fix it to listen for
the lockscreen scene (using KeyguardTransitionInteractor) as well.

Bug: 332558345
Test: manual: turn on Flexi, turn on VisualStability logs, turn screen off and on
Flag: com.android.systemui.scene_container
Change-Id: I1d38dd580a95006159380e7ebb4b1876b5c27805
parent a1568c29
Loading
Loading
Loading
Loading
+68 −1
Original line number Diff line number Diff line
@@ -41,8 +41,12 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.communal.shared.model.CommunalScenes;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.keyguard.shared.model.TransitionState;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.data.repository.FakeShadeRepository;
import com.android.systemui.shade.data.repository.ShadeAnimationRepository;
import com.android.systemui.shade.data.repository.ShadeRepository;
@@ -130,6 +134,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
                mVisualStabilityProvider,
                mWakefulnessLifecycle,
                mKosmos.getCommunalInteractor(),
                mKosmos.getKeyguardTransitionInteractor(),
                mLogger);
        mCoordinator.attach(mNotifPipeline);
        mTestScope.getTestScheduler().runCurrent();
@@ -242,6 +247,38 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
        assertFalse(mNotifStabilityManager.isSectionChangeAllowed(mEntry));
    }

    @Test
    public void testLockscreenPartlyShowing_groupAndSectionChangesNotAllowed() {
        // GIVEN the panel true expanded and device isn't pulsing
        setFullyDozed(false);
        setSleepy(false);
        setLockscreenShowing(0.5f);
        setPulsing(false);

        // THEN group changes are NOT allowed
        assertFalse(mNotifStabilityManager.isGroupChangeAllowed(mEntry));
        assertFalse(mNotifStabilityManager.isGroupPruneAllowed(mGroupEntry));

        // THEN section changes are NOT allowed
        assertFalse(mNotifStabilityManager.isSectionChangeAllowed(mEntry));
    }

    @Test
    public void testLockscreenFullyShowing_groupAndSectionChangesNotAllowed() {
        // GIVEN the panel true expanded and device isn't pulsing
        setFullyDozed(false);
        setSleepy(false);
        setLockscreenShowing(1.0f);
        setPulsing(false);

        // THEN group changes are NOT allowed
        assertFalse(mNotifStabilityManager.isGroupChangeAllowed(mEntry));
        assertFalse(mNotifStabilityManager.isGroupPruneAllowed(mGroupEntry));

        // THEN section changes are NOT allowed
        assertFalse(mNotifStabilityManager.isSectionChangeAllowed(mEntry));
    }

    @Test
    public void testPulsing_screenOff_groupAndSectionChangesNotAllowed() {
        // GIVEN the device is pulsing and screen is off
@@ -616,7 +653,37 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase {
    }

    private void setPanelExpanded(boolean expanded) {
        mStatusBarStateListener.onExpandedChanged(expanded);
        setPanelExpandedAndLockscreenShowing(expanded, /* lockscreenShowing = */ 0.0f);
    }

    private void setLockscreenShowing(float lockscreenShowing) {
        setPanelExpandedAndLockscreenShowing(/* panelExpanded = */ false, lockscreenShowing);
    }

    private void setPanelExpandedAndLockscreenShowing(boolean panelExpanded,
            float lockscreenShowing) {
        if (SceneContainerFlag.isEnabled()) {
            mStatusBarStateListener.onExpandedChanged(panelExpanded);
            mKosmos.getKeyguardTransitionRepository().sendTransitionStepJava(
                    mTestScope,
                    makeLockscreenTransitionStep(lockscreenShowing),
                    /* validateStep = */ false);
        } else {
            mStatusBarStateListener.onExpandedChanged(panelExpanded || lockscreenShowing > 0.0f);
        }
    }

    private TransitionStep makeLockscreenTransitionStep(float value) {
        if (value <= 0.0f) {
            return new TransitionStep(KeyguardState.GONE);
        } else if (value >= 1.0f) {
            return new TransitionStep(KeyguardState.LOCKSCREEN);
        } else {
            return new TransitionStep(
                    KeyguardState.GONE,
                    KeyguardState.LOCKSCREEN,
                    value,
                    TransitionState.RUNNING);
        }
    }
}
+23 −1
Original line number Diff line number Diff line
@@ -27,7 +27,10 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractor;
import com.android.systemui.statusbar.notification.VisibilityLocationProvider;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
@@ -68,6 +71,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
    private final VisualStabilityProvider mVisualStabilityProvider;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private final CommunalInteractor mCommunalInteractor;
    private final KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    private final VisualStabilityCoordinatorLogger mLogger;

    private boolean mSleepy = true;
@@ -77,6 +81,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
    private boolean mNotifPanelCollapsing;
    private boolean mNotifPanelLaunchingActivity;
    private boolean mCommunalShowing = false;
    private boolean mLockscreenShowing = false;

    private boolean mPipelineRunAllowed;
    private boolean mReorderingAllowed;
@@ -106,6 +111,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
            VisualStabilityProvider visualStabilityProvider,
            WakefulnessLifecycle wakefulnessLifecycle,
            CommunalInteractor communalInteractor,
            KeyguardTransitionInteractor keyguardTransitionInteractor,
            VisualStabilityCoordinatorLogger logger) {
        mHeadsUpManager = headsUpManager;
        mShadeAnimationInteractor = shadeAnimationInteractor;
@@ -117,6 +123,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
        mStatusBarStateController = statusBarStateController;
        mDelayableExecutor = delayableExecutor;
        mCommunalInteractor = communalInteractor;
        mKeyguardTransitionInteractor = keyguardTransitionInteractor;
        mLogger = logger;

        dumpManager.registerDumpable(this);
@@ -136,6 +143,9 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
                this::onLaunchingActivityChanged);
        mJavaAdapter.alwaysCollectFlow(mCommunalInteractor.isIdleOnCommunal(),
                this::onCommunalShowingChanged);
        mJavaAdapter.alwaysCollectFlow(mKeyguardTransitionInteractor.transitionValue(
                        KeyguardState.LOCKSCREEN),
                this::onLockscreenKeyguardStateTransitionValueChanged);

        pipeline.setVisualStabilityManager(mNotifStabilityManager);
    }
@@ -249,7 +259,9 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
    }

    private boolean isReorderingAllowed() {
        return ((mFullyDozed && mSleepy) || !mPanelExpanded || mCommunalShowing) && !mPulsing;
        final boolean sleepyAndDozed = mFullyDozed && mSleepy;
        final boolean stackShowing = mPanelExpanded || mLockscreenShowing;
        return (sleepyAndDozed || !stackShowing || mCommunalShowing) && !mPulsing;
    }

    /**
@@ -362,4 +374,14 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable {
        mCommunalShowing = isShowing;
        updateAllowedStates("communalShowing", isShowing);
    }

    private void onLockscreenKeyguardStateTransitionValueChanged(float value) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) {
            return;
        }

        final boolean isShowing = value > 0.0f;
        mLockscreenShowing = isShowing;
        updateAllowedStates("lockscreenShowing", isShowing);
    }
}