FileDocCategorySizeDatePackage
NotificationData.javaAPI DocAndroid 5.1 API11846Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar

NotificationData

public class NotificationData extends Object
The list of currently displaying notifications.

Fields Summary
private final Environment
mEnvironment
private final android.util.ArrayMap
mEntries
private final ArrayList
mSortedAndFiltered
private android.util.ArraySet
mGroupsWithSummaries
private android.service.notification.NotificationListenerService.RankingMap
mRankingMap
private final android.service.notification.NotificationListenerService.Ranking
mTmpRanking
private final Comparator
mRankingComparator
Constructors Summary
public NotificationData(Environment environment)


       
        mEnvironment = environment;
    
Methods Summary
public voidadd(com.android.systemui.statusbar.NotificationData$Entry entry, android.service.notification.NotificationListenerService.RankingMap ranking)

        mEntries.put(entry.notification.getKey(), entry);
        updateRankingAndSort(ranking);
    
public voiddump(java.io.PrintWriter pw, java.lang.String indent)

        int N = mSortedAndFiltered.size();
        pw.print(indent);
        pw.println("active notifications: " + N);
        int active;
        for (active = 0; active < N; active++) {
            NotificationData.Entry e = mSortedAndFiltered.get(active);
            dumpEntry(pw, indent, active, e);
        }

        int M = mEntries.size();
        pw.print(indent);
        pw.println("inactive notifications: " + (M - active));
        int inactiveCount = 0;
        for (int i = 0; i < M; i++) {
            Entry entry = mEntries.valueAt(i);
            if (!mSortedAndFiltered.contains(entry)) {
                dumpEntry(pw, indent, inactiveCount, entry);
                inactiveCount++;
            }
        }
    
private voiddumpEntry(java.io.PrintWriter pw, java.lang.String indent, int i, com.android.systemui.statusbar.NotificationData$Entry e)

        pw.print(indent);
        pw.println("  [" + i + "] key=" + e.key + " icon=" + e.icon);
        StatusBarNotification n = e.notification;
        pw.print(indent);
        pw.println("      pkg=" + n.getPackageName() + " id=" + n.getId() + " score=" +
                n.getScore());
        pw.print(indent);
        pw.println("      notification=" + n.getNotification());
        pw.print(indent);
        pw.println("      tickerText=\"" + n.getNotification().tickerText + "\"");
    
public voidfilterAndSort()

        mSortedAndFiltered.clear();
        mGroupsWithSummaries.clear();

        final int N = mEntries.size();
        for (int i = 0; i < N; i++) {
            Entry entry = mEntries.valueAt(i);
            StatusBarNotification sbn = entry.notification;

            if (shouldFilterOut(sbn)) {
                continue;
            }

            if (sbn.getNotification().isGroupSummary()) {
                mGroupsWithSummaries.add(sbn.getGroupKey());
            }
            mSortedAndFiltered.add(entry);
        }

        // Second pass: Filter out group children with summary.
        if (!mGroupsWithSummaries.isEmpty()) {
            final int M = mSortedAndFiltered.size();
            for (int i = M - 1; i >= 0; i--) {
                Entry ent = mSortedAndFiltered.get(i);
                StatusBarNotification sbn = ent.notification;
                if (sbn.getNotification().isGroupChild() &&
                        mGroupsWithSummaries.contains(sbn.getGroupKey())) {
                    mSortedAndFiltered.remove(i);
                }
            }
        }

        Collections.sort(mSortedAndFiltered, mRankingComparator);
    
public com.android.systemui.statusbar.NotificationData$Entryget(java.lang.String key)

        return mEntries.get(key);
    
public java.util.ArrayListgetActiveNotifications()
Returns the sorted list of active notifications (depending on {@link Environment}

This call doesn't update the list of active notifications. Call {@link #filterAndSort()} when the environment changes.

Don't hold on to or modify the returned list.

        return mSortedAndFiltered;
    
public intgetVisibilityOverride(java.lang.String key)

        if (mRankingMap != null) {
            mRankingMap.getRanking(key, mTmpRanking);
            return mTmpRanking.getVisibilityOverride();
        }
        return NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE;
    
public booleanhasActiveClearableNotifications()
Return whether there are any clearable notifications (that aren't errors).

        for (Entry e : mSortedAndFiltered) {
            if (e.expanded != null) { // the view successfully inflated
                if (e.notification.isClearable()) {
                    return true;
                }
            }
        }
        return false;
    
public booleanisAmbient(java.lang.String key)

        if (mRankingMap != null) {
            mRankingMap.getRanking(key, mTmpRanking);
            return mTmpRanking.isAmbient();
        }
        return false;
    
public booleanisGroupWithSummary(java.lang.String groupKey)

        return mGroupsWithSummaries.contains(groupKey);
    
private static booleanisSystemNotification(android.service.notification.StatusBarNotification sbn)

        String sbnPackage = sbn.getPackageName();
        return "android".equals(sbnPackage) || "com.android.systemui".equals(sbnPackage);
    
public com.android.systemui.statusbar.NotificationData$Entryremove(java.lang.String key, android.service.notification.NotificationListenerService.RankingMap ranking)

        Entry removed = mEntries.remove(key);
        if (removed == null) return null;
        updateRankingAndSort(ranking);
        return removed;
    
booleanshouldFilterOut(android.service.notification.StatusBarNotification sbn)

        if (!(mEnvironment.isDeviceProvisioned() ||
                showNotificationEvenIfUnprovisioned(sbn))) {
            return true;
        }

        if (!mEnvironment.isNotificationForCurrentProfiles(sbn)) {
            return true;
        }

        if (sbn.getNotification().visibility == Notification.VISIBILITY_SECRET &&
                mEnvironment.shouldHideSensitiveContents(sbn.getUserId())) {
            return true;
        }
        return false;
    
public static booleanshowNotificationEvenIfUnprovisioned(android.service.notification.StatusBarNotification sbn)

        return "android".equals(sbn.getPackageName())
                && sbn.getNotification().extras.getBoolean(Notification.EXTRA_ALLOW_DURING_SETUP);
    
public voidupdateRanking(android.service.notification.NotificationListenerService.RankingMap ranking)

        updateRankingAndSort(ranking);
    
private voidupdateRankingAndSort(android.service.notification.NotificationListenerService.RankingMap ranking)

        if (ranking != null) {
            mRankingMap = ranking;
        }
        filterAndSort();