Remove obsolete DeviceTraceParser

Bug: 290857675
Test: atest FlickerLibTestE2e
Change-Id: Iae54a074d181c9efa059d96b1056c106d5a008c2
diff --git a/libraries/flicker/utils/src/android/tools/common/traces/DeviceTraceDump.kt b/libraries/flicker/utils/src/android/tools/common/traces/DeviceTraceDump.kt
deleted file mode 100644
index c3b339e..0000000
--- a/libraries/flicker/utils/src/android/tools/common/traces/DeviceTraceDump.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 android.tools.common.traces
-
-import android.tools.common.traces.events.EventLog
-import android.tools.common.traces.surfaceflinger.LayersTrace
-import android.tools.common.traces.surfaceflinger.TransactionsTrace
-import android.tools.common.traces.wm.TransitionsTrace
-import android.tools.common.traces.wm.WindowManagerTrace
-
-/**
- * Represents a state dump containing the [WindowManagerTrace] and the [LayersTrace] both parsed and
- * in raw (byte) data.
- *
- * @param wmTrace Parsed [WindowManagerTrace]
- * @param layersTrace Parsed [LayersTrace]
- * @param transactionsTrace Parse [TransactionsTrace]
- * @param transitionsTrace Parsed [TransitionsTrace]
- * @param eventLog Parsed [EventLog]
- */
-class DeviceTraceDump(
-    val wmTrace: WindowManagerTrace?,
-    val layersTrace: LayersTrace?,
-    val transactionsTrace: TransactionsTrace? = null,
-    val transitionsTrace: TransitionsTrace? = null,
-    val eventLog: EventLog? = null,
-) {
-    /** A deviceTraceDump is considered valid if at least one of the layers/wm traces is non-null */
-    val isValid: Boolean
-        get() {
-            if (wmTrace == null && layersTrace == null) {
-                return false
-            }
-            return true
-        }
-}
diff --git a/libraries/flicker/utils/src/android/tools/device/traces/monitors/MonitorUtils.kt b/libraries/flicker/utils/src/android/tools/device/traces/monitors/MonitorUtils.kt
index 5445e56..f9796db 100644
--- a/libraries/flicker/utils/src/android/tools/device/traces/monitors/MonitorUtils.kt
+++ b/libraries/flicker/utils/src/android/tools/device/traces/monitors/MonitorUtils.kt
@@ -25,35 +25,18 @@
 import android.tools.common.ScenarioBuilder
 import android.tools.common.Tag
 import android.tools.common.io.Reader
-import android.tools.common.traces.DeviceTraceDump
 import android.tools.common.traces.surfaceflinger.LayersTrace
-import android.tools.common.traces.surfaceflinger.TransactionsTrace
 import android.tools.common.traces.wm.WindowManagerTrace
 import android.tools.device.traces.SERVICE_TRACE_CONFIG
 import android.tools.device.traces.io.ResultReaderWithLru
 import android.tools.device.traces.io.ResultWriter
 import android.tools.device.traces.monitors.wm.WindowManagerTraceMonitor
-import android.tools.device.traces.parsers.DeviceDumpParser
 import android.tools.device.traces.parsers.perfetto.LayersTraceParser
 import android.tools.device.traces.parsers.perfetto.TraceProcessorSession
