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

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

Add traces to aid onScreenTurnedOn latency debugging

+ Adding traces to HingeSensorAngle provider (it seems it takes >10ms to initialize on the ui thread)
+  Adding traces to Keyguard display manager: show and hide presentation together account for 130ms, and should definitely be improved
+ Removed PowerManager import as style checks complained

Bug: 197515205
Test: recorded a perfetto trace and made sure those are there
Change-Id: I38def9d0503638a4647e097c9c5974660e0f8cd0
parent 1c92783e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Trace
import androidx.core.util.Consumer

internal class HingeSensorAngleProvider(private val sensorManager: SensorManager) :
@@ -13,8 +14,10 @@ internal class HingeSensorAngleProvider(private val sensorManager: SensorManager
    private val listeners: MutableList<Consumer<Float>> = arrayListOf()

    override fun start() {
        Trace.beginSection("HingeSensorAngleProvider#start")
        val sensor = sensorManager.getDefaultSensor(Sensor.TYPE_HINGE_ANGLE)
        sensorManager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_FASTEST)
        Trace.endSection()
    }

    override fun stop() {
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.hardware.display.DisplayManager;
import android.media.MediaRouter;
import android.media.MediaRouter.RouteInfo;
import android.os.Bundle;
import android.os.Trace;
import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
@@ -67,11 +68,14 @@ public class KeyguardDisplayManager {

        @Override
        public void onDisplayAdded(int displayId) {
            Trace.beginSection(
                    "KeyguardDisplayManager#onDisplayAdded(displayId=" + displayId + ")");
            final Display display = mDisplayService.getDisplay(displayId);
            if (mShowing) {
                updateNavigationBarVisibility(displayId, false /* navBarVisible */);
                showPresentation(display);
            }
            Trace.endSection();
        }

        @Override
@@ -81,7 +85,10 @@ public class KeyguardDisplayManager {

        @Override
        public void onDisplayRemoved(int displayId) {
            Trace.beginSection(
                    "KeyguardDisplayManager#onDisplayRemoved(displayId=" + displayId + ")");
            hidePresentation(displayId);
            Trace.endSection();
        }
    };

+8 −1
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@ package com.android.systemui.keyguard;

import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.Trace;
import android.util.Log;

import com.android.internal.policy.IKeyguardDrawnCallback;
@@ -83,6 +83,11 @@ public class KeyguardLifecyclesDispatcher {
            final Object obj = msg.obj;
            switch (msg.what) {
                case SCREEN_TURNING_ON:
                    Trace.beginSection("KeyguardLifecyclesDispatcher#SCREEN_TURNING_ON");
                    final String onDrawWaitingTraceTag =
                            "Waiting for KeyguardDrawnCallback#onDrawn";
                    int traceCookie = System.identityHashCode(msg);
                    Trace.beginAsyncSection(onDrawWaitingTraceTag, traceCookie);
                    // Ensure the drawn callback is only ever called once
                    mScreenLifecycle.dispatchScreenTurningOn(new Runnable() {
                            boolean mInvoked;
@@ -92,6 +97,7 @@ public class KeyguardLifecyclesDispatcher {
                                if (!mInvoked) {
                                    mInvoked = true;
                                    try {
                                        Trace.endAsyncSection(onDrawWaitingTraceTag, traceCookie);
                                        ((IKeyguardDrawnCallback) obj).onDrawn();
                                    } catch (RemoteException e) {
                                        Log.w(TAG, "Exception calling onDrawn():", e);
@@ -101,6 +107,7 @@ public class KeyguardLifecyclesDispatcher {
                                }
                            }
                        });
                    Trace.endSection();
                    break;
                case SCREEN_TURNED_ON:
                    mScreenLifecycle.dispatchScreenTurnedOn();