Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/logging/BubbleEventHistoryLogger.kt +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) } Loading @@ -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 -> Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/logging/BubbleLog.kt +3 −2 Original line number Diff line number Diff line Loading @@ -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) } } libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +5 −0 Original line number Diff line number Diff line Loading @@ -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(); } } /** Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/logging/BubbleEventHistoryLoggerTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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} .: .*$") Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/logging/BubbleLogTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/logging/BubbleEventHistoryLogger.kt +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) } Loading @@ -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 -> Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/logging/BubbleLog.kt +3 −2 Original line number Diff line number Diff line Loading @@ -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) } }
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +5 −0 Original line number Diff line number Diff line Loading @@ -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(); } } /** Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/logging/BubbleEventHistoryLoggerTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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} .: .*$") Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/logging/BubbleLogTest.kt +7 −0 Original line number Diff line number Diff line Loading @@ -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 Loading