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

Commit da093f36 authored by Jay Aliomer's avatar Jay Aliomer
Browse files

Add HUN logs to the NSSL

Bug: 198359689
Test: examine logs
Change-Id: I8ca0e31e468b45bfcd9096c8cf4e4559a767b8cd
parent a49a494a
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            return true;
        }
    };

    private NotificationStackScrollLogger mLogger;
    private StatusBar mStatusBar;
    private int[] mTempInt2 = new int[2];
    private boolean mGenerateChildOrderChangedEvent;
@@ -658,6 +658,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        return 0f;
    }

    protected void setLogger(NotificationStackScrollLogger logger) {
        mLogger = logger;
    }

    public float getNotificationSquishinessFraction() {
        return mStackScrollAlgorithm.getNotificationSquishinessFraction(mAmbientState);
    }
@@ -736,6 +740,21 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        }
    }

    private void logHunSkippedForUnexpectedState(String key, boolean expected, boolean actual) {
        if (mLogger == null) return;
        mLogger.hunSkippedForUnexpectedState(key, expected, actual);
    }

    private void logHunAnimationSkipped(String key, String reason) {
        if (mLogger == null) return;
        mLogger.hunAnimationSkipped(key, reason);
    }

    private void logHunAnimationEventAdded(String key, int type) {
        if (mLogger == null) return;
        mLogger.hunAnimationEventAdded(key, type);
    }

    private void onDrawDebug(Canvas canvas) {
        if (mDebugTextUsedYPositions == null) {
            mDebugTextUsedYPositions = new HashSet<>();
@@ -3100,10 +3119,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private void generateHeadsUpAnimationEvents() {
        for (Pair<ExpandableNotificationRow, Boolean> eventPair : mHeadsUpChangeAnimations) {
            ExpandableNotificationRow row = eventPair.first;
            String key = row.getEntry().getKey();
            boolean isHeadsUp = eventPair.second;
            if (isHeadsUp != row.isHeadsUp()) {
                // For cases where we have a heads up showing and appearing again we shouldn't
                // do the animations at all.
                logHunSkippedForUnexpectedState(key, isHeadsUp, row.isHeadsUp());
                continue;
            }
            int type = AnimationEvent.ANIMATION_TYPE_HEADS_UP_OTHER;
@@ -3121,6 +3142,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                if (row.isChildInGroup()) {
                    // We can otherwise get stuck in there if it was just isolated
                    row.setHeadsUpAnimatingAway(false);
                    logHunAnimationSkipped(key, "row is child in group");
                    continue;
                }
            } else {
@@ -3128,6 +3150,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                if (viewState == null) {
                    // A view state was never generated for this view, so we don't need to animate
                    // this. This may happen with notification children.
                    logHunAnimationSkipped(key, "row has no viewState");
                    continue;
                }
                if (isHeadsUp && (mAddedHeadsUpChildren.contains(row) || pinnedAndClosed)) {
@@ -3151,6 +3174,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                        + " onBottom=" + onBottom
                        + " row=" + row.getEntry().getKey());
            }
            logHunAnimationEventAdded(key, type);
        }
        mHeadsUpChangeAnimations.clear();
        mAddedHeadsUpChildren.clear();
@@ -4699,6 +4723,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                if (SPEW) {
                    Log.v(TAG, "generateHeadsUpAnimation: previous hun appear animation cancelled");
                }
                logHunAnimationSkipped(row.getEntry().getKey(),
                        "previous hun appear animation cancelled");
                return;
            }
            mHeadsUpChangeAnimations.add(new Pair<>(row, isHeadsUp));
+5 −1
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ public class NotificationStackScrollLayoutController {
    private final LockscreenShadeTransitionController mLockscreenShadeTransitionController;
    private final InteractionJankMonitor mJankMonitor;
    private final StackStateLogger mStackStateLogger;
    private final NotificationStackScrollLogger mLogger;

    private NotificationStackScrollLayout mView;
    private boolean mFadeNotificationsOnDismiss;
@@ -662,8 +663,10 @@ public class NotificationStackScrollLayoutController {
            VisualStabilityManager visualStabilityManager,
            ShadeController shadeController,
            InteractionJankMonitor jankMonitor,
            StackStateLogger stackLogger) {
            StackStateLogger stackLogger,
            NotificationStackScrollLogger logger) {
        mStackStateLogger = stackLogger;
        mLogger = logger;
        mAllowLongPress = allowLongPress;
        mNotificationGutsManager = notificationGutsManager;
        mVisibilityProvider = visibilityProvider;
@@ -717,6 +720,7 @@ public class NotificationStackScrollLayoutController {
        mView = view;
        mView.setLogger(mStackStateLogger);
        mView.setController(this);
        mView.setLogger(mLogger);
        mView.setTouchHandler(new TouchHandler());
        mView.setStatusBar(mStatusBar);
        mView.setClearAllAnimationListener(this::onAnimationEnd);
+55 −0
Original line number Diff line number Diff line
package com.android.systemui.statusbar.notification.stack

import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel.INFO
import com.android.systemui.log.dagger.NotificationHeadsUpLog
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.*
import javax.inject.Inject

class NotificationStackScrollLogger @Inject constructor(
    @NotificationHeadsUpLog private val buffer: LogBuffer
) {
    fun hunAnimationSkipped(key: String, reason: String) {
        buffer.log(TAG, INFO, {
            str1 = key
            str2 = reason
        }, {
            "heads up animation skipped: key: $str1 reason: $str2"
        })
    }
    fun hunAnimationEventAdded(key: String, type: Int) {
        val reason: String
        reason = if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR) {
            "HEADS_UP_DISAPPEAR"
        } else if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
            "HEADS_UP_DISAPPEAR_CLICK"
        } else if (type == ANIMATION_TYPE_HEADS_UP_APPEAR) {
            "HEADS_UP_APPEAR"
        } else if (type == ANIMATION_TYPE_HEADS_UP_OTHER) {
            "HEADS_UP_OTHER"
        } else if (type == ANIMATION_TYPE_ADD) {
            "ADD"
        } else {
            type.toString()
        }
        buffer.log(TAG, INFO, {
            str1 = key
            str2 = reason
        }, {
            "heads up animation added: $str1 with type $str2"
        })
    }

    fun hunSkippedForUnexpectedState(key: String, expected: Boolean, actual: Boolean) {
        buffer.log(TAG, INFO, {
            str1 = key
            bool1 = expected
            bool2 = actual
        }, {
            "HUN animation skipped for unexpected hun state: " +
                    "key: $str1 expected: $bool1 actual: $bool2"
        })
    }
}

private const val TAG = "NotificationStackScroll"
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    @Mock private ShadeController mShadeController;
    @Mock private InteractionJankMonitor mJankMonitor;
    @Mock private StackStateLogger mStackLogger;
    @Mock private NotificationStackScrollLogger mLogger;

    @Captor
    private ArgumentCaptor<StatusBarStateController.StateListener> mStateListenerArgumentCaptor;
@@ -193,7 +194,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                mVisualStabilityManager,
                mShadeController,
                mJankMonitor,
                mStackLogger
                mStackLogger,
                mLogger
        );

        when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);