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

Commit 6604dcdc authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android Build Coastguard Worker
Browse files

Adding logging to magnetic state changes.

This will help us debug the state of a magnetic interaction in relation
to external animation and input events from other notification
components. The logger uses the @NotificationLog buffer to avoid extra
clutter on the @NotificationRenderLog buffer.

Test: Presubmit and manual check of logs when swiping magnetic
  notifications
Flag: EXEMPT added logging information only.
Bug: 415279408
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:9272dadaee7a651153c2e2fc65af10eb3c77ba65)
Merged-In: Ifcc78279b2e43985eafd7cb2a5d4a3ce240df0a9
Change-Id: Ifcc78279b2e43985eafd7cb2a5d4a3ce240df0a9
parent cdc9d924
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -571,6 +571,8 @@ class MagneticNotificationRowManagerImplTest : SysuiTestCase() {
            override fun canRowBeDismissed(): Boolean {
                return canRowBeDismissed
            }

            override fun getRowLoggingKey(): String = "testable listener"
        }
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -146,6 +146,16 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
        public boolean canRowBeDismissed() {
            return canExpandableViewBeDismissed();
        }

        @NonNull
        @Override
        public String getRowLoggingKey() {
            if (ExpandableView.this instanceof ExpandableNotificationRow row) {
                return row.getLoggingKey();
            } else {
                return "null";
            }
        }
    };

    /**
+37 −14
Original line number Diff line number Diff line
@@ -55,10 +55,7 @@ constructor(
        )
    }

    fun logRemoveTransientFromContainer(
        childEntry: String,
        containerEntry: String,
    ) {
    fun logRemoveTransientFromContainer(childEntry: String, containerEntry: String) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.INFO,
@@ -91,11 +88,7 @@ constructor(
        )
    }

    fun logAddTransientRow(
        childEntry: String,
        containerEntry: String,
        index: Int,
    ) {
    fun logAddTransientRow(childEntry: String, containerEntry: String, index: Int) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.ERROR,
@@ -186,11 +179,7 @@ constructor(
        )
    }

    fun logAppearAnimationFinished(
        entry: String,
        isAppear: Boolean,
        cancelled: Boolean,
    ) {
    fun logAppearAnimationFinished(entry: String, isAppear: Boolean, cancelled: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.DEBUG,
@@ -232,6 +221,40 @@ constructor(
            { "Failed to set magnetic row translation for $str1 on state $str2." },
        )
    }

    fun logMagneticRowManagerStateSet(
        loggingKey: String,
        from: MagneticNotificationRowManagerImpl.State,
        to: MagneticNotificationRowManagerImpl.State,
    ) {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                str1 = loggingKey
                str2 = from.name
                str3 = to.name
            },
            { "Magnetic state changed from $str2 to $str3 for notification: $str1" },
        )
    }

    fun logMagneticRowManagerInvalidStateChange(
        from: MagneticNotificationRowManagerImpl.State,
        to: MagneticNotificationRowManagerImpl.State,
    ) {
        buffer.log(
            TAG,
            LogLevel.ERROR,
            {
                str1 = from.name
                str2 = to.name
            },
            {
                "Magnetic state changed from $str1 to $str2 on a null swiped listener, or the logging key of the listener is null"
            },
        )
    }
}

private const val TAG = "NotifRow"
+14 −1
Original line number Diff line number Diff line
@@ -50,7 +50,20 @@ constructor(
) : MagneticNotificationRowManager {

    var currentState = State.IDLE
        private set
        private set(value) {
            val swipedLoggingKey =
                currentMagneticListeners.swipedListener()?.getRowLoggingKey().toString()
            if (swipedLoggingKey == "null") {
                logger.logMagneticRowManagerInvalidStateChange(from = currentState, to = value)
            } else {
                logger.logMagneticRowManagerStateSet(
                    loggingKey = swipedLoggingKey,
                    from = currentState,
                    to = value,
                )
            }
            field = value
        }

    // Magnetic targets
    var currentMagneticListeners = listOf<MagneticRowListener?>()
+3 −0
Original line number Diff line number Diff line
@@ -53,4 +53,7 @@ interface MagneticRowListener {

    /** Can the row be dismissed. */
    fun canRowBeDismissed(): Boolean

    /** Get the logging key associated with this [MagneticRowListener] */
    fun getRowLoggingKey(): String
}