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

Commit 857bc685 authored by Robert Snoeberger's avatar Robert Snoeberger
Browse files

Disable MediaNotificationProcessor

Disabling MediaNotificationProcessor when the new media experience is
enabled. The notification views that are inflated won't be shown anyway
so it is just a waste of time and memory.

Fixes: 157732475
Test: manual - heap_profile systemui while SoundCloud is playing. Verify
that flame graph doesn't show a hotspot for MediaNotificationProcessor.processNotification

Change-Id: I252697255ce2b30c99d244acd4e30cd56eb0416d
parent fa99bb4b
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import android.widget.RemoteViews;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.ImageMessageConsumer;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.media.MediaDataManagerKt;
import com.android.systemui.media.MediaFeatureFlag;
import com.android.systemui.statusbar.InflationTask;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.SmartReplyController;
@@ -71,6 +73,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
    public static final String TAG = "NotifContentInflater";

    private boolean mInflateSynchronously = false;
    private final boolean mIsMediaInQS;
    private final NotificationRemoteInputManager mRemoteInputManager;
    private final NotifRemoteViewCache mRemoteViewCache;
    private final Lazy<SmartReplyConstants> mSmartReplyConstants;
@@ -85,12 +88,14 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            Lazy<SmartReplyConstants> smartReplyConstants,
            Lazy<SmartReplyController> smartReplyController,
            ConversationNotificationProcessor conversationProcessor,
            MediaFeatureFlag mediaFeatureFlag,
            @Background Executor bgExecutor) {
        mRemoteViewCache = remoteViewCache;
        mRemoteInputManager = remoteInputManager;
        mSmartReplyConstants = smartReplyConstants;
        mSmartReplyController = smartReplyController;
        mConversationProcessor = conversationProcessor;
        mIsMediaInQS = mediaFeatureFlag.getEnabled();
        mBgExecutor = bgExecutor;
    }

@@ -135,7 +140,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                bindParams.usesIncreasedHeight,
                bindParams.usesIncreasedHeadsUpHeight,
                callback,
                mRemoteInputManager.getRemoteViewsOnClickHandler());
                mRemoteInputManager.getRemoteViewsOnClickHandler(),
                mIsMediaInQS);
        if (mInflateSynchronously) {
            task.onPostExecute(task.doInBackground());
        } else {
@@ -711,6 +717,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        private RemoteViews.OnClickHandler mRemoteViewClickHandler;
        private CancellationSignal mCancellationSignal;
        private final ConversationNotificationProcessor mConversationProcessor;
        private final boolean mIsMediaInQS;

        private AsyncInflationTask(
                Executor bgExecutor,
@@ -726,7 +733,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                boolean usesIncreasedHeight,
                boolean usesIncreasedHeadsUpHeight,
                InflationCallback callback,
                RemoteViews.OnClickHandler remoteViewClickHandler) {
                RemoteViews.OnClickHandler remoteViewClickHandler,
                boolean isMediaFlagEnabled) {
            mEntry = entry;
            mRow = row;
            mSmartReplyConstants = smartReplyConstants;
@@ -742,6 +750,7 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            mRemoteViewClickHandler = remoteViewClickHandler;
            mCallback = callback;
            mConversationProcessor = conversationProcessor;
            mIsMediaInQS = isMediaFlagEnabled;
            entry.setInflationTask(this);
        }

@@ -765,7 +774,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                    packageContext = new RtlEnabledContext(packageContext);
                }
                Notification notification = sbn.getNotification();
                if (notification.isMediaNotification()) {
                if (notification.isMediaNotification() && !(mIsMediaInQS
                        && MediaDataManagerKt.isMediaNotification(sbn))) {
                    MediaNotificationProcessor processor = new MediaNotificationProcessor(mContext,
                            packageContext);
                    processor.processNotification(notification, recoveredBuilder);
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import androidx.test.filters.SmallTest;
import androidx.test.filters.Suppress;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.media.MediaFeatureFlag;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.SmartReplyController;
import com.android.systemui.statusbar.notification.ConversationNotificationProcessor;
@@ -110,6 +111,7 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
                () -> smartReplyConstants,
                () -> smartReplyController,
                mConversationNotificationProcessor,
                mock(MediaFeatureFlag.class),
                mock(Executor.class));
    }

+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.util.NotificationMessagingUtil;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.media.MediaFeatureFlag;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.plugins.PluginManager;
@@ -197,6 +198,7 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase {
                () -> mock(SmartReplyConstants.class),
                () -> mock(SmartReplyController.class),
                mock(ConversationNotificationProcessor.class),
                mock(MediaFeatureFlag.class),
                mBgExecutor);
        mRowContentBindStage = new RowContentBindStage(
                binder,
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.widget.RemoteViews;
import com.android.systemui.TestableDependency;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.bubbles.BubblesTestActivity;
import com.android.systemui.media.MediaFeatureFlag;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -133,6 +134,7 @@ public class NotificationTestHelper {
                () -> mock(SmartReplyConstants.class),
                () -> mock(SmartReplyController.class),
                mock(ConversationNotificationProcessor.class),
                mock(MediaFeatureFlag.class),
                mock(Executor.class));
        contentBinder.setInflateSynchronously(true);
        mBindStage = new RowContentBindStage(contentBinder,