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

Commit 4324a25d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ic8f22359,I3b94dee1

* changes:
  Don't query settings for the notification history state every time we update the footer.
  Add trace sections for comparison of the notification pipelines
parents 849d2442 08a567fd
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
        if (!mNotifPipelineFlags.checkLegacyPipelineEnabled()) {
            return;
        }
        Trace.beginSection("NotificationViewHierarchyManager.updateNotificationViews");

        beginUpdate();

@@ -353,6 +354,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
        mListContainer.onNotificationViewUpdateFinished();

        endUpdate();
        Trace.endSection();
    }

    /**
@@ -362,6 +364,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
     * {@link com.android.systemui.statusbar.notification.collection.coordinator.StackCoordinator}
     */
    private void updateNotifStats() {
        Trace.beginSection("NotificationViewHierarchyManager.updateNotifStats");
        boolean hasNonClearableAlertingNotifs = false;
        boolean hasClearableAlertingNotifs = false;
        boolean hasNonClearableSilentNotifs = false;
@@ -403,6 +406,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
                hasNonClearableSilentNotifs /* hasNonClearableSilentNotifs */,
                hasClearableSilentNotifs /* hasClearableSilentNotifs */
        ));
        Trace.endSection();
    }

    /**
@@ -520,7 +524,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
    }

    private void updateRowStatesInternal() {
        Trace.beginSection("NotificationViewHierarchyManager#updateRowStates");
        Trace.beginSection("NotificationViewHierarchyManager.updateRowStates");
        final int N = mListContainer.getContainerChildCount();

        int visibleNotifications = 0;
+25 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.Ranking;
@@ -343,11 +344,14 @@ public class NotificationEntryManager implements
    private final InflationCallback mInflationCallback = new InflationCallback() {
        @Override
        public void handleInflationException(NotificationEntry entry, Exception e) {
            Trace.beginSection("NotificationEntryManager.handleInflationException");
            NotificationEntryManager.this.handleInflationException(entry.getSbn(), e);
            Trace.endSection();
        }

        @Override
        public void onAsyncInflationFinished(NotificationEntry entry) {
            Trace.beginSection("NotificationEntryManager.onAsyncInflationFinished");
            mPendingNotifications.remove(entry.getKey());
            // If there was an async task started after the removal, we don't want to add it back to
            // the list, otherwise we might get leaks.
@@ -369,6 +373,7 @@ public class NotificationEntryManager implements
                    }
                }
            }
            Trace.endSection();
        }
    };

@@ -463,6 +468,7 @@ public class NotificationEntryManager implements
            boolean forceRemove,
            DismissedByUserStats dismissedByUserStats,
            int reason) {
        Trace.beginSection("NotificationEntryManager.removeNotificationInternal");

        final NotificationEntry entry = getActiveNotificationUnfiltered(key);

@@ -470,6 +476,7 @@ public class NotificationEntryManager implements
            if (interceptor.onNotificationRemoveRequested(key, entry, reason)) {
                // Remove intercepted; log and skip
                mLogger.logRemovalIntercepted(key);
                Trace.endSection();
                return;
            }
        }
@@ -557,6 +564,7 @@ public class NotificationEntryManager implements
                mLeakDetector.trackGarbage(entry);
            }
        }
        Trace.endSection();
    }

    private void sendNotificationRemovalToServer(
@@ -620,6 +628,7 @@ public class NotificationEntryManager implements
    private void addNotificationInternal(
            StatusBarNotification notification,
            RankingMap rankingMap) throws InflationException {
        Trace.beginSection("NotificationEntryManager.addNotificationInternal");
        String key = notification.getKey();
        if (DEBUG) {
            Log.d(TAG, "addNotification key=" + key);
@@ -667,6 +676,7 @@ public class NotificationEntryManager implements
        for (NotifCollectionListener listener : mNotifCollectionListeners) {
            listener.onRankingApplied();
        }
        Trace.endSection();
    }

    public void addNotification(StatusBarNotification notification, RankingMap ranking) {
@@ -679,12 +689,14 @@ public class NotificationEntryManager implements

    private void updateNotificationInternal(StatusBarNotification notification,
            RankingMap ranking) throws InflationException {
        Trace.beginSection("NotificationEntryManager.updateNotificationInternal");
        if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")");

        final String key = notification.getKey();
        abortExistingInflation(key, "updateNotification");
        final NotificationEntry entry = getActiveNotificationUnfiltered(key);
        if (entry == null) {
            Trace.endSection();
            return;
        }

@@ -721,6 +733,7 @@ public class NotificationEntryManager implements
        for (NotifCollectionListener listener : mNotifCollectionListeners) {
            listener.onRankingApplied();
        }
        Trace.endSection();
    }

    public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
@@ -740,14 +753,17 @@ public class NotificationEntryManager implements
            mLogger.logUseWhileNewPipelineActive("updateNotifications", reason);
            return;
        }
        Trace.beginSection("NotificationEntryManager.updateNotifications");
        reapplyFilterAndSort(reason);
        if (mPresenter != null) {
            mPresenter.updateNotificationViews(reason);
        }
        mNotifLiveDataStore.setActiveNotifList(getVisibleNotifications());
        Trace.endSection();
    }

    public void updateNotificationRanking(RankingMap rankingMap) {
        Trace.beginSection("NotificationEntryManager.updateNotificationRanking");
        List<NotificationEntry> entries = new ArrayList<>();
        entries.addAll(getVisibleNotifications());
        entries.addAll(mPendingNotifications.values());
@@ -788,6 +804,7 @@ public class NotificationEntryManager implements
        for (NotifCollectionListener listener : mNotifCollectionListeners) {
            listener.onRankingApplied();
        }
        Trace.endSection();
    }

    void notifyChannelModified(
@@ -887,6 +904,7 @@ public class NotificationEntryManager implements

    /** @return list of active notifications filtered for the current user */
    public List<NotificationEntry> getActiveNotificationsForCurrentUser() {
        Trace.beginSection("NotificationEntryManager.getActiveNotificationsForCurrentUser");
        Assert.isMainThread();
        ArrayList<NotificationEntry> filtered = new ArrayList<>();

@@ -898,7 +916,7 @@ public class NotificationEntryManager implements
            }
            filtered.add(entry);
        }

        Trace.endSection();
        return filtered;
    }

