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

Commit 3bcf7453 authored by Riddle Hsu's avatar Riddle Hsu Committed by Nick Chameyev
Browse files

Unblock screen-on after start transaction is completed

The waitForAllWindowsDrawn logic may not wait
for the desired state of the transition, so delegate
the screen on condition to transition, which makes sure
the initial states are applied by the start transaction
of transition.

Bug: 301420598
Test: fold/unfold without flickering
Test: emulate delay in DeferredDisplayUpdater
  => check that we wait for transition to start
Test: atest DisplayContentDeferredUpdateTests
Merged-In: Ibed2cf715cc3898167cab02e21405bf028ca1111
Change-Id: Ibed2cf715cc3898167cab02e21405bf028ca1111
parent d99e36d2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -7,6 +7,16 @@ flag {
  bug: "232195501"
}

flag {
    name: "wait_for_transition_on_display_switch"
    namespace: "windowing_frontend"
    description: "Waits for Shell transition to start before unblocking the screen after display switch"
    bug: "301420598"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
  name: "edge_to_edge_by_default"
  namespace: "windowing_frontend"
+1 −0
Original line number Diff line number Diff line
@@ -730,6 +730,7 @@ public final class DisplayManagerService extends SystemService {
            mContext.getSystemService(DeviceStateManager.class).registerCallback(
                    new HandlerExecutor(mHandler), new DeviceStateListener());

            mLogicalDisplayMapper.onWindowManagerReady();
            scheduleTraversalLocked(false);
        }
    }
+15 −0
Original line number Diff line number Diff line
@@ -41,10 +41,12 @@ import android.view.DisplayInfo;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.foldables.FoldGracePeriodProvider;
import com.android.server.LocalServices;
import com.android.server.display.feature.DisplayManagerFlags;
import com.android.server.display.layout.DisplayIdProducer;
import com.android.server.display.layout.Layout;
import com.android.server.display.utils.DebugUtils;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.utils.FoldSettingProvider;

import java.io.PrintWriter;
@@ -189,6 +191,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
     * #updateLogicalDisplaysLocked} to establish which Virtual Devices own which Virtual Displays.
     */
    private final ArrayMap<String, Integer> mVirtualDeviceDisplayMapping = new ArrayMap<>();
    private WindowManagerPolicy mWindowManagerPolicy;

    private int mNextNonDefaultGroupId = Display.DEFAULT_DISPLAY_GROUP + 1;
    private final DisplayIdProducer mIdProducer = (isDefault) ->
@@ -273,6 +276,10 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
        mListener.onTraversalRequested();
    }

    public void onWindowManagerReady() {
        mWindowManagerPolicy = LocalServices.getService(WindowManagerPolicy.class);
    }

    public LogicalDisplay getDisplayLocked(int displayId) {
        return getDisplayLocked(displayId, /* includeDisabled= */ true);
    }
@@ -1114,14 +1121,22 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
            final int logicalDisplayId = displayLayout.getLogicalDisplayId();

            LogicalDisplay newDisplay = getDisplayLocked(logicalDisplayId);
            boolean newDisplayCreated = false;
            if (newDisplay == null) {
                newDisplay = createNewLogicalDisplayLocked(
                        null /*displayDevice*/, logicalDisplayId);
                newDisplayCreated = true;
            }

            // Now swap the underlying display devices between the old display and the new display
            final LogicalDisplay oldDisplay = getDisplayLocked(device);
            if (newDisplay != oldDisplay) {
                // Display is swapping, notify WindowManager, so it can prepare for
                // the display switch
                if (!newDisplayCreated && mWindowManagerPolicy != null) {
                    mWindowManagerPolicy.onDisplaySwitchStart(newDisplay.getDisplayIdLocked());
                }

                newDisplay.swapDisplaysLocked(oldDisplay);
            }
            DisplayDeviceConfig config = device.getDisplayDeviceConfig();
+7 −0
Original line number Diff line number Diff line
@@ -5658,6 +5658,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    @Override
    public void onDisplaySwitchStart(int displayId) {
        if (displayId == DEFAULT_DISPLAY) {
            mDefaultDisplayPolicy.onDisplaySwitchStart();
        }
    }

    private long getKeyguardDrawnTimeout() {
        final boolean bootCompleted =
                LocalServices.getService(SystemServiceManager.class).isBootCompleted();
+3 −0
Original line number Diff line number Diff line
@@ -895,6 +895,9 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
        void onScreenOff();
    }

    /** Called when the physical display starts to switch, e.g. fold/unfold. */
    void onDisplaySwitchStart(int displayId);

    /**
     * Return whether the default display is on and not blocked by a black surface.
     */
Loading