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

Commit be737613 authored by Mykola Podolian's avatar Mykola Podolian Committed by Android (Google) Code Review
Browse files

Merge "Applied enable_bubble_event_history_logs flag." into main

parents de151355 4227cd57
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.shared.bubbles.logging
import android.icu.text.SimpleDateFormat
import android.text.TextUtils
import androidx.annotation.VisibleForTesting
import com.android.wm.shell.Flags
import java.io.PrintWriter
import java.util.Locale

@@ -58,6 +59,7 @@ class BubbleEventHistoryLogger : DebugLogger {
        eventData: String? = null,
        timestamp: Long = System.currentTimeMillis(),
    ) {
        if (!Flags.enableBubbleEventHistoryLogs()) return
        if (recentEvents.size >= MAX_EVENTS) {
            recentEvents.removeAt(0)
        }
@@ -68,7 +70,8 @@ class BubbleEventHistoryLogger : DebugLogger {
     * Dumps the collected events history to the provided [PrintWriter], adding the [prefix] at the
     * beginning of each line.
     */
    fun dump(prefix: String = "", pw: PrintWriter) {
    fun dump(pw: PrintWriter, prefix: String = "") {
        if (!Flags.enableBubbleEventHistoryLogs()) return
        val recentEventsCopy = synchronized(this) { ArrayList(recentEvents) }
        pw.println("${prefix}Bubbles events history:")
        recentEventsCopy.reversed().forEach { event ->
+3 −2
Original line number Diff line number Diff line
@@ -95,7 +95,8 @@ object BubbleLog {
        }
    }

    fun dump(prefix: String = "", pw: PrintWriter) {
        bubbleEventHistoryLogger.dump(prefix, pw)
    @JvmStatic
    fun dump(pw: PrintWriter, prefix: String = "") {
        bubbleEventHistoryLogger.dump(pw, prefix)
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -3172,6 +3172,11 @@ public class BubbleController implements ConfigurationChangeListener,
        mBubbleTransitions.mTaskViewTransitions.dump(pw);

        mBubblePositioner.dump(pw);

        if (Flags.enableBubbleEventHistoryLogs()) {
            BubbleLog.dump(pw, prefix);
            pw.println();
        }
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.wm.shell.shared.bubbles.logging

import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.wm.shell.Flags
import com.android.wm.shell.shared.bubbles.logging.BubbleEventHistoryLogger.Companion.DATE_FORMAT
import com.android.wm.shell.shared.bubbles.logging.BubbleEventHistoryLogger.Companion.DATE_FORMATTER
import com.android.wm.shell.shared.bubbles.logging.BubbleEventHistoryLogger.Companion.MAX_EVENTS
@@ -28,14 +31,18 @@ import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import kotlin.text.split
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

/** Unit tests for [BubbleEventHistoryLogger]. */
@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(Flags.FLAG_ENABLE_BUBBLE_EVENT_HISTORY_LOGS)
class BubbleEventHistoryLoggerTest {

    @get:Rule val flagsRule = SetFlagsRule()

    private val logger = BubbleEventHistoryLogger()
    private val logPattern = Regex("^\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3} .: .*$")

+7 −0
Original line number Diff line number Diff line
@@ -15,21 +15,28 @@
 */
package com.android.wm.shell.shared.bubbles.logging

import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import android.text.TextUtils
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.wm.shell.Flags
import com.google.common.truth.Truth.assertThat
import java.io.PrintWriter
import java.io.StringWriter
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

/** Unit tests for [BubbleLog]. */
@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(Flags.FLAG_ENABLE_BUBBLE_EVENT_HISTORY_LOGS)
class BubbleLogTest {

    @get:Rule val flagsRule = SetFlagsRule()

    @Before
    fun setup() {
        // Clear all loggers except BubbleEventHistoryLogger