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

Commit 5813c352 authored by Yuri Lin's avatar Yuri Lin Committed by Android (Google) Code Review
Browse files

Merge "Log bundle expands/collapses" into main

parents 22913bb0 26895010
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.PluginManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.SmartReplyController
import com.android.systemui.statusbar.notification.BundleInteractionLogger
import com.android.systemui.statusbar.notification.ColorUpdateLogger
import com.android.systemui.statusbar.notification.collection.EntryAdapter
import com.android.systemui.statusbar.notification.collection.EntryAdapterFactory
@@ -113,6 +114,7 @@ class ExpandableNotificationRowControllerTest : SysuiTestCase() {
    private val msdlPlayer: MSDLPlayer = mock()
    private val rebindingTracker: NotificationRebindingTracker = mock()
    private val entryAdapterFactory: EntryAdapterFactory = mock()
    private val bundleInteractionLogger: BundleInteractionLogger = mock()
    private lateinit var controller: ExpandableNotificationRowController

    @Before
@@ -164,6 +166,7 @@ class ExpandableNotificationRowControllerTest : SysuiTestCase() {
            rebindingTracker,
            entryAdapterFactory,
            kosmos.windowRootViewBlurInteractor,
            bundleInteractionLogger,
        )
    }

+15 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification

import android.service.notification.Adjustment
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import com.android.internal.util.FrameworkStatsLog
@@ -24,13 +25,26 @@ 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);
    @UiEvent(doc = "User dismissed a bundle") NOTIF_BUNDLE_DISMISSED(2264),
    @UiEvent(doc = "User expanded a bundle") NOTIF_BUNDLE_EXPANDED(2343),
    @UiEvent(doc = "User collapsed a bundle") NOTIF_BUNDLE_COLLAPSED(2344);

    override fun getId() = _id
}

class BundleInteractionLogger @Inject constructor() {

    fun logBundleExpansionChanged(@Adjustment.Types bundleType: Int, nowExpanded: Boolean) {
        FrameworkStatsLog.write(
            FrameworkStatsLog.NOTIFICATION_BUNDLE_INTERACTED,
            /* optional int32 event_id */ if (nowExpanded)
                BundleInteractedEvent.NOTIF_BUNDLE_EXPANDED.id
            else BundleInteractedEvent.NOTIF_BUNDLE_COLLAPSED.id,
            /* optional int32 type */ bundleType,
            /* optional bool contents_shown */ true, // irrelevant but inherently true
        )
    }

    fun logBundleDismissed(bundle: BundleEntry) {
        FrameworkStatsLog.write(
            FrameworkStatsLog.NOTIFICATION_BUNDLE_INTERACTED,
+4 −0
Original line number Diff line number Diff line
@@ -257,6 +257,10 @@ class BundleEntryAdapter(
        // do nothing. it should not be possible for a bundle to be contained within a bundle
        Log.wtf(TAG, "onBundleDisabled() called")
    }

    override fun getBundleType(): Int {
        return entry.bundleRepository.bundleType
    }
}

private const val TAG = "BundleEntryAdapter"
+5 −0
Original line number Diff line number Diff line
@@ -243,5 +243,10 @@ public interface EntryAdapter {
     * Processes when the bundle this entry is within is disabled.
     */
    void onBundleDisabled();

    /**
     * Returns the bundle type of this entry if it is a bundle.
     */
    int getBundleType();
}
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import android.os.SystemClock
import android.service.notification.NotificationListenerService
import android.service.notification.StatusBarNotification
import android.util.Log
import com.android.internal.logging.MetricsLogger
import com.android.systemui.statusbar.notification.NotificationActivityStarter
import com.android.systemui.statusbar.notification.collection.coordinator.BundleCoordinator.Companion.debugBundleAppName
@@ -297,4 +298,11 @@ class NotificationEntryAdapter(
            row.attachedChildren?.forEach { it.entryAdapter.onBundleDisabled() }
        }
    }

    override fun getBundleType(): Int {
        Log.wtf(TAG, "getBundleType() called on non-bundle entry")
        return -1
    }
}

private const val TAG = "NotifEntryAdapter"
Loading