-import android.tools.device.traces.parsers.perfetto.TransactionsTraceParser
-import android.tools.device.traces.parsers.wm.WindowManagerTraceParser
 import java.io.File
 import perfetto.protos.PerfettoConfig.SurfaceFlingerLayersConfig
 
 /**
- * Acquire the [WindowManagerTrace] with the device state changes that happen when executing the
- * commands defined in the [predicate].
- *
- * @param predicate Commands to execute
- * @throws UnsupportedOperationException If tracing is already activated
- */
-fun withWMTracing(predicate: () -> Unit): WindowManagerTrace {
-    return WindowManagerTraceParser()
-        .parse(WindowManagerTraceMonitor().withTracing(Tag.ALL, predicate))
-}
-
-/**
  * Acquire the [LayersTrace] with the device state changes that happen when executing the commands
  * defined in the [predicate].
  *
@@ -73,20 +56,6 @@
 }
 
 /**
- * Acquire the [TransactionsTrace] with the device state changes that happen when executing the
- * commands defined in the [predicate].
- *
- * @param predicate Commands to execute
- * @throws UnsupportedOperationException If tracing is already activated
- */
-fun withTransactionsTracing(predicate: () -> Unit): TransactionsTrace {
-    val trace = PerfettoTraceMonitor().enableTransactionsTrace().withTracing(Tag.ALL, predicate)
-    return TraceProcessorSession.loadPerfettoTrace(trace) { session ->
-        TransactionsTraceParser().parse(session)
-    }
-}
-
-/**
  * Acquire the [WindowManagerTrace] and [LayersTrace] with the device state changes that happen when
  * executing the commands defined in the [predicate].
  *
@@ -100,26 +69,6 @@
             PerfettoTraceMonitor().enableLayersTrace().enableTransactionsTrace(),
         ),
     predicate: () -> Unit
-): DeviceTraceDump {
-    val traces = recordTraces(traceMonitors, predicate)
-    return DeviceDumpParser.fromTrace(traces)
-}
-
-/**
- * Acquire the [WindowManagerTrace] and [LayersTrace] with the device state changes that happen when
- * executing the commands defined in the [predicate].
- *
- * @param predicate Commands to execute
- * @return a trace [Reader]
- * @throws UnsupportedOperationException If tracing is already activated
- */
-fun recordTraces(
-    traceMonitors: List<TraceMonitor> =
-        listOf(
-            WindowManagerTraceMonitor(),
-            PerfettoTraceMonitor().enableLayersTrace().enableTransactionsTrace(),
-        ),
-    predicate: () -> Unit
 ): Reader {
     val tmpFile = File.createTempFile("recordTraces", "")
     val writer =
diff --git a/libraries/flicker/utils/src/android/tools/device/traces/parsers/DeviceDumpParser.kt b/libraries/flicker/utils/src/android/tools/device/traces/parsers/DeviceDumpParser.kt
index bb648a2..be41b1b 100644
--- a/libraries/flicker/utils/src/android/tools/device/traces/parsers/DeviceDumpParser.kt
+++ b/libraries/flicker/utils/src/android/tools/device/traces/parsers/DeviceDumpParser.kt
@@ -17,9 +17,7 @@
 package android.tools.device.traces.parsers
 
 import android.tools.common.Logger
-import android.tools.common.io.Reader
 import android.tools.common.traces.DeviceStateDump
-import android.tools.common.traces.DeviceTraceDump
 import android.tools.common.traces.NullableDeviceStateDump
 import android.tools.common.traces.surfaceflinger.LayerTraceEntry
 import android.tools.common.traces.surfaceflinger.LayersTrace
@@ -96,24 +94,5 @@
                 )
             }
         }
-
-        /**
-         * Creates a device state dump containing the WindowManager and Layers trace obtained from a
-         * regular trace. The parsed traces may contain a multiple [WindowManagerState] or
-         * [LayerTraceEntry].
-         *
-         * @param reader trace reader
-         * @param clearCache If the caching used while parsing the proto should be
-         *
-         * ```
-         *                               cleared or remain in memory
-         * ```
-         */
-        @JvmStatic
-        fun fromTrace(reader: Reader): DeviceTraceDump {
-            return Logger.withTracing("fromTrace") {
-                DeviceTraceDump(reader.readWmTrace(), reader.readLayersTrace())
-            }
-        }
     }
 }
diff --git a/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/MonitorUtilsTest.kt b/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/MonitorUtilsTest.kt
index bf280c5..51a82d6 100644
--- a/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/MonitorUtilsTest.kt
+++ b/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/MonitorUtilsTest.kt
@@ -16,8 +16,7 @@
 
 package android.tools.device.traces.monitors
 
