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

Commit 2d094810 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "Adding logging to magnetic state changes." into main

parents a343a705 9272dada
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
}