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

Commit e10a48e3 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Fix flicker in taskbar visibility when shade moves display

SysUI was telling to launcher the shade was visible in the old display when the expansion on an external display happened.
This was triggering the taskbar to become invisible for a few frames, and then return visible on the default display.

By using the shade repository pending id we can immediately propagate the SysUIState for the correct display

Bug: 362719719
Bug: 398011576
Test: NotificationPanelViewControllerTest
Flag: com.android.systemui.shade_window_goes_around
Change-Id: I7eab3284acf9b295d32fd2c0802974e1cc562611
parent b7e21647
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -598,7 +598,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
                mKeyguardClockPositionAlgorithm,
                mMSDLPlayer,
                mBrightnessMirrorShowingRepository,
                new BlurConfig(0f, 0f));
                new BlurConfig(0f, 0f),
                () -> mKosmos.getFakeShadeDisplaysRepository());
        mNotificationPanelViewController.initDependencies(
                mCentralSurfaces,
                null,
+1 −3
Original line number Diff line number Diff line
@@ -195,9 +195,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo
    @EnableFlags(Flags.FLAG_SHADE_WINDOW_GOES_AROUND)
    public void updateSystemUiStateFlags_updatesSysuiStateInteractor() {
        var DISPLAY_ID = 10;
        var displayMock = display(TYPE_INTERNAL, /* flags= */ 0, /* id= */DISPLAY_ID,
                /* state= */ null);
        when(mView.getDisplay()).thenReturn(displayMock);
        mKosmos.getFakeShadeDisplaysRepository().setPendingDisplayId(DISPLAY_ID);

        mNotificationPanelViewController.updateSystemUiStateFlags();

+2 −1
Original line number Diff line number Diff line
@@ -830,7 +830,8 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
    private void notifySystemUiStateFlags(@SystemUiStateFlags long flags, int displayId) {
        if (SysUiState.DEBUG) {
            Log.d(TAG_OPS, "Notifying sysui state change to launcher service: proxy="
                    + mLauncherProxy + " flags=" + flags + " displayId=" + displayId);
                    + mLauncherProxy + " display=" + displayId + " flags="
                    + QuickStepContract.getSystemUiStateString(flags) + " displayId=" + displayId);
        }
        try {
            if (mLauncherProxy != null) {
+18 −4
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.settings.brightness.data.repository.BrightnessMirrorShowingRepository;
import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor;
import com.android.systemui.shade.data.repository.FlingInfo;
import com.android.systemui.shade.data.repository.ShadeDisplaysRepository;
import com.android.systemui.shade.data.repository.ShadeRepository;
import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractor;
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround;
@@ -204,6 +205,7 @@ import dalvik.annotation.optimization.NeverCompile;
import com.google.android.msdl.data.model.MSDLToken;
import com.google.android.msdl.domain.MSDLPlayer;

import dagger.Lazy;
import kotlin.Unit;

import kotlinx.coroutines.CoroutineDispatcher;
@@ -456,6 +458,7 @@ public final class NotificationPanelViewController implements
    @Deprecated // Use SysUIStateInteractor instead
    private final SysUiState mSysUiState;
    private final SysUIStateDisplaysInteractor mSysUIStateDisplaysInteractor;
    private final Lazy<ShadeDisplaysRepository> mShadeDisplaysRepository;
    private final NotificationShadeDepthController mDepthController;
    private final NavigationBarController mNavigationBarController;
    private final int mDisplayId;
@@ -637,7 +640,8 @@ public final class NotificationPanelViewController implements
            KeyguardClockPositionAlgorithm keyguardClockPositionAlgorithm,
            MSDLPlayer msdlPlayer,
            BrightnessMirrorShowingRepository brightnessMirrorShowingRepository,
            BlurConfig blurConfig) {
            BlurConfig blurConfig,
            Lazy<ShadeDisplaysRepository> shadeDisplaysRepository) {
        mBlurConfig = blurConfig;
        SceneContainerFlag.assertInLegacyMode();
        keyguardStateController.addCallback(new KeyguardStateController.Callback() {
@@ -745,6 +749,7 @@ public final class NotificationPanelViewController implements
        mTapAgainViewController = tapAgainViewController;
        mSysUiState = sysUiState;
        mSysUIStateDisplaysInteractor = sysUIStateDisplaysInteractor;
        mShadeDisplaysRepository = shadeDisplaysRepository;
        mKeyguardBypassController = bypassController;
        mUpdateMonitor = keyguardUpdateMonitor;
        mLockscreenShadeTransitionController = lockscreenShadeTransitionController;
@@ -2716,9 +2721,18 @@ public final class NotificationPanelViewController implements
    }

    private int getShadeDisplayId() {
        if (mView != null && mView.getDisplay() != null) return mView.getDisplay().getDisplayId();
        if (ShadeWindowGoesAround.isEnabled()) {
            var pendingDisplayId =
                    mShadeDisplaysRepository.get().getPendingDisplayId().getValue();
            // Use the pendingDisplayId from the repository, *not* the Shade's context.
            // This ensures correct UI state updates also if this method is called just *before*
            // the Shade window moves to another display.
            // The pendingDisplayId is guaranteed to be updated before this method is called.
            return pendingDisplayId;
        } else {
            return Display.DEFAULT_DISPLAY;
        }
    }

    private void setPerDisplaySysUIStateFlags() {
        mSysUIStateDisplaysInteractor.setFlagsExclusivelyToDisplay(
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.systemui.scene.shared.model.sceneDataSource
import com.android.systemui.scene.ui.view.mockWindowRootViewProvider
import com.android.systemui.settings.brightness.data.repository.brightnessMirrorShowingRepository
import com.android.systemui.settings.displayTracker
import com.android.systemui.shade.data.repository.fakeShadeDisplaysRepository
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeLayoutParams
@@ -199,5 +200,6 @@ class KosmosJavaAdapter() {
    val windowRootViewBlurInteractor by lazy { kosmos.windowRootViewBlurInteractor }
    val sysuiState by lazy { kosmos.sysUiState }
    val displayTracker by lazy { kosmos.displayTracker }
    val fakeShadeDisplaysRepository by lazy { kosmos.fakeShadeDisplaysRepository }
    val sysUIStateDispatcher by lazy { kosmos.sysUIStateDispatcher }
}