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

Commit b945ea53 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

WMS screen-unfreezing trace tags

Adds perfetto trace tag for WMS (un)freezing screen. This is important
for user-switches, where we need to determine when the user-switch is
complete.

Test: manual - user-switch and observe
Test: systemui-multiuser-suite
Bug: 210527498
Change-Id: Ieff68eb7175efbac9e23684564d9bd4c0e189312
parent d707ebcd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2034,6 +2034,11 @@ class UserController implements Handler.Callback {
        }
    }

    /**
     * Tell WindowManager we're ready to unfreeze the screen, at its leisure. Note that there is
     * likely a lot going on, and WM won't unfreeze until the drawing is all done, so
     * the actual unfreeze may still not happen for a long time; this is expected.
     */
    @VisibleForTesting
    void unfreezeScreen() {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog();
+21 −1
Original line number Diff line number Diff line
@@ -695,6 +695,7 @@ public class WindowManagerService extends IWindowManager.Stub
    final static int WINDOWS_FREEZING_SCREENS_TIMEOUT = 2;
    int mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE;

    /** Indicates that the system server is actively demanding the screen be frozen. */
    boolean mClientFreezingScreen = false;
    int mAppsFreezingScreen = 0;

@@ -3091,6 +3092,7 @@ public class WindowManagerService extends IWindowManager.Stub
    // Misc IWindowSession methods
    // -------------------------------------------------------------

    /** Freeze the screen during a user-switch event. Called by UserController. */
    @Override
    public void startFreezingScreen(int exitAnim, int enterAnim) {
        if (!checkCallingPermission(android.Manifest.permission.FREEZE_SCREEN,
@@ -3113,6 +3115,11 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    /**
     * No longer actively demand that the screen remain frozen.
     * Called by UserController after a user-switch.
     * This doesn't necessarily immediately unlock the screen; it just allows it if we're ready.
     */
    @Override
    public void stopFreezingScreen() {
        if (!checkCallingPermission(android.Manifest.permission.FREEZE_SCREEN,
@@ -5859,6 +5866,13 @@ public class WindowManagerService extends IWindowManager.Stub
            return;
        }

        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "WMS.doStartFreezingDisplay");
        doStartFreezingDisplay(exitAnim, enterAnim, displayContent, overrideOriginalRotation);
        Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
    }

    private void doStartFreezingDisplay(int exitAnim, int enterAnim, DisplayContent displayContent,
            int overrideOriginalRotation) {
        ProtoLog.d(WM_DEBUG_ORIENTATION,
                            "startFreezingDisplayLocked: exitAnim=%d enterAnim=%d called by %s",
                            exitAnim, enterAnim, Debug.getCallers(8));
@@ -5929,10 +5943,16 @@ public class WindowManagerService extends IWindowManager.Stub
            return;
        }

        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "WMS.doStopFreezingDisplayLocked-"
                + mLastFinishedFreezeSource);
        doStopFreezingDisplayLocked(displayContent);
        Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
    }

    private void doStopFreezingDisplayLocked(DisplayContent displayContent) {
        ProtoLog.d(WM_DEBUG_ORIENTATION,
                    "stopFreezingDisplayLocked: Unfreezing now");


        // We must make a local copy of the displayId as it can be potentially overwritten later on
        // in this method. For example, {@link startFreezingDisplayLocked} may be called as a result
        // of update rotation, but we reference the frozen display after that call in this method.