@@ -908,10 +926,12 @@ public class NotificationEntryManager implements
     * @param reason the reason for calling this method, which will be logged
     */
    public void updateRanking(RankingMap rankingMap, String reason) {
        Trace.beginSection("NotificationEntryManager.updateRanking");
        updateRankingAndSort(rankingMap, reason);
        for (NotifCollectionListener listener : mNotifCollectionListeners) {
            listener.onRankingApplied();
        }
        Trace.endSection();
    }

    /** Resorts / filters the current notification set with the current RankingMap */
@@ -920,7 +940,9 @@ public class NotificationEntryManager implements
            mLogger.logUseWhileNewPipelineActive("reapplyFilterAndSort", reason);
            return;
        }
        Trace.beginSection("NotificationEntryManager.reapplyFilterAndSort");
        updateRankingAndSort(mRanker.getRankingMap(), reason);
        Trace.endSection();
    }

    /** Calls to NotificationRankingManager and updates mSortedAndFiltered */
@@ -929,9 +951,11 @@ public class NotificationEntryManager implements
            mLogger.logUseWhileNewPipelineActive("updateRankingAndSort", reason);
            return;
        }
        Trace.beginSection("NotificationEntryManager.updateRankingAndSort");
        mSortedAndFiltered.clear();
        mSortedAndFiltered.addAll(mRanker.updateRanking(
                rankingMap, mActiveNotifications.values(), reason));
        Trace.endSection();
    }

    /** dump the current active notification list. Called from StatusBar */
