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

Commit a60166c5 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Skip string concatenation for debug logs when possible" into main

parents f9227e6f 115ccd55
Loading
Loading
Loading
Loading
+20 −21
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.collection;
import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.internal.util.Preconditions.checkState;
import static com.android.systemui.statusbar.notification.collection.GroupEntry.ROOT_ENTRY;
import static com.android.systemui.statusbar.notification.collection.coordinator.BundleCoordinator.debugBundleLog;
import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_BUILD_STARTED;
import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_FINALIZE_FILTERING;
import static com.android.systemui.statusbar.notification.collection.listbuilder.PipelineState.STATE_FINALIZING;
@@ -433,7 +434,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
    private void buildList() {
        Trace.beginSection("ShadeListBuilder.buildList");
        mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
        debugLog(mPipelineState.getStateName() + "---------------------");
        debugBundleLog(TAG, () -> mPipelineState.getStateName() + "---------------------");

        if (mPendingEntries != null) {
            mAllEntries = mPendingEntries;
@@ -620,7 +621,8 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
            } else {
                if (applyFilters((NotificationEntry) listEntry, now, filters)) {
                    bundleChildrenToRemove.add(listEntry);
                    debugLog("annulled bundle child" + listEntry.getKey()
                    debugBundleLog(TAG, () ->
                            "annulled bundle child" + listEntry.getKey()
                                    + " bundle size: " + bundleEntry.getChildren().size());
                }
            }
@@ -717,15 +719,11 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
        // TODO(b/399736937) prefix channel with numbered id for fixed order:
        //  "bundle_01:android.app.news"
        if (be == null) {
            debugLog("BundleEntry not found for bundleId: " + id);
            debugBundleLog(TAG, () -> "BundleEntry not found for bundleId: " + id);
        }
        return be;
    }

    private void debugLog(String s) {
        BundleCoordinator.debugBundleLog(TAG, () -> s);
    }

    private void debugList(String s) {
        if (!BundleCoordinator.debugBundleUi) {
            return;
@@ -775,16 +773,16 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
            }
            String id = getNotifBundler().getBundleIdOrNull(listEntry);
            if (id == null) {
                debugLog("bundleNotifs: no bundle id for:" + listEntry.getKey());
                debugBundleLog(TAG, () ->"bundleNotifs: no bundle id for:" + listEntry.getKey());
                out.add(listEntry);
            } else {
                BundleEntry bundleEntry = getBundleEntry(id);
                if (bundleEntry == null) {
                    debugLog("bundleNotifs: BundleEntry NULL for: "
                    debugBundleLog(TAG, () ->"bundleNotifs: BundleEntry NULL for: "
                            + listEntry.getKey() + " bundleId:" + id);
                    out.add(listEntry);
                } else {
                    debugLog("bundleNotifs: ADD listEntry:" + listEntry.getKey()
                    debugBundleLog(TAG, () ->"bundleNotifs: ADD listEntry:" + listEntry.getKey()
                            + " to bundle:" + bundleEntry.getKey());
                    bundleEntry.addChild(listEntry);
                    listEntry.setParent(bundleEntry);
@@ -929,7 +927,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {

        // Iterate backwards, so that we can remove elements without affecting indices of
        // yet-to-be-accessed entries.
        debugLog(mPipelineState.getStateName() + " pruneIncompleteGroups size: "
        debugBundleLog(TAG, () -> mPipelineState.getStateName() + " pruneIncompleteGroups size: "
                + shadeList.size());

        for (int i = shadeList.size() - 1; i >= 0; i--) {
@@ -947,11 +945,11 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {

                if (bundleEntry.getChildren().isEmpty()) {
                    BundleEntry prunedBundle = (BundleEntry) shadeList.remove(i);
                    debugLog(mPipelineState.getStateName()
                    debugBundleLog(TAG, () -> mPipelineState.getStateName()
                            + " pruned empty bundle: "
                            + prunedBundle.getKey());
                } else {
                    debugLog(mPipelineState.getStateName()
                    debugBundleLog(TAG, () -> mPipelineState.getStateName()
                            + " skip pruning bundle: " + bundleEntry.getKey()
                            + " size: " + bundleEntry.getChildren().size());
                }
@@ -965,7 +963,8 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
            Set<String> groupsWithChildrenLostToStability) {
        final List<NotificationEntry> children = group.getRawChildren();
        final boolean hasSummary = group.getSummary() != null;
        debugLog(mPipelineState.getStateName() + " pruneGroupEntry " + group.getKey()
        debugBundleLog(TAG,
                () -> mPipelineState.getStateName() + " pruneGroupEntry " + group.getKey()
                        + " hasSummary:" + hasSummary
                        + " childCount:" + children.size()
        );
@@ -1008,14 +1007,14 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
            // its children (if any) directly to top-level.
            pruneGroupAtIndexAndPromoteAnyChildren(shadeList, group, i, "too small");
        } else {
            debugLog(mPipelineState.getStateName()
            debugBundleLog(TAG, () -> mPipelineState.getStateName()
                    + " group not pruned: " + group.getKey());
        }
    }

    private void pruneGroupAtIndexAndPromoteSummary(List<PipelineEntry> shadeList,
            GroupEntry group, int index) {
        debugLog(mPipelineState.getStateName() + " promote summary prune group:"
        debugBundleLog(TAG, () -> mPipelineState.getStateName() + " promote summary prune group:"
                + group.getKey());

        // Validate that the group has no children
@@ -1039,7 +1038,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
            GroupEntry group, int index, String reason) {

        final boolean inBundle = group.getAttachState().getParent() instanceof BundleEntry;
        debugLog(mPipelineState.getStateName()
        debugBundleLog(TAG, () -> mPipelineState.getStateName()
                + " " + reason + " => promote child prune group:" + group.getKey()
                + " parent: " + group.getAttachState().getParent().getKey()
                + " inBundle:" + inBundle
@@ -1050,7 +1049,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {

        // Validate that the replaced entry was the group entry
        if (oldEntry != group) {
            debugLog(mPipelineState.getStateName()
            debugBundleLog(TAG, () -> mPipelineState.getStateName()
                    + " oldEntry:" + oldEntry.getKey()
                    + " groupToRemove:" + group.getKey());
        }
+7 −11
Original line number Diff line number Diff line
@@ -60,22 +60,18 @@ constructor(
     */
    private val keyToControllerMap = mutableMapOf<String, NotifViewController?>()

    fun debugLog(s: String) {
        debugBundleLog(TAG, { s })
    }

    /** Build view and controller for BundleEntry. */
    fun inflateBundleEntry(bundleEntry: BundleEntry) {
        debugLog("inflateBundleEntry: ${bundleEntry.key}")
        debugBundleLog(TAG, { "inflateBundleEntry: ${bundleEntry.key}" })
        if (keyToControllerMap.containsKey(bundleEntry.key)) {
            // Skip if bundle is inflating or inflated.
            debugLog("already in map: ${bundleEntry.key}")
            debugBundleLog(TAG, { "already in map: ${bundleEntry.key}" })
            return
        }
        val parent: ViewGroup = listContainer.getViewParentForNotification()
        val inflationFinishedListener: (ExpandableNotificationRow) -> Unit = { row ->
            // A subset of NotificationRowBinderImpl.inflateViews
            debugLog("finished inflating: ${bundleEntry.key}")
            debugBundleLog(TAG, { "finished inflating: ${bundleEntry.key}" })
            bundleEntry.row = row
            val component =
                rowComponent
@@ -92,7 +88,7 @@ constructor(
                BundleHeaderViewModel(BundleInteractor(bundleEntry.bundleRepository))
            )
        }
        debugLog("calling inflate: ${bundleEntry.key}")
        debugBundleLog(TAG, { "calling inflate: ${bundleEntry.key}" })
        keyToControllerMap[bundleEntry.key] = null
        rowInflaterTaskProvider
            .get()
@@ -106,10 +102,10 @@ constructor(

    /** Return ExpandableNotificationRowController for BundleEntry. */
    fun requireNodeController(bundleEntry: BundleEntry): NodeController {
        debugLog(
        debugBundleLog(TAG, {
            "requireNodeController: ${bundleEntry.key}" +
                    "controller: ${keyToControllerMap[bundleEntry.key]}"
        )
        })
        return keyToControllerMap[bundleEntry.key]
            ?: error("No view has been registered for bundle: ${bundleEntry.key}")
    }
+2 −6
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ constructor(
        return applicationScope.launchTraced("AsyncRowInflater-bg", inflationCoroutineDispatcher) {
            val view =
                try {
                    debugLog("inflater.inflate resId: $resId parent: $parent")
                    debugBundleLog(TAG, { "inflater.inflate resId: $resId parent: $parent" });
                    inflater.inflate(resId, parent, false)
                } catch (ex: RuntimeException) {
                    // Probably a Looper failure, retry on the UI thread
@@ -78,7 +78,7 @@ constructor(
            withContextTraced("AsyncRowInflater-ui", mainCoroutineDispatcher) {
                // If the inflate failed on the inflation thread, try again on the main thread
                val finalView = view ?: inflater.inflate(resId, parent, false)
                debugLog("finalView: $finalView")
                debugBundleLog(TAG, { "finalView: $finalView" });

                // Inform the listener of the completion
                listener.onInflateFinished(finalView, resId, parent)
@@ -86,10 +86,6 @@ constructor(
        }
    }

    private inline fun debugLog(s: String) {
        debugBundleLog(TAG, { s });
    }

    /**
     * Callback interface (identical to the one from AsyncLayoutInflater) for receiving the inflated
     * view
+5 −11
Original line number Diff line number Diff line
@@ -88,11 +88,6 @@ public class RowInflaterTask implements InflationTask,
        inflate(context, parent, entry, null, listener);
    }

    private void debugLog(String s) {
        // TODO(b/399736937) update debug logs for bundles to using lambda
        debugBundleLog(TAG,  () -> s);
    }

    public void inflate(Context context, ViewGroup parent, BundleEntry entry,
            @Nullable Executor listenerExecutor, RowInflationFinishedListener listener) {
        if (TRACE_ORIGIN) {
@@ -103,11 +98,11 @@ public class RowInflaterTask implements InflationTask,
        RowAsyncLayoutInflater asyncLayoutFactory = new RowAsyncLayoutInflater(
                entry, mSystemClock, mLogger, mUserTracker.getUserHandle());
        if (Flags.useNotifInflationThreadForRow()) {
            debugLog("mAsyncRowInflater.inflate bundle: " + entry.getKey());
            debugBundleLog(TAG,  () -> "mAsyncRowInflater.inflate bundle: " + entry.getKey());
            mAsyncRowInflater.inflate(context, asyncLayoutFactory,
                    R.layout.status_bar_notification_row, parent, this);
        } else {
            debugLog("AsyncLayoutInflater.inflate bundle: " + entry.getKey());
            debugBundleLog(TAG,  () -> "AsyncLayoutInflater.inflate bundle: " + entry.getKey());
            AsyncLayoutInflater inflater = new AsyncLayoutInflater(context, asyncLayoutFactory);
            inflater.inflate(R.layout.status_bar_notification_row, parent, listenerExecutor, this);
        }
@@ -223,17 +218,16 @@ public class RowInflaterTask implements InflationTask,

    @Override
    public void onInflateFinished(View view, int resid, ViewGroup parent) {
        debugLog("mAsyncRowInflater.inflate onInflateFinished: " + view
        debugBundleLog(TAG,  () -> "mAsyncRowInflater.inflate onInflateFinished: " + view
                + " parent: " + parent
                + " mEntry: " + mEntry
                + " mBundleEntry: " + mBundleEntry
                + " mCancelled: " + mCancelled
        );
                + " mCancelled: " + mCancelled);
        final long elapsedMs = mSystemClock.elapsedRealtime() - mInflateStartTimeMs;
        if (mEntry == null) {
            if (mBundleEntry != null) {
                if (!mCancelled) {
                    debugLog( "mListener.onInflationFinished for bundle:"
                    debugBundleLog(TAG,  () -> "mListener.onInflationFinished for bundle:"
                            + mBundleEntry.getKey());
                    mListener.onInflationFinished((ExpandableNotificationRow) view);
                }