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

Commit 5b39923b authored by Yining Liu's avatar Yining Liu
Browse files

Add logs to track notification removal animation process

Add logs to track the start and end of notification removal animations.
The logs are useful to analyse transient views.

Bug: 281628358
Test: manual
Change-Id: I4d660265f10faa4519e8f8242705908393d57de4
parent eca966cb
Loading
Loading
Loading
Loading
+63 −36
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.systemui.statusbar.notification.stack;

import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -346,15 +349,13 @@ public class StackStateAnimator {
            ArrayList<NotificationStackScrollLayout.AnimationEvent> animationEvents) {
        boolean needsCustomAnimation = false;
        for (NotificationStackScrollLayout.AnimationEvent event : animationEvents) {
            final ExpandableView changingView = (ExpandableView) event.mChangingView;
            final ExpandableView changingView = event.mChangingView;
            boolean loggable = false;
            boolean isHeadsUp = false;
            boolean isGroupChild = false;
            String key = null;
            if (changingView instanceof ExpandableNotificationRow && mLogger != null) {
                loggable = true;
                isHeadsUp = ((ExpandableNotificationRow) changingView).isHeadsUp();
                isGroupChild = changingView.isChildInGroup();
                key = ((ExpandableNotificationRow) changingView).getEntry().getKey();
            }
            if (event.animationType ==
@@ -374,7 +375,11 @@ public class StackStateAnimator {

            } else if (event.animationType ==
                    NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_REMOVE) {
                if (changingView.getVisibility() != View.VISIBLE) {
                int changingViewVisibility = changingView.getVisibility();
                if (loggable) {
                    mLogger.processAnimationEventsRemoval(key, changingViewVisibility, isHeadsUp);
                }
                if (changingViewVisibility != View.VISIBLE) {
                    changingView.removeFromTransientContainer();
                    continue;
                }
@@ -410,15 +415,20 @@ public class StackStateAnimator {
                    translationDirection = Math.max(Math.min(translationDirection, 1.0f),-1.0f);

                }
                Runnable postAnimation = () -> {
                Runnable postAnimation;
                Runnable startAnimation;
                if (loggable) {
                    String finalKey = key;
                    final boolean finalIsHeadsHp = isHeadsUp;
                    startAnimation = () -> {
                        mLogger.animationStart(finalKey, "ANIMATION_TYPE_REMOVE", finalIsHeadsHp);
                        changingView.setInRemovalAnimation(true);
                    };
                    postAnimation = () -> {
                        mLogger.animationEnd(finalKey, "ANIMATION_TYPE_REMOVE", finalIsHeadsHp);
                        changingView.setInRemovalAnimation(false);
                        changingView.removeFromTransientContainer();
                    };
                Runnable startAnimation = ()-> {
                    changingView.setInRemovalAnimation(true);
                };
                if (loggable) {
                    String finalKey = key;
                    if (isHeadsUp) {
                        mLogger.logHUNViewDisappearingWithRemoveEvent(key);
                        postAnimation = () -> {
@@ -426,22 +436,27 @@ public class StackStateAnimator {
                            mLogger.disappearAnimationEnded(finalKey);
                            changingView.removeFromTransientContainer();
                        };
                    } else if (isGroupChild) {
                        mLogger.groupChildRemovalEventProcessed(key);
                    }
                } else {
                    startAnimation = ()-> {
                        changingView.setInRemovalAnimation(true);
                    };
                    postAnimation = () -> {
                        changingView.setInRemovalAnimation(false);
                            mLogger.groupChildRemovalAnimationEnded(finalKey);
                        changingView.removeFromTransientContainer();
                    };
                }
                }
                changingView.performRemoveAnimation(ANIMATION_DURATION_APPEAR_DISAPPEAR,
                        0 /* delay */, translationDirection, false /* isHeadsUpAppear */,
                        startAnimation, postAnimation, getGlobalAnimationFinishedListener());
                needsCustomAnimation = true;
            } else if (event.animationType ==
                NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_REMOVE_SWIPED_OUT) {
                if (mHostLayout.isFullySwipedOut(changingView)) {
                boolean isFullySwipedOut = mHostLayout.isFullySwipedOut(changingView);
                if (loggable) {
                    mLogger.processAnimationEventsRemoveSwipeOut(key, isFullySwipedOut, isHeadsUp);
                }
                if (isFullySwipedOut) {
                    changingView.removeFromTransientContainer();
                }
            } else if (event.animationType == NotificationStackScrollLayout
@@ -472,10 +487,8 @@ public class StackStateAnimator {
                }

                mTmpState.applyToView(changingView);
            } else if (event.animationType == NotificationStackScrollLayout
                            .AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR
                    || event.animationType == NotificationStackScrollLayout
                            .AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
            } else if (event.animationType == ANIMATION_TYPE_HEADS_UP_DISAPPEAR
                    || event.animationType == ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
                mHeadsUpDisappearChildren.add(changingView);
                Runnable endRunnable = null;
                if (changingView.getParent() == null) {
@@ -499,24 +512,38 @@ public class StackStateAnimator {
                    // We need to add the global animation listener, since once no animations are
                    // running anymore, the panel will instantly hide itself. We need to wait until
                    // the animation is fully finished for this though.
                    Runnable tmpEndRunnable = endRunnable;
                    Runnable postAnimation = () -> {
                    final Runnable tmpEndRunnable = endRunnable;
                    Runnable postAnimation;
                    Runnable startAnimation;
                    if (loggable) {
                        mLogger.logHUNViewDisappearing(key);
                        String finalKey1 = key;
                        final boolean finalIsHeadsUp = isHeadsUp;
                        final String type =
                                event.animationType == ANIMATION_TYPE_HEADS_UP_DISAPPEAR
                                        ? "ANIMATION_TYPE_HEADS_UP_DISAPPEAR"
                                        : "ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK";
                        startAnimation = () -> {
                            mLogger.animationStart(finalKey1, type, finalIsHeadsUp);
                            changingView.setInRemovalAnimation(true);
                        };
                        postAnimation = () -> {
                            mLogger.disappearAnimationEnded(finalKey1);
                            mLogger.animationEnd(finalKey1, type, finalIsHeadsUp);
                            changingView.setInRemovalAnimation(false);
                            if (tmpEndRunnable != null) {
                                tmpEndRunnable.run();
                            }
                        };
                    Runnable startAnimation = () -> {
                        changingView.setInRemovalAnimation(true);
                    };
                    if (loggable) {
                        mLogger.logHUNViewDisappearing(key);

                        Runnable tmpPostAnimation = postAnimation;
                        String finalKey1 = key;
                    } else {
                        postAnimation = () -> {
                            mLogger.disappearAnimationEnded(finalKey1);
                            tmpPostAnimation.run();
                            changingView.setInRemovalAnimation(false);
                            if (tmpEndRunnable != null) {
                                tmpEndRunnable.run();
                            }
                        };
                        startAnimation = () -> {
                            changingView.setInRemovalAnimation(true);
                        };
                    }
                    long removeAnimationDelay = changingView.performRemoveAnimation(
+115 −42
Original line number Diff line number Diff line
@@ -5,73 +5,146 @@ import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.dagger.NotificationHeadsUpLog
import com.android.systemui.log.dagger.NotificationRenderLog
import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.util.visibilityString
import javax.inject.Inject

class StackStateLogger @Inject constructor(
class StackStateLogger
@Inject
constructor(
    @NotificationHeadsUpLog private val buffer: LogBuffer,
    @NotificationRenderLog private val notificationRenderBuffer: LogBuffer
) {
    fun logHUNViewDisappearing(key: String) {
        buffer.log(TAG, LogLevel.INFO, {
            str1 = logKey(key)
        }, {
            "Heads up view disappearing $str1 "
        })
        buffer.log(
            TAG,
            LogLevel.INFO,
            { str1 = logKey(key) },
            { "Heads up view disappearing $str1 " }
        )
    }

    fun logHUNViewAppearing(key: String) {
        buffer.log(TAG, LogLevel.INFO, {
            str1 = logKey(key)
        }, {
            "Heads up notification view appearing $str1 "
        })
        buffer.log(
            TAG,
            LogLevel.INFO,
            { str1 = logKey(key) },
            { "Heads up notification view appearing $str1 " }
        )
    }

    fun logHUNViewDisappearingWithRemoveEvent(key: String) {
        buffer.log(TAG, LogLevel.ERROR, {
            str1 = logKey(key)
        }, {
            "Heads up view disappearing $str1 for ANIMATION_TYPE_REMOVE"
        })
        buffer.log(
            TAG,
            LogLevel.ERROR,
            { str1 = logKey(key) },
            { "Heads up view disappearing $str1 for ANIMATION_TYPE_REMOVE" }
        )
    }

    fun logHUNViewAppearingWithAddEvent(key: String) {
        buffer.log(TAG, LogLevel.ERROR, {
            str1 = logKey(key)
        }, {
            "Heads up view disappearing $str1 for ANIMATION_TYPE_ADD"
        })
        buffer.log(
            TAG,
            LogLevel.ERROR,
            { str1 = logKey(key) },
            { "Heads up view disappearing $str1 for ANIMATION_TYPE_ADD" }
        )
    }

    fun disappearAnimationEnded(key: String) {
        buffer.log(TAG, LogLevel.INFO, {
            str1 = logKey(key)
        }, {
            "Heads up notification disappear animation ended $str1 "
        })
        buffer.log(
            TAG,
            LogLevel.INFO,
            { str1 = logKey(key) },
            { "Heads up notification disappear animation ended $str1 " }
        )
    }

    fun appearAnimationEnded(key: String) {
        buffer.log(TAG, LogLevel.INFO, {
            str1 = logKey(key)
        }, {
            "Heads up notification appear animation ended $str1 "
        })
        buffer.log(
            TAG,
            LogLevel.INFO,
            { str1 = logKey(key) },
            { "Heads up notification appear animation ended $str1 " }
        )
    }

    fun groupChildRemovalEventProcessed(key: String) {
        notificationRenderBuffer.log(TAG, LogLevel.DEBUG, {
            str1 = logKey(key)
        }, {
            "Group Child Notification removal event processed $str1 for ANIMATION_TYPE_REMOVE"
        })
        notificationRenderBuffer.log(
            TAG,
            LogLevel.DEBUG,
            { str1 = logKey(key) },
            { "Group Child Notification removal event processed $str1 for ANIMATION_TYPE_REMOVE" }
        )
    }
    fun groupChildRemovalAnimationEnded(key: String) {
        notificationRenderBuffer.log(TAG, LogLevel.INFO, {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.INFO,
            { str1 = logKey(key) },
            { "Group child notification removal animation ended $str1 " }
        )
    }

    fun processAnimationEventsRemoval(key: String, visibility: Int, isHeadsUp: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.INFO,
            {
                str1 = logKey(key)
                int1 = visibility
                bool1 = isHeadsUp
            },
            {
                "ProcessAnimationEvents ANIMATION_TYPE_REMOVE for: $str1, " +
                    "changingViewVisibility: ${visibilityString(int1)}, isHeadsUp: $bool1"
            }
        )
    }

    fun processAnimationEventsRemoveSwipeOut(
        key: String,
        isFullySwipedOut: Boolean,
        isHeadsUp: Boolean
    ) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.INFO,
            {
                str1 = logKey(key)
                bool1 = isFullySwipedOut
                bool2 = isHeadsUp
            },
            {
                "ProcessAnimationEvents ANIMATION_TYPE_REMOVE_SWIPED_OUT for: $str1, " +
                    "isFullySwipedOut: $bool1, isHeadsUp: $bool2"
            }
        )
    }

    fun animationStart(key: String?, animationType: String, isHeadsUp: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.INFO,
            {
                str1 = logKey(key)
                str2 = animationType
                bool1 = isHeadsUp
            },
            { "Animation Start, type: $str2, notif key: $str1, isHeadsUp: $bool1" }
        )
    }

    fun animationEnd(key: String, animationType: String, isHeadsUp: Boolean) {
        notificationRenderBuffer.log(
            TAG,
            LogLevel.INFO,
            {
                str1 = logKey(key)
        }, {
            "Group child notification removal animation ended $str1 "
        })
                str2 = animationType
                bool1 = isHeadsUp
            },
            { "Animation End, type: $str2, notif key: $str1, isHeadsUp: $bool1" }
        )
    }
}