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

Commit 4ebf7432 authored by Yining Liu's avatar Yining Liu
Browse files

Move group notification summary header view inflation to the background thread

Move the group notification summary header view inflation to the background thread
to reduce janks and improve the performance of System UI.

Bug: 217799515
Test: atest NotificationChildrenContainerTest
Flag: ACONFIG notification_async_group_header_inflation DEVELOPMENT
Change-Id: I7124e909add1efa964f6b4d6f0effdc309fc1d1d
parent e437c588
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -174,6 +174,23 @@ public class StatusBarNotification implements Parcelable {
        return sbnKey;
    }

    /**
     * @return Whether the Entry is a group child by the app or system
     * @hide
     */
    public boolean isAppOrSystemGroupChild() {
        return isGroup() && !getNotification().isGroupSummary();
    }


    /**
     * @return Whether the Entry is a group summary by the app or system
     * @hide
     */
    public boolean isAppOrSystemGroupSummary() {
        return isGroup() && getNotification().isGroupSummary();
    }

    private String groupKey() {
        if (overrideGroupKey != null) {
            return user.getIdentifier() + "|" + pkg + "|" + "g:" + overrideGroupKey;
+7 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import com.android.internal.widget.ConversationLayout;
import com.android.internal.widget.ImageFloatingTextView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationContentView;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;

import java.util.ArrayList;
import java.util.HashSet;
@@ -253,7 +255,8 @@ public class NotificationGroupingUtil {
        }

        public void init() {
            View header = mParentRow.getNotificationViewWrapper().getNotificationHeader();
            NotificationViewWrapper wrapper = mParentRow.getNotificationViewWrapper();
            View header = wrapper == null ? null : wrapper.getNotificationHeader();
            mParentView = header == null ? null : header.findViewById(mId);
            mParentData = mExtractor == null ? null : mExtractor.extractData(mParentRow);
            mApply = !mComparator.isEmpty(mParentView);
@@ -326,6 +329,9 @@ public class NotificationGroupingUtil {

        @Override
        public boolean isEmpty(View view) {
            if (AsyncGroupHeaderViewInflation.isEnabled() && view == null) {
                return true;
            }
            if (view instanceof ImageView) {
                return ((ImageView) view).getDrawable() == null;
            }
+5 −4
Original line number Diff line number Diff line
@@ -363,10 +363,11 @@ public class PreparationCoordinator implements Coordinator {

    NotifInflater.Params getInflaterParams(NotifUiAdjustment adjustment, String reason) {
        return new NotifInflater.Params(
                adjustment.isMinimized(),
                reason,
                adjustment.isSnoozeEnabled(),
                adjustment.isChildInGroup()
                /* isLowPriority = */ adjustment.isMinimized(),
                /* reason = */ reason,
                /* showSnooze = */ adjustment.isSnoozeEnabled(),
                /* isChildInGroup = */ adjustment.isChildInGroup(),
                /* isGroupSummary = */ adjustment.isGroupSummary()
        );
    }

+1 −0
Original line number Diff line number Diff line
@@ -60,5 +60,6 @@ interface NotifInflater {
        val reason: String,
        val showSnooze: Boolean,
        val isChildInGroup: Boolean = false,
        val isGroupSummary: Boolean = false,
    )
}
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Notification
import android.app.RemoteInput
import android.graphics.drawable.Icon
import android.text.TextUtils
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation
import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation

/**
@@ -36,6 +37,7 @@ class NotifUiAdjustment internal constructor(
    val isMinimized: Boolean,
    val needsRedaction: Boolean,
    val isChildInGroup: Boolean,
    val isGroupSummary: Boolean,
) {
    companion object {
        @JvmStatic
@@ -55,6 +57,8 @@ class NotifUiAdjustment internal constructor(
            //  !oldAdjustment.isChildInGroup && newAdjustment.isChildInGroup -> true
            AsyncHybridViewInflation.isEnabled &&
                    oldAdjustment.isChildInGroup != newAdjustment.isChildInGroup -> true
            AsyncGroupHeaderViewInflation.isEnabled &&
                !oldAdjustment.isGroupSummary && newAdjustment.isGroupSummary -> true
            else -> false
        }

Loading