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

Commit 58ee34ab authored by Yining Liu's avatar Yining Liu Committed by Cherrypicker Worker
Browse files

Add logs for group child notification removal animation start and end

Add logs for group child notification removal animation process and end. For each "Group Child Notification removal event processed", there should be a corresponding "Group child notification removal animation ended" log, otherwise the removal animation of group child ends abruptly.

Bug: 281628358
Test: StackStateLoggerTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b6c850554596c641084115af688f24992fcea45e)
Merged-In: I7fd2cb3a8d218908c5f2c2f9cd54d6a22b4f73d3
Change-Id: I7fd2cb3a8d218908c5f2c2f9cd54d6a22b4f73d3
parent 81392e3d
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -347,10 +347,12 @@ public class StackStateAnimator {
            final ExpandableView changingView = (ExpandableView) 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 ==
@@ -407,13 +409,21 @@ public class StackStateAnimator {

                }
                Runnable postAnimation = changingView::removeFromTransientContainer;
                if (loggable && isHeadsUp) {
                    mLogger.logHUNViewDisappearingWithRemoveEvent(key);
                if (loggable) {
                    String finalKey = key;
                    if (isHeadsUp) {
                        mLogger.logHUNViewDisappearingWithRemoveEvent(key);
                        postAnimation = () -> {
                            mLogger.disappearAnimationEnded(finalKey);
                            changingView.removeFromTransientContainer();
                        };
                    } else if (isGroupChild) {
                        mLogger.groupChildRemovalEventProcessed(key);
                        postAnimation = () -> {
                            mLogger.groupChildRemovalAnimationEnded(finalKey);
                            changingView.removeFromTransientContainer();
                        };
                    }
                }
                changingView.performRemoveAnimation(ANIMATION_DURATION_APPEAR_DISAPPEAR,
                        0 /* delay */, translationDirection, false /* isHeadsUpAppear */,
+18 −1
Original line number Diff line number Diff line
@@ -3,11 +3,13 @@ package com.android.systemui.statusbar.notification.stack
import com.android.systemui.log.dagger.NotificationHeadsUpLog
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel
import com.android.systemui.log.dagger.NotificationRenderLog
import com.android.systemui.statusbar.notification.logKey
import javax.inject.Inject

class StackStateLogger @Inject constructor(
    @NotificationHeadsUpLog private val buffer: LogBuffer
    @NotificationHeadsUpLog private val buffer: LogBuffer,
    @NotificationRenderLog private val notificationRenderBuffer: LogBuffer
) {
    fun logHUNViewDisappearing(key: String) {
        buffer.log(TAG, LogLevel.INFO, {
@@ -56,6 +58,21 @@ class StackStateLogger @Inject constructor(
            "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"
        })
    }
    fun groupChildRemovalAnimationEnded(key: String) {
        notificationRenderBuffer.log(TAG, LogLevel.INFO, {
            str1 = logKey(key)
        }, {
            "Group child notification removal animation ended $str1 "
        })
    }
}

private const val TAG = "StackScroll"
 No newline at end of file
+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.notification.logging

import android.testing.AndroidTestingRunner
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel
import com.android.systemui.log.LogcatEchoTracker
import com.android.systemui.statusbar.notification.stack.StackStateLogger
import com.google.common.truth.Truth
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidTestingRunner::class)
@SmallTest
class StackStateLoggerTest : SysuiTestCase() {
    private val logBufferCounter = LogBufferCounter()
    private lateinit var logger: StackStateLogger

    @Before
    fun setup() {
        logger = StackStateLogger(logBufferCounter.logBuffer, logBufferCounter.logBuffer)
    }

    @Test
    fun groupChildRemovalEvent() {
        logger.groupChildRemovalEventProcessed(KEY)
        verifyDidLog(1)
        logger.groupChildRemovalAnimationEnded(KEY)
        verifyDidLog(1)
    }

    class LogBufferCounter {
        val recentLogs = mutableListOf<Pair<String, LogLevel>>()
        val tracker =
            object : LogcatEchoTracker {
                override val logInBackgroundThread: Boolean = false
                override fun isBufferLoggable(bufferName: String, level: LogLevel): Boolean = false
                override fun isTagLoggable(tagName: String, level: LogLevel): Boolean {
                    recentLogs.add(tagName to level)
                    return true
                }
            }
        val logBuffer =
            LogBuffer(name = "test", maxSize = 1, logcatEchoTracker = tracker, systrace = false)

        fun verifyDidLog(times: Int) {
            Truth.assertThat(recentLogs).hasSize(times)
            recentLogs.clear()
        }
    }

    private fun verifyDidLog(times: Int) {
        logBufferCounter.verifyDidLog(times)
    }

    companion object {
        private val KEY = "PACKAGE_NAME"
    }
}