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

Commit ba90a039 authored by Jernej Virag's avatar Jernej Virag
Browse files

Trace measurement and layout of ExpandableNotificationRow

This view sometimes takes suspiciously long to measure and layout - this adds tracing with information about what kind of notification style is being inflated to aid debugging.

Bug:217190505
Test: Manually on device
Change-Id: I6c69e4ab40a9116d95112c6301469a0d1947a311
parent a38e938b
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.Trace;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
@@ -1246,6 +1247,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    private void reInflateViews() {
        Trace.beginSection("ExpandableNotificationRow#reInflateViews");
        // Let's update our childrencontainer. This is intentionally not guarded with
        // mIsSummaryWithChildren since we might have had children but not anymore.
        if (mChildrenContainer != null) {
@@ -1277,6 +1279,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        RowContentBindParams params = mRowContentBindStage.getStageParams(mEntry);
        params.setNeedsReinflation(true);
        mRowContentBindStage.requestRebind(mEntry, null /* callback */);
        Trace.endSection();
    }

    @Override
@@ -1736,6 +1739,29 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        };
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        Trace.beginSection(appendTraceStyleTag("ExpNotRow#onMeasure"));
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        Trace.endSection();
    }

    /** Generates and appends "(MessagingStyle)" type tag to passed string for tracing. */
    @NonNull
    private String appendTraceStyleTag(@NonNull String traceTag) {
        if (!Trace.isEnabled()) {
            return traceTag;
        }

        Class<? extends Notification.Style> style =
                getEntry().getSbn().getNotification().getNotificationStyle();
        if (style == null) {
            return traceTag + "(nostyle)";
        } else {
            return traceTag + "(" + style.getSimpleName() + ")";
        }
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
@@ -2542,6 +2568,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        Trace.beginSection(appendTraceStyleTag("ExpNotRow#onLayout"));
        int intrinsicBefore = getIntrinsicHeight();
        super.onLayout(changed, left, top, right, bottom);
        if (intrinsicBefore != getIntrinsicHeight()
@@ -2555,6 +2582,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (mLayoutListener != null) {
            mLayoutListener.onLayout();
        }
        Trace.endSection();
    }

    /**