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

Commit 78288b97 authored by Kenny Chen's avatar Kenny Chen Committed by Android (Google) Code Review
Browse files

Merge "Revert "Remove NOTIFICATION_GROUP_EXPANSION_CHANGE flag."" into main

parents 1e532f39 7157b5aa
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -102,6 +102,12 @@ object Flags {
            default = true
        )

    /** Only notify group expansion listeners when a change happens. */
    // TODO(b/292213543): Tracking Bug
    @JvmField
    val NOTIFICATION_GROUP_EXPANSION_CHANGE =
            releasedFlag("notification_group_expansion_change")

    // TODO(b/301955929)
    @JvmField
    val NOTIF_LS_BACKGROUND_THREAD =
+13 −5
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import androidx.annotation.NonNull;
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -51,11 +53,14 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
     */
    private final Set<NotificationEntry> mExpandedGroups = new HashSet<>();

    private final FeatureFlags mFeatureFlags;

    @Inject
    public GroupExpansionManagerImpl(DumpManager dumpManager,
            GroupMembershipManager groupMembershipManager) {
            GroupMembershipManager groupMembershipManager, FeatureFlags featureFlags) {
        mDumpManager = dumpManager;
        mGroupMembershipManager = groupMembershipManager;
        mFeatureFlags = featureFlags;
    }

    /**
@@ -81,9 +86,11 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
    };

    public void attach(NotifPipeline pipeline) {
        if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)) {
            mDumpManager.registerDumpable(this);
            pipeline.addOnBeforeRenderListListener(mNotifTracker);
        }
    }

    @Override
    public void registerGroupExpansionChangeListener(OnGroupExpansionChangeListener listener) {
@@ -98,7 +105,8 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
    @Override
    public void setGroupExpanded(NotificationEntry entry, boolean expanded) {
        NotificationEntry groupSummary = mGroupMembershipManager.getGroupSummary(entry);
        if (entry.getParent() == null) {
        if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)
                && entry.getParent() == null) {
            if (expanded) {
                throw new IllegalArgumentException("Cannot expand group that is not attached");
            } else {
@@ -116,7 +124,7 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
        }

        // Only notify listeners if something changed.
        if (changed) {
        if (!mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE) || changed) {
            sendOnGroupExpandedChange(entry, expanded);
        }
    }
+22 −8
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.flags.FeatureFlagsClassic;
import com.android.systemui.flags.Flags;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -36,17 +38,25 @@ import javax.inject.Inject;
 */
@SysUISingleton
public class GroupMembershipManagerImpl implements GroupMembershipManager {
    FeatureFlagsClassic mFeatureFlags;

    @Inject
    public GroupMembershipManagerImpl() {}
    public GroupMembershipManagerImpl(FeatureFlagsClassic featureFlags) {
        mFeatureFlags = featureFlags;
    }

    @Override
    public boolean isGroupSummary(@NonNull NotificationEntry entry) {
        if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)) {
            if (entry.getParent() == null) {
                // The entry is not attached, so it doesn't count.
                return false;
            }
            // If entry is a summary, its parent is a GroupEntry with summary = entry.
            return entry.getParent().getSummary() == entry;
        } else {
            return getGroupSummary(entry) == entry;
        }
    }

    @Nullable
@@ -60,8 +70,12 @@ public class GroupMembershipManagerImpl implements GroupMembershipManager {

    @Override
    public boolean isChildInGroup(@NonNull NotificationEntry entry) {
        if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_GROUP_EXPANSION_CHANGE)) {
            // An entry is a child if it's not a summary or top level entry, but it is attached.
            return !isGroupSummary(entry) && !isTopLevelEntry(entry) && entry.getParent() != null;
        } else {
            return !isTopLevelEntry(entry);
        }
    }

    @Override
+0 −0

File moved.

+0 −7
Original line number Diff line number Diff line
@@ -52,38 +52,32 @@ public class GroupEntryBuilder {
        return ge;
    }

    /** Sets the group key. */
    public GroupEntryBuilder setKey(String key) {
        mKey = key;
        return this;
    }

    /** Sets the creation time. */
    public GroupEntryBuilder setCreationTime(long creationTime) {
        mCreationTime = creationTime;
        return this;
    }

    /** Sets the parent entry of the group. */
    public GroupEntryBuilder setParent(@Nullable GroupEntry entry) {
        mParent = entry;
        return this;
    }

    /** Sets the section the group belongs to. */
    public GroupEntryBuilder setSection(@Nullable NotifSection section) {
        mNotifSection = section;
        return this;
    }

    /** Sets the group summary. */
    public GroupEntryBuilder setSummary(
            NotificationEntry summary) {
        mSummary = summary;
        return this;
    }

    /** Sets the group children. */
    public GroupEntryBuilder setChildren(List<NotificationEntry> children) {
        mChildren.clear();
        mChildren.addAll(children);
@@ -96,7 +90,6 @@ public class GroupEntryBuilder {
        return this;
    }

    /** Get the group's internal children list. */
    public static List<NotificationEntry> getRawChildren(GroupEntry groupEntry) {
        return groupEntry.getRawChildren();
    }
Loading