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

Commit 37e78d64 authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Merge "Merge "Worked around a bug where the a group child could be leaked"...

Merge "Merge "Worked around a bug where the a group child could be leaked" into oc-dr1-dev am: f89e462b am: b364e46f" into oc-mr1-dev-plus-aosp
am: 078b2534

Change-Id: I254ec238c7ce7bc12f0dc91546f84c202efe937a
parents 56bb3aeb 078b2534
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,7 @@ public class NotificationData {
        private int mCachedContrastColor = COLOR_INVALID;
        private int mCachedContrastColor = COLOR_INVALID;
        private int mCachedContrastColorIsFor = COLOR_INVALID;
        private int mCachedContrastColorIsFor = COLOR_INVALID;
        private InflationTask mRunningTask = null;
        private InflationTask mRunningTask = null;
        private Throwable mDebugThrowable;


        public Entry(StatusBarNotification n) {
        public Entry(StatusBarNotification n) {
            this.key = n.getKey();
            this.key = n.getKey();
@@ -249,6 +250,19 @@ public class NotificationData {
        public InflationTask getRunningTask() {
        public InflationTask getRunningTask() {
            return mRunningTask;
            return mRunningTask;
        }
        }

        /**
         * Set a throwable that is used for debugging
         *
         * @param debugThrowable the throwable to save
         */
        public void setDebugThrowable(Throwable debugThrowable) {
            mDebugThrowable = debugThrowable;
        }

        public Throwable getDebugThrowable() {
            return mDebugThrowable;
        }
    }
    }


    private final ArrayMap<String, Entry> mEntries = new ArrayMap<>();
    private final ArrayMap<String, Entry> mEntries = new ArrayMap<>();
+31 −10
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone;


import android.service.notification.StatusBarNotification;
import android.service.notification.StatusBarNotification;
import android.support.annotation.Nullable;
import android.support.annotation.Nullable;
import android.util.Log;


import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationData;
@@ -29,7 +30,6 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Iterator;
import java.util.Map;
import java.util.Map;


@@ -38,6 +38,7 @@ import java.util.Map;
 */
 */
public class NotificationGroupManager implements OnHeadsUpChangedListener {
public class NotificationGroupManager implements OnHeadsUpChangedListener {


    private static final String TAG = "NotificationGroupManager";
    private final HashMap<String, NotificationGroup> mGroupMap = new HashMap<>();
    private final HashMap<String, NotificationGroup> mGroupMap = new HashMap<>();
    private OnGroupChangeListener mListener;
    private OnGroupChangeListener mListener;
    private int mBarState = -1;
    private int mBarState = -1;
@@ -96,7 +97,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener {
            return;
            return;
        }
        }
        if (isGroupChild(sbn)) {
        if (isGroupChild(sbn)) {
            group.children.remove(removed);
            group.children.remove(removed.key);
        } else {
        } else {
            group.summary = null;
            group.summary = null;
        }
        }
@@ -109,6 +110,9 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener {
    }
    }


    public void onEntryAdded(final NotificationData.Entry added) {
    public void onEntryAdded(final NotificationData.Entry added) {
        if (added.row.isRemoved()) {
            added.setDebugThrowable(new Throwable());
        }
        final StatusBarNotification sbn = added.notification;
        final StatusBarNotification sbn = added.notification;
        boolean isGroupChild = isGroupChild(sbn);
        boolean isGroupChild = isGroupChild(sbn);
        String groupKey = getGroupKey(sbn);
        String groupKey = getGroupKey(sbn);
@@ -118,15 +122,25 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener {
            mGroupMap.put(groupKey, group);
            mGroupMap.put(groupKey, group);
        }
        }
        if (isGroupChild) {
        if (isGroupChild) {
            group.children.add(added);
            NotificationData.Entry existing = group.children.get(added.key);
            if (existing != null && existing != added) {
                Throwable existingThrowable = existing.getDebugThrowable();
                Log.wtf(TAG, "Inconsistent entries found with the same key " + added.key
                        + "existing removed: " + existing.row.isRemoved()
                        + (existingThrowable != null
                                ? Log.getStackTraceString(existingThrowable) + "\n": "")
                        + " added removed" + added.row.isRemoved()
                        , new Throwable());
            }
            group.children.put(added.key, added);
            updateSuppression(group);
            updateSuppression(group);
        } else {
        } else {
            group.summary = added;
            group.summary = added;
            group.expanded = added.row.areChildrenExpanded();
            group.expanded = added.row.areChildrenExpanded();
            updateSuppression(group);
            updateSuppression(group);
            if (!group.children.isEmpty()) {
            if (!group.children.isEmpty()) {
                HashSet<NotificationData.Entry> childrenCopy =
                ArrayList<NotificationData.Entry> childrenCopy
                        (HashSet<NotificationData.Entry>) group.children.clone();
                        = new ArrayList<>(group.children.values());
                for (NotificationData.Entry child : childrenCopy) {
                for (NotificationData.Entry child : childrenCopy) {
                    onEntryBecomingChild(child);
                    onEntryBecomingChild(child);
                }
                }
@@ -410,7 +424,8 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener {
        // The parent of a suppressed group got huned, lets hun the child!
        // The parent of a suppressed group got huned, lets hun the child!
        NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
        NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
        if (notificationGroup != null) {
        if (notificationGroup != null) {
            Iterator<NotificationData.Entry> iterator = notificationGroup.children.iterator();
            Iterator<NotificationData.Entry> iterator
                    = notificationGroup.children.values().iterator();
            NotificationData.Entry child = iterator.hasNext() ? iterator.next() : null;
            NotificationData.Entry child = iterator.hasNext() ? iterator.next() : null;
            if (child == null) {
            if (child == null) {
                child = getIsolatedChild(sbn.getGroupKey());
                child = getIsolatedChild(sbn.getGroupKey());
@@ -463,7 +478,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener {
    }
    }


    public static class NotificationGroup {
    public static class NotificationGroup {
        public final HashSet<NotificationData.Entry> children = new HashSet<>();
        public final HashMap<String, NotificationData.Entry> children = new HashMap<>();
        public NotificationData.Entry summary;
        public NotificationData.Entry summary;
        public boolean expanded;
        public boolean expanded;
        /**
        /**
@@ -474,10 +489,16 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener {
        @Override
        @Override
        public String toString() {
        public String toString() {
            String result = "    summary:\n      "
            String result = "    summary:\n      "
                    + (summary != null ? summary.notification : "null");
                    + (summary != null ? summary.notification : "null")
                    + (summary != null && summary.getDebugThrowable() != null
                            ? Log.getStackTraceString(summary.getDebugThrowable())
                            : "");
            result += "\n    children size: " + children.size();
            result += "\n    children size: " + children.size();
            for (NotificationData.Entry child : children) {
            for (NotificationData.Entry child : children.values()) {
                result += "\n      " + child.notification;
                result += "\n      " + child.notification
                + (child.getDebugThrowable() != null
                        ? Log.getStackTraceString(child.getDebugThrowable())
                        : "");
            }
            }
            return result;
            return result;
        }
        }