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

Commit 72655bf4 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Add traces to aid onScreenTuringOn latency debugging

Those traces are useful to debug what happens in the unfold scenario: we discovered that recent changes added a lot of delay in systemui receiving onScreenTuringOn, and onDisplayChanged callbacks.

Bug: 197515205
Test: recorded a perfetto trace and made sure those are there
Change-Id: Iec9f2261dd63d414e1e5387933b7374a5f003e11
parent a52caf03
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.display;

import android.annotation.NonNull;
import android.os.Trace;
import android.util.Slog;
import android.view.Display;
import android.view.DisplayAddress;
@@ -38,6 +39,7 @@ import java.util.function.Consumer;
 */
class DisplayDeviceRepository implements DisplayAdapter.Listener {
    private static final String TAG = "DisplayDeviceRepository";
    private static final Boolean DEBUG = false;

    public static final int DISPLAY_DEVICE_EVENT_ADDED = 1;
    public static final int DISPLAY_DEVICE_EVENT_CHANGED = 2;
@@ -75,6 +77,11 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {

    @Override
    public void onDisplayDeviceEvent(DisplayDevice device, int event) {
        String tag = null;
        if (DEBUG) {
            tag = "DisplayDeviceRepository#onDisplayDeviceEvent (event=" + event + ")";
            Trace.beginAsyncSection(tag, 0);
        }
        switch (event) {
            case DISPLAY_DEVICE_EVENT_ADDED:
                handleDisplayDeviceAdded(device);
@@ -88,6 +95,9 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
                handleDisplayDeviceRemoved(device);
                break;
        }
        if (DEBUG) {
            Trace.endAsyncSection(tag, 0);
        }
    }

    @Override
@@ -156,7 +166,9 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
                Slog.w(TAG, "Attempted to change non-existent display device: " + info);
                return;
            }

            if (DEBUG) {
                Trace.beginSection("handleDisplayDeviceChanged");
            }
            int diff = device.mDebugLastLoggedDeviceInfo.diff(info);
            if (diff == DisplayDeviceInfo.DIFF_STATE) {
                Slog.i(TAG, "Display device changed state: \"" + info.name
@@ -176,6 +188,9 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {

            device.applyPendingDisplayDeviceInfoChangesLocked();
            sendEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
            if (DEBUG) {
                Trace.endSection();
            }
        }
    }

+6 −0
Original line number Diff line number Diff line
@@ -781,7 +781,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                mDisplayStatsId = mUniqueDisplayId.hashCode();
                mDisplayDeviceConfig = config;
                loadFromDisplayDeviceConfig(token, info);
                if (DEBUG) {
                    Trace.beginAsyncSection("DisplayPowerController#updatePowerState", 0);
                }
                updatePowerState();
                if (DEBUG) {
                    Trace.endAsyncSection("DisplayPowerController#updatePowerState", 0);
                }
            }
        });
    }
+7 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.display;

import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.Mode.INVALID_MODE_ID;

import android.app.ActivityThread;
@@ -1391,7 +1392,12 @@ final class LocalDisplayAdapter extends DisplayAdapter {
        }

        public boolean getBootDisplayModeSupport() {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "getBootDisplayModeSupport");
            try {
                return SurfaceControl.getBootDisplayModeSupport();
            } finally {
                Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
            }
        }

        public void setBootDisplayMode(IBinder displayToken, int modeId) {