-import android.tools.common.traces.DeviceTraceDump
-import android.tools.device.traces.parsers.DeviceDumpParser
+import android.tools.common.io.Reader
 import androidx.test.platform.app.InstrumentationRegistry
 import androidx.test.uiautomator.UiDevice
 import com.google.common.truth.Truth
@@ -38,24 +37,13 @@
         validateTrace(trace)
     }
 
-    @Test
-    fun recordTraces() {
-        val trace = recordTraces {
-            device.pressHome()
-            device.pressRecentApps()
-        }
-
-        val dump = DeviceDumpParser.fromTrace(trace)
-        validateTrace(dump)
-    }
-
-    private fun validateTrace(dump: DeviceTraceDump) {
+    private fun validateTrace(dump: Reader) {
         Truth.assertWithMessage("Could not obtain SF trace")
-            .that(dump.layersTrace?.entries ?: emptyArray())
+            .that(dump.readLayersTrace()?.entries ?: emptyArray())
             .asList()
             .isNotEmpty()
         Truth.assertWithMessage("Could not obtain WM trace")
-            .that(dump.wmTrace?.entries ?: emptyArray())
+            .that(dump.readWmTrace()?.entries ?: emptyArray())
             .asList()
             .isNotEmpty()
     }
diff --git a/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/PerfettoTraceMonitorTest.kt b/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/PerfettoTraceMonitorTest.kt
index c6f7ae6..9c2efee 100644
--- a/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/PerfettoTraceMonitorTest.kt
+++ b/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/PerfettoTraceMonitorTest.kt
@@ -32,7 +32,7 @@
  */
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 class PerfettoTraceMonitorTest : TraceMonitorTest<PerfettoTraceMonitor>() {
-    override val traceType = TraceType.SF // TODO: ???
+    override val traceType = TraceType.SF
     override fun getMonitor() = PerfettoTraceMonitor().enableLayersTrace().enableTransactionsTrace()
 
     override fun assertTrace(traceData: ByteArray) {
@@ -50,18 +50,6 @@
     }
 
     @Test
-    fun withTransactionsTracingTest() {
-        val trace = withTransactionsTracing {
-            device.pressHome()
-            device.pressRecentApps()
-        }
-
-        Truth.assertWithMessage("Could not obtain transactions trace")
-            .that(trace.entries)
-            .isNotEmpty()
-    }
-
-    @Test
     fun layersDump() {
         val traceData = PerfettoTraceMonitor().enableLayersDump().withTracing {}
         assertTrace(traceData)
diff --git a/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/wm/WindowManagerTraceMonitorTest.kt b/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/wm/WindowManagerTraceMonitorTest.kt
index 2ef853b..33d75ae 100644
--- a/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/wm/WindowManagerTraceMonitorTest.kt
+++ b/libraries/flicker/utils/test/src/android/tools/device/traces/monitors/wm/WindowManagerTraceMonitorTest.kt
@@ -20,7 +20,6 @@
 import android.tools.device.traces.TRACE_CONFIG_REQUIRE_CHANGES
 import android.tools.device.traces.io.ResultReader
 import android.tools.device.traces.monitors.TraceMonitorTest
-import android.tools.device.traces.monitors.withWMTracing
 import android.tools.utils.CleanFlickerEnvironmentRule
 import android.tools.utils.newTestResultWriter
 import com.android.server.wm.nano.WindowManagerTraceFileProto
@@ -47,16 +46,6 @@
     }
 
     @Test
-    fun withWMTracingTest() {
-        val trace = withWMTracing {
-            device.pressHome()
-            device.pressRecentApps()
-        }
-
-        Truth.assertWithMessage("Could not obtain WM trace").that(trace.entries).isNotEmpty()
-    }
-
-    @Test
     fun includesProtologTrace() {
         val monitor = getMonitor()
         monitor.start()