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

Commit 1067cfe7 authored by Yuri Lin's avatar Yuri Lin
Browse files

Log bundle dismissal in NotificationBundleInteracted.

This change does not yet include a real value for whether the bundle's contents were shown, only that it was dismissed.

Bug: 415113012
Test: atom tester
Flag: com.android.systemui.notification_bundle_ui
Change-Id: If167567b656e832510f7d5d3c3b6ea9b89d1f659
parent a8d48c07
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.LogBufferEulogizer;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.BundleInteractionLogger;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.collection.NoManSimulator.NotifEvent;
import com.android.systemui.statusbar.notification.collection.NotifCollection.CancellationReason;
@@ -131,6 +132,7 @@ public class NotifCollectionTest extends SysuiTestCase {
    @Spy private RecordingCollectionListener mCollectionListener;
    @Mock private CollectionReadyForBuildListener mBuildListener;
    @Mock private NotificationDismissibilityProvider mDismissibilityProvider;
    @Mock private BundleInteractionLogger mBundleLogger;

    @Spy private RecordingLifetimeExtender mExtender1 = new RecordingLifetimeExtender("Extender1");
    @Spy private RecordingLifetimeExtender mExtender2 = new RecordingLifetimeExtender("Extender2");
@@ -175,7 +177,8 @@ public class NotifCollectionTest extends SysuiTestCase {
                mBgExecutor,
                mEulogizer,
                mock(DumpManager.class),
                mDismissibilityProvider);
                mDismissibilityProvider,
                mBundleLogger);
        mCollection.attach(mGroupCoalescer);
        mCollection.addCollectionListener(mCollectionListener);
        mCollection.setBuildListener(mBuildListener);
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.notification

import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import com.android.internal.util.FrameworkStatsLog
import com.android.systemui.statusbar.notification.collection.BundleEntry
import javax.inject.Inject

enum class BundleInteractedEvent(private val _id: Int) : UiEventLogger.UiEventEnum {
    @UiEvent(doc = "User dismissed a bundle") NOTIF_BUNDLE_DISMISSED(2264);

    override fun getId() = _id
}

class BundleInteractionLogger @Inject constructor() {

    fun logBundleDismissed(bundle: BundleEntry) {
        FrameworkStatsLog.write(
            FrameworkStatsLog.NOTIFICATION_BUNDLE_INTERACTED,
            /* optional int32 event_id */ BundleInteractedEvent.NOTIF_BUNDLE_DISMISSED.id,
            /* optional int32 type */ bundle.bundleRepository.bundleType,
            // TODO: b/415113012 - correctly reflect whether the bundle was ever expanded
            /* optional bool contents_shown */ false,
        )
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.LogBufferEulogizer;
import com.android.systemui.statusbar.notification.BundleInteractionLogger;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.collection.coalescer.CoalescedEvent;
import com.android.systemui.statusbar.notification.collection.coalescer.GroupCoalescer;
@@ -157,6 +158,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable {
    private final DumpManager mDumpManager;
    private final NotifCollectionInconsistencyTracker mInconsistencyTracker;
    private final NotificationDismissibilityProvider mDismissibilityProvider;
    private final BundleInteractionLogger mBundleLogger;

    private final Map<String, NotificationEntry> mNotificationSet = new ArrayMap<>();
    private final Collection<NotificationEntry> mReadOnlyNotificationSet =
@@ -191,7 +193,8 @@ public class NotifCollection implements Dumpable, PipelineDumpable {
            @Background Executor bgExecutor,
            LogBufferEulogizer logBufferEulogizer,
            DumpManager dumpManager,
            NotificationDismissibilityProvider dismissibilityProvider) {
            NotificationDismissibilityProvider dismissibilityProvider,
            BundleInteractionLogger bundleLogger) {
        mStatusBarService = statusBarService;
        mClock = clock;
        mNotifPipelineFlags = notifPipelineFlags;
@@ -202,6 +205,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable {
        mDumpManager = dumpManager;
        mInconsistencyTracker = new NotifCollectionInconsistencyTracker(mLogger);
        mDismissibilityProvider = dismissibilityProvider;
        mBundleLogger = bundleLogger;
    }

    /** Initializes the NotifCollection and registers it to receive notification events. */
@@ -1124,6 +1128,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable {
        BundleDismissalRunnable runnable = new BundleDismissalRunnable(bundleEntry,
                cancellationReason, statsCreator);
        mLogger.logBundleDismissalRegistered(runnable);
        mBundleLogger.logBundleDismissed(bundleEntry);
        return runnable;
    }