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

Commit 89d7d605 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Add trace sections to visual interruption decisions

Hopefully the refactor doesn't cause any performance regressions, but
let's record trace sections just in case.

Bug: 261728888
Test: atest NotificationInterruptStateProviderWrapperTest
Test: atest VisualInterruptionDecisionProviderImplTest
Flag: ACONFIG com.android.systemui.visual_interruptions_refactor TEAMFOOD
Change-Id: I0e6809635d69245574495a8e79c5da4548048d46
parent 7ac4f12b
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.systemui.statusbar.notification.interruption

import com.android.app.tracing.traceSection
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.RefactorFlagUtils
@@ -82,20 +83,33 @@ class NotificationInterruptStateProviderWrapper(
    }

    override fun makeUnloggedHeadsUpDecision(entry: NotificationEntry): Decision =
        traceSection("NotificationInterruptStateProviderWrapper#makeUnloggedHeadsUpDecision") {
            wrapped.checkHeadsUp(entry, /* log= */ false).let { DecisionImpl.of(it) }
        }

    override fun makeAndLogHeadsUpDecision(entry: NotificationEntry): Decision =
        traceSection("NotificationInterruptStateProviderWrapper#makeAndLogHeadsUpDecision") {
            wrapped.checkHeadsUp(entry, /* log= */ true).let { DecisionImpl.of(it) }
        }

    override fun makeUnloggedFullScreenIntentDecision(entry: NotificationEntry) =
        wrapped.getFullScreenIntentDecision(entry).let { FullScreenIntentDecisionImpl(entry, it) }
        traceSection(
            "NotificationInterruptStateProviderWrapper#makeUnloggedFullScreenIntentDecision"
        ) {
            wrapped.getFullScreenIntentDecision(entry).let {
                FullScreenIntentDecisionImpl(entry, it)
            }
        }

    override fun logFullScreenIntentDecision(decision: FullScreenIntentDecision) {
    override fun logFullScreenIntentDecision(decision: FullScreenIntentDecision) =
        traceSection("NotificationInterruptStateProviderWrapper#logFullScreenIntentDecision") {
            (decision as FullScreenIntentDecisionImpl).let {
                wrapped.logFullScreenIntentDecision(it.originalEntry, it.originalDecision)
            }
        }

    override fun makeAndLogBubbleDecision(entry: NotificationEntry): Decision =
        traceSection("NotificationInterruptStateProviderWrapper#makeAndLogBubbleDecision") {
            wrapped.shouldBubbleUp(entry).let { DecisionImpl.of(it) }
        }
}
+56 −46
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.hardware.display.AmbientDisplayConfiguration
import android.os.Handler
import android.os.PowerManager
import android.util.Log
import com.android.app.tracing.traceSection
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.logging.UiEventLogger
import com.android.internal.logging.UiEventLogger.UiEventEnum
@@ -196,7 +197,8 @@ constructor(
        filters.remove(filter)
    }

    override fun makeUnloggedHeadsUpDecision(entry: NotificationEntry): Decision {
    override fun makeUnloggedHeadsUpDecision(entry: NotificationEntry): Decision =
        traceSection("VisualInterruptionDecisionProviderImpl#makeUnloggedHeadsUpDecision") {
            check(started)

            return if (statusBarStateController.isDozing) {
@@ -207,7 +209,8 @@ constructor(
                .decision
        }

    override fun makeAndLogHeadsUpDecision(entry: NotificationEntry): Decision {
    override fun makeAndLogHeadsUpDecision(entry: NotificationEntry): Decision =
        traceSection("VisualInterruptionDecisionProviderImpl#makeAndLogHeadsUpDecision") {
            check(started)

            return if (statusBarStateController.isDozing) {
@@ -229,10 +232,13 @@ constructor(
            ?: checkFilters(PULSE, entry) ?: checkSuppressInterruptions(entry)
                ?: LoggableDecision.unsuppressed

    override fun makeAndLogBubbleDecision(entry: NotificationEntry): Decision {
    override fun makeAndLogBubbleDecision(entry: NotificationEntry): Decision =
        traceSection("VisualInterruptionDecisionProviderImpl#makeAndLogBubbleDecision") {
            check(started)

        return makeLoggableBubbleDecision(entry).also { logDecision(BUBBLE, entry, it) }.decision
            return makeLoggableBubbleDecision(entry)
                .also { logDecision(BUBBLE, entry, it) }
                .decision
        }

    private fun makeLoggableBubbleDecision(entry: NotificationEntry): LoggableDecision =
@@ -251,7 +257,10 @@ constructor(

    override fun makeUnloggedFullScreenIntentDecision(
        entry: NotificationEntry
    ): FullScreenIntentDecision {
    ): FullScreenIntentDecision =
        traceSection(
            "VisualInterruptionDecisionProviderImpl#makeUnloggedFullScreenIntentDecision"
        ) {
            check(started)

            val couldHeadsUp = makeUnloggedHeadsUpDecision(entry).shouldInterrupt
@@ -260,7 +269,8 @@ constructor(
            return FullScreenIntentDecisionImpl(entry, fsiDecision)
        }

    override fun logFullScreenIntentDecision(decision: FullScreenIntentDecision) {
    override fun logFullScreenIntentDecision(decision: FullScreenIntentDecision) =
        traceSection("VisualInterruptionDecisionProviderImpl#logFullScreenIntentDecision") {
            check(started)

            if (decision !is FullScreenIntentDecisionImpl) {