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

Commit 6976087e authored by Ned Burns's avatar Ned Burns
Browse files

Inline a few methods in NotificationEntryManager

These methods were only called in one location and either (a) weren't
safe to call in any other situation or (b) weren't conceptually
distinct from their caller.

Test: atest
Change-Id: I7bbb2e9b51b678144f13897db27ad324e78be587
parent ef2ef6c9
Loading
Loading
Loading
Loading
+20 −48
Original line number Diff line number Diff line
@@ -253,21 +253,6 @@ public class NotificationEntryManager implements
        }
    }

    private void addEntry(NotificationData.Entry shadeEntry) {
        if (shadeEntry == null) {
            return;
        }
        // Add the expanded view and icon.
        mNotificationData.add(shadeEntry);
        tagForeground(shadeEntry.notification);
        updateNotifications();
        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onNotificationAdded(shadeEntry);
        }

        maybeScheduleUpdateNotificationViews(shadeEntry);
    }

    private void maybeScheduleUpdateNotificationViews(NotificationData.Entry entry) {
        long audibleAlertTimeout = RECENTLY_ALERTED_THRESHOLD_MS
                - (System.currentTimeMillis() - entry.lastAudiblyAlertedMs);
@@ -289,7 +274,13 @@ public class NotificationEntryManager implements
                for (NotificationEntryListener listener : mNotificationEntryListeners) {
                    listener.onEntryInflated(entry, inflatedFlags);
                }
                addEntry(entry);
                mNotificationData.add(entry);
                tagForeground(entry.notification);
                updateNotifications();
                for (NotificationEntryListener listener : mNotificationEntryListeners) {
                    listener.onNotificationAdded(entry);
                }
                maybeScheduleUpdateNotificationViews(entry);
            } else {
                for (NotificationEntryListener listener : mNotificationEntryListeners) {
                    listener.onEntryReinflated(entry);
@@ -347,7 +338,9 @@ public class NotificationEntryManager implements
                // Let's remove the children if this was a summary
                handleGroupSummaryRemoved(key);

                removeNotificationViews(key, ranking);
                mNotificationData.remove(key, ranking);
                updateNotifications();
                Dependency.get(LeakDetector.class).trackGarbage(entry);

                for (NotificationEntryListener listener : mNotificationEntryListeners) {
                    listener.onEntryRemoved(entry, visibility, removedByUser);
@@ -356,18 +349,6 @@ public class NotificationEntryManager implements
        }
    }

    private StatusBarNotification removeNotificationViews(String key,
            NotificationListenerService.RankingMap ranking) {
        NotificationData.Entry entry = mNotificationData.remove(key, ranking);
        if (entry == null) {
            Log.w(TAG, "removeNotification for unknown key: " + key);
            return null;
        }
        updateNotifications();
        Dependency.get(LeakDetector.class).trackGarbage(entry);
        return entry.notification;
    }

    /**
     * Ensures that the group children are cancelled immediately when the group summary is cancelled
     * instead of waiting for the notification manager to send all cancels. Otherwise this could
@@ -423,36 +404,27 @@ public class NotificationEntryManager implements
        }
    }

    private NotificationData.Entry createNotificationEntry(
            StatusBarNotification sbn, NotificationListenerService.Ranking ranking)
            throws InflationException {
    private void addNotificationInternal(StatusBarNotification notification,
            NotificationListenerService.RankingMap rankingMap) throws InflationException {
        String key = notification.getKey();
        if (DEBUG) {
            Log.d(TAG, "createNotificationEntry(notification=" + sbn + " " + ranking);
            Log.d(TAG, "addNotification key=" + key);
        }

        NotificationData.Entry entry = new NotificationData.Entry(sbn, ranking);
        mNotificationData.updateRanking(rankingMap);
        NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking();
        rankingMap.getRanking(key, ranking);

        NotificationData.Entry entry = new NotificationData.Entry(notification, ranking);
        if (BubbleController.shouldAutoBubble(getContext(), entry)) {
            entry.setIsBubble(true);
        }

        Dependency.get(LeakDetector.class).trackInstance(entry);
        // Construct the expanded view.
        getRowBinder().inflateViews(entry, () -> performRemoveNotification(sbn),
        getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification),
                mNotificationData.get(entry.key) != null);
        return entry;
    }

    private void addNotificationInternal(StatusBarNotification notification,
            NotificationListenerService.RankingMap rankingMap) throws InflationException {
        String key = notification.getKey();
        if (DEBUG) {
            Log.d(TAG, "addNotification key=" + key);
        }

        mNotificationData.updateRanking(rankingMap);
        NotificationListenerService.Ranking ranking = new NotificationListenerService.Ranking();
        rankingMap.getRanking(key, ranking);
        NotificationData.Entry entry = createNotificationEntry(notification, ranking);
        abortExistingInflation(key);

        mPendingNotifications.put(key, entry);