+10 −0
Original line number Diff line number Diff line
@@ -426,14 +426,18 @@ public class ShadeListBuilder implements Dumpable {
        }
        Trace.endSection();

        Trace.beginSection("ShadeListBuilder.logEndBuildList");
        // Step 9: We're done!
        mLogger.logEndBuildList(
                mIterationCount,
                mReadOnlyNotifList.size(),
                countChildren(mReadOnlyNotifList));
        if (mAlwaysLogList || mIterationCount % 10 == 0) {
            Trace.beginSection("ShadeListBuilder.logFinalList");
            mLogger.logFinalList(mNotifList);
            Trace.endSection();
        }
        Trace.endSection();
        mPipelineState.setState(STATE_IDLE);
        mIterationCount++;
        Trace.endSection();
@@ -996,16 +1000,20 @@ public class ShadeListBuilder implements Dumpable {
    }

    private void freeEmptyGroups() {
        Trace.beginSection("ShadeListBuilder.freeEmptyGroups");
        mGroups.values().removeIf(ge -> ge.getSummary() == null && ge.getChildren().isEmpty());
        Trace.endSection();
    }

    private void logChanges() {
        Trace.beginSection("ShadeListBuilder.logChanges");
        for (NotificationEntry entry : mAllEntries) {
            logAttachStateChanges(entry);
        }
        for (GroupEntry group : mGroups.values()) {
            logAttachStateChanges(group);
        }
        Trace.endSection();
    }

    private void logAttachStateChanges(ListEntry entry) {
@@ -1083,6 +1091,7 @@ public class ShadeListBuilder implements Dumpable {
    }

    private void cleanupPluggables() {
        Trace.beginSection("ShadeListBuilder.cleanupPluggables");
        callOnCleanup(mNotifPreGroupFilters);
        callOnCleanup(mNotifPromoters);
        callOnCleanup(mNotifFinalizeFilters);
@@ -1093,6 +1102,7 @@ public class ShadeListBuilder implements Dumpable {
        }

        callOnCleanup(List.of(getStabilityManager()));
        Trace.endSection();
    }

    private void callOnCleanup(List<? extends Pluggable<?>> pluggables) {
+6 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.statusbar.notification.collection.render.NotifStackC
import com.android.systemui.statusbar.notification.collection.render.NotifStats
import com.android.systemui.statusbar.notification.stack.BUCKET_SILENT
import com.android.systemui.statusbar.phone.NotificationIconAreaController
import com.android.systemui.util.traceSection
import javax.inject.Inject

/**
@@ -38,7 +39,8 @@ class StackCoordinator @Inject internal constructor(
        pipeline.addOnAfterRenderListListener(::onAfterRenderList)
    }

    fun onAfterRenderList(entries: List<ListEntry>, controller: NotifStackController) {
    fun onAfterRenderList(entries: List<ListEntry>, controller: NotifStackController) =
        traceSection("StackCoordinator.onAfterRenderList") {
            controller.setNotifStats(calculateNotifStats(entries))
            notificationIconAreaController.updateNotificationIcons(entries)
        }
+6 −3
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.children
import com.android.systemui.util.foldToSparseArray
import com.android.systemui.util.takeUntil
import com.android.systemui.util.traceSection
import javax.inject.Inject

/**
@@ -157,7 +158,9 @@ class NotificationSectionsManager @Inject internal constructor(
            }
        }
    }
    private fun logShadeContents() = parent.children.forEachIndexed(::logShadeChild)
    private fun logShadeContents() = traceSection("NotifSectionsManager.logShadeContents") {
        parent.children.forEachIndexed(::logShadeChild)
    }

    private val isUsingMultipleSections: Boolean
        get() = sectionsFeatureManager.getNumberOfBuckets() > 1
@@ -221,10 +224,10 @@ class NotificationSectionsManager @Inject internal constructor(
     * Should be called whenever notifs are added, removed, or updated. Updates section boundary
     * bookkeeping and adds/moves/removes section headers if appropriate.
     */
    fun updateSectionBoundaries(reason: String) {
    fun updateSectionBoundaries(reason: String) = traceSection("NotifSectionsManager.update") {
        notifPipelineFlags.checkLegacyPipelineEnabled()
        if (!isUsingMultipleSections) {
            return
            return@traceSection
        }
        logger.logStartSectionUpdate(reason)

Loading