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

Commit 967ed2a1 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed a bug where the wrong group was HUNd

Fixes: 22466201
Fixes: 27925006
Change-Id: Iaaf91b63c0bb218a75b449554f17ed3828fdfff8
parent 9870ad94
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;

/**
@@ -37,6 +38,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
    private OnGroupChangeListener mListener;
    private int mBarState = -1;
    private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
    private HeadsUpManager mHeadsUpManager;

    public void setOnGroupChangeListener(OnGroupChangeListener listener) {
        mListener = listener;
@@ -142,6 +144,9 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
                        && group.summary.notification.getNotification().isGroupSummary()
                        && hasIsolatedChildren(group)));
        if (prevSuppressed != group.suppressed) {
            if (group.suppressed) {
                handleSuppressedSummaryHeadsUpped(group.summary);
            }
            mListener.onGroupsChanged();
        }
    }
@@ -160,6 +165,15 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
        return count;
    }

    private NotificationData.Entry getIsolatedChild(String groupKey) {
        for (StatusBarNotification sbn : mIsolatedEntries.values()) {
            if (sbn.getGroupKey().equals(groupKey) && isIsolated(sbn)) {
                return mGroupMap.get(sbn.getKey()).summary;
            }
        }
        return null;
    }

    public void onEntryUpdated(NotificationData.Entry entry,
            StatusBarNotification oldNotification) {
        if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
@@ -332,6 +346,9 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
                // it doesn't lead to an update.
                updateSuppression(mGroupMap.get(entry.notification.getGroupKey()));
                mListener.onGroupsChanged();
            } else {
                handleSuppressedSummaryHeadsUpped(entry);

            }
        } else {
            if (mIsolatedEntries.containsKey(sbn.getKey())) {
@@ -344,6 +361,32 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
        }
    }

    private void handleSuppressedSummaryHeadsUpped(NotificationData.Entry entry) {
        StatusBarNotification sbn = entry.notification;
        if (!isGroupSuppressed(sbn.getGroupKey())
                || !sbn.getNotification().isGroupSummary()
                || !entry.row.isHeadsUp()) {
            return;
        }
        // The parent of a suppressed group got huned, lets hun the child!
        NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
        if (notificationGroup != null) {
            Iterator<NotificationData.Entry> iterator = notificationGroup.children.iterator();
            NotificationData.Entry child = iterator.hasNext() ? iterator.next() : null;
            if (child == null) {
                child = getIsolatedChild(sbn.getGroupKey());
            }
            if (child != null) {
                if (mHeadsUpManager.isHeadsUp(child.key)) {
                    mHeadsUpManager.updateNotification(child, true);
                } else {
                    mHeadsUpManager.showNotification(child);
                }
            }
        }
        mHeadsUpManager.releaseImmediately(entry.key);
    }

    private boolean shouldIsolate(StatusBarNotification sbn) {
        NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
        return (sbn.isGroup() && !sbn.getNotification().isGroupSummary())
@@ -360,6 +403,10 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
                || notificationGroup.summary.row.getTranslationY() < 0;
    }

    public void setHeadsUpManager(HeadsUpManager headsUpManager) {
        mHeadsUpManager = headsUpManager;
    }

    public static class NotificationGroup {
        public final HashSet<NotificationData.Entry> children = new HashSet<>();
        public NotificationData.Entry summary;
+1 −0
Original line number Diff line number Diff line
@@ -730,6 +730,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mHeadsUpManager.addListener(mGroupManager);
        mNotificationPanel.setHeadsUpManager(mHeadsUpManager);
        mNotificationData.setHeadsUpManager(mHeadsUpManager);
        mGroupManager.setHeadsUpManager(mHeadsUpManager);

        if (MULTIUSER_DEBUG) {
            mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(
+5 −0
Original line number Diff line number Diff line
@@ -185,6 +185,11 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL

        if (alert) {
            HeadsUpEntry headsUpEntry = mHeadsUpEntries.get(headsUp.key);
            if (headsUpEntry == null) {
                // the entry was released before this update (i.e by a listener) This can happen
                // with the groupmanager
                return;
            }
            headsUpEntry.updateEntry();
            setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUp));
        }