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

Commit 3e438046 authored by Yining Liu's avatar Yining Liu
Browse files

Remove redundant logs from StackStateAnimator

Remove redundant logs from StackStateAnimator. The new logs in
StackStateLogger covers the old HUN logs.

Test: manual
Bug: 281628358

Change-Id: I6da9961754aa195d664dfb6e6de592c3b5539e26
parent 5b39923b
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -429,14 +429,6 @@ public class StackStateAnimator {
                        changingView.setInRemovalAnimation(false);
                        changingView.removeFromTransientContainer();
                    };
                    if (isHeadsUp) {
                        mLogger.logHUNViewDisappearingWithRemoveEvent(key);
                        postAnimation = () -> {
                            changingView.setInRemovalAnimation(false);
                            mLogger.disappearAnimationEnded(finalKey);
                            changingView.removeFromTransientContainer();
                        };
                    }
                } else {
                    startAnimation = ()-> {
                        changingView.setInRemovalAnimation(true);
@@ -516,7 +508,6 @@ public class StackStateAnimator {
                    Runnable postAnimation;
                    Runnable startAnimation;
                    if (loggable) {
                        mLogger.logHUNViewDisappearing(key);
                        String finalKey1 = key;
                        final boolean finalIsHeadsUp = isHeadsUp;
                        final String type =
@@ -528,7 +519,6 @@ public class StackStateAnimator {
                            changingView.setInRemovalAnimation(true);
                        };
                        postAnimation = () -> {
                            mLogger.disappearAnimationEnded(finalKey1);
                            mLogger.animationEnd(finalKey1, type, finalIsHeadsUp);
                            changingView.setInRemovalAnimation(false);
                            if (tmpEndRunnable != null) {
+0 −43
Original line number Diff line number Diff line
@@ -14,14 +14,6 @@ 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 " }
        )
    }

    fun logHUNViewAppearing(key: String) {
        buffer.log(
@@ -32,15 +24,6 @@ constructor(
        )
    }

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

    fun logHUNViewAppearingWithAddEvent(key: String) {
        buffer.log(
            TAG,
@@ -50,15 +33,6 @@ constructor(
        )
    }

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

    fun appearAnimationEnded(key: String) {
        buffer.log(
            TAG,
@@ -68,23 +42,6 @@ constructor(
        )
    }

    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 " }
        )
    }

    fun processAnimationEventsRemoval(key: String, visibility: Int, isHeadsUp: Boolean) {
        notificationRenderBuffer.log(
            TAG,
+0 −77
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.LogcatEchoTracker
import com.android.systemui.log.core.LogLevel
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"
    }
}