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

Commit 5d695bff authored by Yining Liu's avatar Yining Liu
Browse files

Add traces to the main thread inflation of NotificationHeaderView and HybridNotificationView

Add traces to the main thread inflation of NotificationHeaderView and HybridNotificationView to track the performance of inflation.

Bug: 285039325
Test: Perfetto
Change-Id: I1399c5ece6acea1f6997650254d61dd3f0b2b256
parent 9cdcda8d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -556,6 +556,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    public void onNotificationUpdated() {
        if (mIsSummaryWithChildren) {
            Trace.beginSection("ExpNotRow#onNotifUpdated (summary)");
        } else {
            Trace.beginSection("ExpNotRow#onNotifUpdated (leaf)");
        }
        for (NotificationContentView l : mLayouts) {
            l.onNotificationUpdated(mEntry);
        }
@@ -591,6 +596,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mUpdateSelfBackgroundOnUpdate = false;
            updateBackgroundColorsOfSelf();
        }
        Trace.endSection();
    }

    private void updateBackgroundColorsOfSelf() {
@@ -2588,6 +2594,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mIsSummaryWithChildren = mChildrenContainer != null
                && mChildrenContainer.getNotificationChildCount() > 0;
        if (mIsSummaryWithChildren) {
            Trace.beginSection("ExpNotRow#onChildCountChanged (summary)");
            NotificationViewWrapper wrapper = mChildrenContainer.getNotificationViewWrapper();
            if (wrapper == null || wrapper.getNotificationHeader() == null) {
                mChildrenContainer.recreateNotificationHeader(mExpandClickListener,
@@ -2599,6 +2606,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        updateChildrenAppearance();
        updateChildrenVisibility();
        applyChildrenRoundness();
        if (mIsSummaryWithChildren) {
            Trace.endSection();
        }
    }

    protected void expandNotification() {
+9 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
import android.content.res.Resources;
import android.os.Trace;
import android.service.notification.StatusBarNotification;
import android.util.TypedValue;
import android.view.LayoutInflater;
@@ -57,6 +58,7 @@ public class HybridGroupManager {
    }

    private HybridNotificationView inflateHybridView(View contentView, ViewGroup parent) {
        Trace.beginSection("HybridGroupManager#inflateHybridView");
        LayoutInflater inflater = LayoutInflater.from(mContext);
        int layout = contentView instanceof ConversationLayout
                ? R.layout.hybrid_conversation_notification
@@ -64,6 +66,7 @@ public class HybridGroupManager {
        HybridNotificationView hybrid = (HybridNotificationView)
                inflater.inflate(layout, parent, false);
        parent.addView(hybrid);
        Trace.endSection();
        return hybrid;
    }

@@ -90,12 +93,18 @@ public class HybridGroupManager {
    public HybridNotificationView bindFromNotification(HybridNotificationView reusableView,
            View contentView, StatusBarNotification notification,
            ViewGroup parent) {
        boolean isNewView = false;
        if (reusableView == null) {
            Trace.beginSection("HybridGroupManager#bindFromNotification");
            reusableView = inflateHybridView(contentView, parent);
            isNewView = true;
        }
        CharSequence titleText = resolveTitle(notification.getNotification());
        CharSequence contentText = resolveText(notification.getNotification());
        reusableView.bind(titleText, contentText, contentView);
        if (isNewView) {
            Trace.endSection();
        }
        return reusableView;
    }

+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.RemoteException;
import android.os.Trace;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.util.AttributeSet;
@@ -1193,6 +1194,7 @@ public class NotificationContentView extends FrameLayout implements Notification

    private void updateSingleLineView() {
        if (mIsChildInGroup) {
            Trace.beginSection("NotifContentView#updateSingleLineView");
            boolean isNewView = mSingleLineView == null;
            mSingleLineView = mHybridGroupManager.bindFromNotification(
                    mSingleLineView, mContractedChild, mNotificationEntry.getSbn(), this);
@@ -1200,6 +1202,7 @@ public class NotificationContentView extends FrameLayout implements Notification
                updateViewVisibility(mVisibleType, VISIBLE_TYPE_SINGLELINE,
                        mSingleLineView, mSingleLineView);
            }
            Trace.endSection();
        } else if (mSingleLineView != null) {
            removeView(mSingleLineView);
            mSingleLineView = null;
+2 −0
Original line number Diff line number Diff line
@@ -379,6 +379,7 @@ public class NotificationChildrenContainer extends ViewGroup
    }

    public void recreateNotificationHeader(OnClickListener listener, boolean isConversation) {
        Trace.beginSection("NotifChildCont#recreateHeader");
        mHeaderClickListener = listener;
        mIsConversation = isConversation;
        StatusBarNotification notification = mContainingNotification.getEntry().getSbn();
@@ -406,6 +407,7 @@ public class NotificationChildrenContainer extends ViewGroup
        recreateLowPriorityHeader(builder, isConversation);
        updateHeaderVisibility(false /* animate */);
        updateChildrenAppearance();
        Trace.endSection();
    }

    /**