Merge "Add bubble icon factories to the icon lib" into udc-dev
diff --git a/motiontoollib/build.gradle b/motiontoollib/build.gradle
index 647d03d..e3750ec 100644
--- a/motiontoollib/build.gradle
+++ b/motiontoollib/build.gradle
@@ -8,6 +8,7 @@
 
 android {
     namespace = "com.android.app.motiontool"
+    testNamespace = "com.android.app.motiontool.tests"
     defaultConfig {
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
diff --git a/motiontoollib/src/com/android/app/motiontool/DdmHandleMotionTool.kt b/motiontoollib/src/com/android/app/motiontool/DdmHandleMotionTool.kt
index 63a6fee..c7a6b0d 100644
--- a/motiontoollib/src/com/android/app/motiontool/DdmHandleMotionTool.kt
+++ b/motiontoollib/src/com/android/app/motiontool/DdmHandleMotionTool.kt
@@ -107,7 +107,7 @@
         MotionToolsResponse.newBuilder().apply {
             tryCatchingMotionToolManagerExceptions {
                 setPollTrace(PollTraceResponse.newBuilder()
-                        .setExportedData(motionToolManager.pollTrace(pollTraceRequest.traceId)))
+                        .setData(motionToolManager.pollTrace(pollTraceRequest.traceId)))
             }
         }.build()
 
@@ -115,7 +115,7 @@
         MotionToolsResponse.newBuilder().apply {
             tryCatchingMotionToolManagerExceptions {
                 setEndTrace(EndTraceResponse.newBuilder()
-                        .setExportedData(motionToolManager.endTrace(endTraceRequest.traceId)))
+                        .setData(motionToolManager.endTrace(endTraceRequest.traceId)))
             }
         }.build()
 
diff --git a/motiontoollib/src/com/android/app/motiontool/MotionToolManager.kt b/motiontoollib/src/com/android/app/motiontool/MotionToolManager.kt
index 66b00f7..c0244c9 100644
--- a/motiontoollib/src/com/android/app/motiontool/MotionToolManager.kt
+++ b/motiontoollib/src/com/android/app/motiontool/MotionToolManager.kt
@@ -23,7 +23,7 @@
 import android.view.WindowManagerGlobal
 import androidx.annotation.VisibleForTesting
 import com.android.app.viewcapture.ViewCapture
-import com.android.app.viewcapture.data.ExportedData
+import com.android.app.viewcapture.data.MotionWindowData
 
 /**
  * Singleton to manage motion tracing sessions.
@@ -77,29 +77,29 @@
     }
 
     /**
-     * Ends [ViewCapture] and returns the captured [ExportedData] since the [beginTrace] call or the
-     * last [pollTrace] call.
+     * Ends [ViewCapture] and returns the captured [MotionWindowData] since the [beginTrace] call or
+     * the last [pollTrace] call.
      */
     @Synchronized
-    fun endTrace(traceId: Int): ExportedData {
+    fun endTrace(traceId: Int): MotionWindowData {
         Log.d(TAG, "End Trace for id: $traceId")
         val traceMetadata = traces.getOrElse(traceId) { throw UnknownTraceIdException(traceId) }
-        val exportedData = pollTrace(traceId)
+        val data = pollTrace(traceId)
         traceMetadata.stopTrace()
         traces.remove(traceId)
-        return exportedData
+        return data
     }
 
     /**
-     * Returns the [ExportedData] captured since the [beginTrace] call or the last [pollTrace] call.
+     * Returns the [MotionWindowData] captured since the [beginTrace] call or last [pollTrace] call.
      * This function can only be used after [beginTrace] is called and before [endTrace] is called.
      */
     @Synchronized
-    fun pollTrace(traceId: Int): ExportedData {
+    fun pollTrace(traceId: Int): MotionWindowData {
         val traceMetadata = traces.getOrElse(traceId) { throw UnknownTraceIdException(traceId) }
-        val exportedData = getExportedDataFromViewCapture(traceMetadata)
-        traceMetadata.updateLastPolledTime(exportedData)
-        return exportedData
+        val data = getDataFromViewCapture(traceMetadata)
+        traceMetadata.updateLastPolledTime(data)
+        return data
     }
 
     /**
@@ -115,23 +115,21 @@
         traceIdCounter = 0
     }
 
-    private fun getExportedDataFromViewCapture(traceMetadata: TraceMetadata): ExportedData {
+    private fun getDataFromViewCapture(traceMetadata: TraceMetadata): MotionWindowData {
         val rootView =
             getRootView(traceMetadata.windowId)
                 ?: throw WindowNotFoundException(traceMetadata.windowId)
 
-        val exportedData = viewCapture
-            .getDumpTask(rootView)
-            ?.orElse(null)
-            ?.get() ?: return ExportedData.newBuilder().build()
-
-        val filteredFrameData = exportedData.frameDataList
-                ?.filter { it.timestamp > traceMetadata.lastPolledTime }
-
-        return exportedData.toBuilder()
-                .clearFrameData()
-                .addAllFrameData(filteredFrameData)
-                .build()
+        val data: MotionWindowData = viewCapture
+            .getDumpTask(rootView).get()
+            ?.orElse(null) ?: return MotionWindowData.newBuilder().build()
+        val filteredFrameData = data.frameDataList.filter {
+            it.timestamp > traceMetadata.lastPolledTime
+        }
+        return data.toBuilder()
+            .clearFrameData()
+            .addAllFrameData(filteredFrameData)
+            .build()
     }
 
     private fun getRootView(windowId: String): View? {
@@ -148,9 +146,9 @@
     var lastPolledTime: Long,
     var stopTrace: () -> Unit
 ) {
-    fun updateLastPolledTime(exportedData: ExportedData?) {
-        exportedData?.frameDataList?.maxOfOrNull { it.timestamp }?.let { maxFrameTimestamp ->
-            lastPolledTime = maxFrameTimestamp
+    fun updateLastPolledTime(data: MotionWindowData?) {
+        data?.frameDataList?.maxOfOrNull { it.timestamp }?.let {
+            lastPolledTime = it
         }
     }
 }
diff --git a/motiontoollib/src/com/android/app/motiontool/proto/motion_tool.proto b/motiontoollib/src/com/android/app/motiontool/proto/motion_tool.proto
index cd5ad2f..04ee020 100644
--- a/motiontoollib/src/com/android/app/motiontool/proto/motion_tool.proto
+++ b/motiontoollib/src/com/android/app/motiontool/proto/motion_tool.proto
@@ -98,7 +98,7 @@
 }
 
 message EndTraceResponse {
-  optional com.android.app.viewcapture.data.ExportedData exported_data = 1;
+  optional com.android.app.viewcapture.data.MotionWindowData data = 1;
 }
 
 // Polls collected motion trace data collected since the last PollTraceRequest (or the
@@ -108,6 +108,6 @@
 }
 
 message PollTraceResponse {
-  optional com.android.app.viewcapture.data.ExportedData exported_data = 1;
+  optional com.android.app.viewcapture.data.MotionWindowData data = 1;
 }
 
diff --git a/motiontoollib/tests/AndroidManifest.xml b/motiontoollib/tests/AndroidManifest.xml
index 3db8d2f..c16e25f 100644
--- a/motiontoollib/tests/AndroidManifest.xml
+++ b/motiontoollib/tests/AndroidManifest.xml
@@ -15,14 +15,14 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.app.motiontool">
+    package="com.android.app.motiontool.tests">
 
     <application
         android:debuggable="true"
         android:theme="@android:style/Theme.NoTitleBar">
 
         <activity
-            android:name=".util.TestActivity"
+            android:name="com.android.app.motiontool.util.TestActivity"
             android:exported="false" />
 
         <uses-library android:name="android.test.runner" />
@@ -32,6 +32,6 @@
     <instrumentation
         android:name="android.testing.TestableInstrumentation"
         android:label="Tests for MotionTool Lib"
-        android:targetPackage="com.android.app.motiontool"/>
+        android:targetPackage="com.android.app.motiontool.tests"/>
 
 </manifest>
diff --git a/motiontoollib/tests/com/android/app/motiontool/DdmHandleMotionToolTest.kt b/motiontoollib/tests/com/android/app/motiontool/DdmHandleMotionToolTest.kt
index 7d78237..f330980 100644
--- a/motiontoollib/tests/com/android/app/motiontool/DdmHandleMotionToolTest.kt
+++ b/motiontoollib/tests/com/android/app/motiontool/DdmHandleMotionToolTest.kt
@@ -119,7 +119,7 @@
         activityScenarioRule.scenario.onActivity {
             val beginTraceResponse = performBeginTraceRequest(getActivityViewRootId())
             val endTraceResponse = performEndTraceRequest(beginTraceResponse.beginTrace.traceId)
-            Assert.assertTrue(endTraceResponse.endTrace.exportedData.frameDataList.isEmpty())
+            Assert.assertTrue(endTraceResponse.endTrace.data.frameDataList.isEmpty())
         }
     }
 
@@ -133,11 +133,11 @@
                 activity.findViewById<View>(android.R.id.content).viewTreeObserver.dispatchOnDraw()
 
                 val pollTraceResponse = performPollTraceRequest(traceId)
-                assertEquals(1, pollTraceResponse.pollTrace.exportedData.frameDataList.size)
+                assertEquals(1, pollTraceResponse.pollTrace.data.frameDataList.size)
 
                 // Verify that frameData is only included once and is not returned again
                 val endTraceResponse = performEndTraceRequest(traceId)
-                assertEquals(0, endTraceResponse.endTrace.exportedData.frameDataList.size)
+                assertEquals(0, endTraceResponse.endTrace.data.frameDataList.size)
             }
         }
     }
diff --git a/motiontoollib/tests/com/android/app/motiontool/MotionToolManagerTest.kt b/motiontoollib/tests/com/android/app/motiontool/MotionToolManagerTest.kt
index 560f798..c522d0c 100644
--- a/motiontoollib/tests/com/android/app/motiontool/MotionToolManagerTest.kt
+++ b/motiontoollib/tests/com/android/app/motiontool/MotionToolManagerTest.kt
@@ -87,12 +87,12 @@
             Choreographer.getInstance().postFrameCallback {
                 activity.findViewById<View>(android.R.id.content).viewTreeObserver.dispatchOnDraw()
 
-                val polledExportedData = motionToolManager.pollTrace(traceId)
-                assertEquals(1, polledExportedData.frameDataList.size)
+                val polledData = motionToolManager.pollTrace(traceId)
+                assertEquals(1, polledData.frameDataList.size)
 
                 // Verify that frameData is only included once and is not returned again
-                val endExportedData = motionToolManager.endTrace(traceId)
-                assertEquals(0, endExportedData.frameDataList.size)
+                val endData = motionToolManager.endTrace(traceId)
+                assertEquals(0, endData.frameDataList.size)
             }
         }
     }
diff --git a/viewcapturelib/build.gradle b/viewcapturelib/build.gradle
index 1e7bb2a..e5442cc 100644
--- a/viewcapturelib/build.gradle
+++ b/viewcapturelib/build.gradle
@@ -8,6 +8,7 @@
 
 android {
     namespace = "com.android.app.viewcapture"
+    testNamespace = "com.android.app.viewcapture.test"
     defaultConfig {
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
diff --git a/viewcapturelib/src/com/android/app/viewcapture/SettingsAwareViewCapture.kt b/viewcapturelib/src/com/android/app/viewcapture/SettingsAwareViewCapture.kt
index c84d4d5..d5aca54 100644
--- a/viewcapturelib/src/com/android/app/viewcapture/SettingsAwareViewCapture.kt
+++ b/viewcapturelib/src/com/android/app/viewcapture/SettingsAwareViewCapture.kt
@@ -17,12 +17,15 @@
 package com.android.app.viewcapture
 
 import android.content.Context
+import android.content.pm.LauncherApps
 import android.database.ContentObserver
 import android.os.Handler
 import android.os.Looper
+import android.os.ParcelFileDescriptor
 import android.os.Process
 import android.provider.Settings
 import android.view.Choreographer
+import android.window.IDumpCallback
 import androidx.annotation.AnyThread
 import androidx.annotation.VisibleForTesting
 import java.util.concurrent.Executor
@@ -36,6 +39,10 @@
 @VisibleForTesting
 internal constructor(private val context: Context, choreographer: Choreographer, executor: Executor)
     : ViewCapture(DEFAULT_MEMORY_SIZE, DEFAULT_INIT_POOL_SIZE, choreographer, executor) {
+    /** Dumps all the active view captures to the wm trace directory via LauncherAppService */
+    private val mDumpCallback: IDumpCallback.Stub = object : IDumpCallback.Stub() {
+        override fun onDump(out: ParcelFileDescriptor) = dumpTo(out, context)
+    }
 
     init {
         enableOrDisableWindowListeners()
@@ -57,6 +64,12 @@
             MAIN_EXECUTOR.execute {
                 enableOrDisableWindowListeners(isEnabled)
             }
+            val launcherApps = context.getSystemService(LauncherApps::class.java)
+            if (isEnabled) {
+                launcherApps?.registerDumpCallback(mDumpCallback)
+            } else {
+                launcherApps?.unRegisterDumpCallback(mDumpCallback)
+            }
         }
     }
 
diff --git a/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java b/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java
index fcd7ad8..de2f967 100644
--- a/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java
+++ b/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java
@@ -16,19 +16,15 @@
 
 package com.android.app.viewcapture;
 
-import static java.util.stream.Collectors.toList;
-
 import android.content.Context;
 import android.content.res.Resources;
 import android.media.permission.SafeCloseable;
 import android.os.HandlerThread;
 import android.os.Looper;
+import android.os.ParcelFileDescriptor;
 import android.os.Trace;
 import android.text.TextUtils;
-import android.util.Base64;
-import android.util.Base64OutputStream;
 import android.util.Log;
-import android.util.Pair;
 import android.util.SparseArray;
 import android.view.Choreographer;
 import android.view.View;
@@ -36,25 +32,27 @@
 import android.view.ViewTreeObserver;
 import android.view.Window;
 
+import androidx.annotation.AnyThread;
 import androidx.annotation.Nullable;
 import androidx.annotation.UiThread;
 import androidx.annotation.WorkerThread;
 
 import com.android.app.viewcapture.data.ExportedData;
 import com.android.app.viewcapture.data.FrameData;
+import com.android.app.viewcapture.data.MotionWindowData;
 import com.android.app.viewcapture.data.ViewNode;
+import com.android.app.viewcapture.data.WindowData;
 
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
-import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executor;
-import java.util.concurrent.FutureTask;
 import java.util.function.Consumer;
-import java.util.zip.GZIPOutputStream;
+import java.util.function.Predicate;
 
 /**
  * Utility class for capturing view data every frame
@@ -149,62 +147,51 @@
         if (mIsEnabled) mListeners.forEach(WindowListener::attachToRoot);
     }
 
-
-    /**
-     * Dumps all the active view captures
-     */
-    public void dump(PrintWriter writer, FileDescriptor out, Context context) {
+    @AnyThread
+    protected void dumpTo(ParcelFileDescriptor outFd, Context context) {
         if (!mIsEnabled) {
             return;
         }
-        ViewIdProvider idProvider = new ViewIdProvider(context.getResources());
-
-        // Collect all the tasks first so that all the tasks are posted on the executor
-        List<Pair<String, FutureTask<ExportedData>>> tasks = mListeners.stream()
-                .map(l -> {
-                    FutureTask<ExportedData> task =
-                            new FutureTask<ExportedData>(() -> l.dumpToProto(idProvider));
-                    mBgExecutor.execute(task);
-                    return Pair.create(l.name, task);
-                })
-                .collect(toList());
-        tasks.forEach(pair -> {
-            writer.println();
-            writer.println(" ContinuousViewCapture:");
-            writer.println(" window " + pair.first + ":");
-            writer.println("  pkg:" + context.getPackageName());
-            writer.print("  data:");
-            writer.flush();
-            try (OutputStream os = new FileOutputStream(out)) {
-                ExportedData data = pair.second.get();
-                OutputStream encodedOS = new GZIPOutputStream(new Base64OutputStream(os,
-                        Base64.NO_CLOSE | Base64.NO_PADDING | Base64.NO_WRAP));
-                data.writeTo(encodedOS);
-                encodedOS.close();
-                os.flush();
-            } catch (Exception e) {
-                Log.e(TAG, "Error capturing proto", e);
-            }
-            writer.println();
-            writer.println("--end--");
-        });
+        ArrayList<Class> classList = new ArrayList<>();
+        try (OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(outFd)) {
+            ExportedData.newBuilder()
+                    .setPackage(context.getPackageName())
+                    .addAllWindowData(getWindowData(context, classList, l -> l.mIsActive).get())
+                    .addAllClassname(toStringList(classList))
+                    .build()
+                    .writeTo(os);
+        } catch (InterruptedException | ExecutionException e) {
+            Log.e(TAG, "failed to get window data", e);
+        } catch (IOException e) {
+            Log.e(TAG, "failed to output data to wm trace", e);
+        }
     }
 
-    public Optional<FutureTask<ExportedData>> getDumpTask(View view) {
-        Context context = view.getContext().getApplicationContext();
-        ViewIdProvider idProvider = new ViewIdProvider(context.getResources());
-
-        return mListeners.stream()
-                .filter(l -> l.mRoot.equals(view))
-                .map(l -> {
-                    FutureTask<ExportedData> task =
-                            new FutureTask<ExportedData>(() -> l.dumpToProto(idProvider));
-                    mBgExecutor.execute(task);
-                    return task;
-                })
-                .findFirst();
+    private static List<String> toStringList(List<Class> classList) {
+        return classList.stream().map(Class::getName).toList();
     }
 
+    public CompletableFuture<Optional<MotionWindowData>> getDumpTask(View view) {
+        ArrayList<Class> classList = new ArrayList<>();
+        return getWindowData(view.getContext().getApplicationContext(), classList,
+                l -> l.mRoot.equals(view)).thenApply(list -> list.stream().findFirst().map(w ->
+                MotionWindowData.newBuilder()
+                        .addAllFrameData(w.getFrameDataList())
+                        .addAllClassname(toStringList(classList))
+                        .build()));
+    }
+
+    @AnyThread
+    private CompletableFuture<List<WindowData>> getWindowData(Context context,
+            ArrayList<Class> outClassList, Predicate<WindowListener> filter) {
+        ViewIdProvider idProvider = new ViewIdProvider(context.getResources());
+        return CompletableFuture.supplyAsync(() ->
+                mListeners.stream().filter(filter).toList(), MAIN_EXECUTOR).thenApplyAsync(it ->
+                        it.stream().map(l -> l.dumpToProto(idProvider, outClassList)).toList(),
+                mBgExecutor);
+    }
+
+
     /**
      * Once this window listener is attached to a window's root view, it traverses the entire
      * view tree on the main thread every time onDraw is called. It then saves the state of the view
@@ -400,11 +387,9 @@
         }
 
         @WorkerThread
-        private ExportedData dumpToProto(ViewIdProvider idProvider) {
+        private WindowData dumpToProto(ViewIdProvider idProvider, ArrayList<Class> classList) {
+            WindowData.Builder builder = WindowData.newBuilder().setTitle(name);
             int size = (mNodesBg[mMemorySize - 1] == null) ? mFrameIndexBg + 1 : mMemorySize;
-            ExportedData.Builder exportedDataBuilder = ExportedData.newBuilder();
-            ArrayList<Class> classList = new ArrayList<>();
-
             for (int i = size - 1; i >= 0; i--) {
                 int index = (mMemorySize + mFrameIndexBg - i) % mMemorySize;
                 ViewNode.Builder nodeBuilder = ViewNode.newBuilder();
@@ -412,11 +397,9 @@
                 FrameData.Builder frameDataBuilder = FrameData.newBuilder()
                         .setNode(nodeBuilder)
                         .setTimestamp(mFrameTimesNanosBg[index]);
-                exportedDataBuilder.addFrameData(frameDataBuilder);
+                builder.addFrameData(frameDataBuilder);
             }
-            return exportedDataBuilder
-                    .addAllClassname(classList.stream().map(Class::getName).collect(toList()))
-                    .build();
+            return builder.build();
         }
 
         private ViewRef captureViewTree(View view, ViewRef start) {
diff --git a/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto b/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto
index 899f678..d4df2ae 100644
--- a/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto
+++ b/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto
@@ -21,7 +21,17 @@
 option java_multiple_files = true;
 
 message ExportedData {
+  repeated WindowData windowData = 1;
+  optional string package = 2;
+  repeated string classname = 3;
+}
 
+message WindowData {
+  repeated FrameData frameData = 1;
+  optional string title = 2;
+}
+
+message MotionWindowData {
   repeated FrameData frameData = 1;
   repeated string classname = 2;
 }
diff --git a/viewcapturelib/tests/AndroidManifest.xml b/viewcapturelib/tests/AndroidManifest.xml
index fb47dd8..8d31c0e 100644
--- a/viewcapturelib/tests/AndroidManifest.xml
+++ b/viewcapturelib/tests/AndroidManifest.xml
@@ -15,14 +15,13 @@
   -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.app.viewcapture">
-
+    package="com.android.app.viewcapture.test">
     <application
         android:debuggable="true"
         android:theme="@android:style/Theme.NoTitleBar">
 
         <activity
-            android:name=".TestActivity"
+            android:name="com.android.app.viewcapture.TestActivity"
             android:exported="false" />
 
         <uses-library android:name="android.test.runner" />
@@ -31,7 +30,7 @@
 
     <instrumentation
         android:name="android.testing.TestableInstrumentation"
-        android:label="Tests for ViewCapture Lib"
-        android:targetPackage="com.android.app.viewcapture" />
+        android:label="Tests for MotionTool Lib"
+        android:targetPackage="com.android.app.viewcapture.test"/>
 
 </manifest>
diff --git a/viewcapturelib/tests/com/android/app/viewcapture/SettingsAwareViewCaptureTest.kt b/viewcapturelib/tests/com/android/app/viewcapture/SettingsAwareViewCaptureTest.kt
index e08b549..2157ee4 100644
--- a/viewcapturelib/tests/com/android/app/viewcapture/SettingsAwareViewCaptureTest.kt
+++ b/viewcapturelib/tests/com/android/app/viewcapture/SettingsAwareViewCaptureTest.kt
@@ -16,6 +16,7 @@
 
 package com.android.app.viewcapture
 
+import android.Manifest
 import android.content.Context
 import android.content.Intent
 import android.media.permission.SafeCloseable
@@ -26,6 +27,7 @@
 import androidx.test.ext.junit.rules.ActivityScenarioRule
 import androidx.test.filters.SmallTest
 import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.rule.GrantPermissionRule
 import com.android.app.viewcapture.SettingsAwareViewCapture.Companion.VIEW_CAPTURE_ENABLED
 import com.android.app.viewcapture.ViewCapture.MAIN_EXECUTOR
 import junit.framework.Assert.assertEquals
@@ -40,6 +42,8 @@
     private val activityIntent = Intent(context, TestActivity::class.java)
 
     @get:Rule val activityScenarioRule = ActivityScenarioRule<TestActivity>(activityIntent)
+    @get:Rule val grantPermissionRule =
+        GrantPermissionRule.grant(Manifest.permission.WRITE_SECURE_SETTINGS)
 
     @Test
     fun do_not_capture_view_hierarchies_if_setting_is_disabled() {
diff --git a/viewcapturelib/tests/com/android/app/viewcapture/ViewCaptureTest.kt b/viewcapturelib/tests/com/android/app/viewcapture/ViewCaptureTest.kt
index b0fcca1..b341fe9 100644
--- a/viewcapturelib/tests/com/android/app/viewcapture/ViewCaptureTest.kt
+++ b/viewcapturelib/tests/com/android/app/viewcapture/ViewCaptureTest.kt
@@ -27,7 +27,7 @@
 import androidx.test.filters.SmallTest
 import androidx.test.platform.app.InstrumentationRegistry
 import com.android.app.viewcapture.TestActivity.Companion.TEXT_VIEW_COUNT
-import com.android.app.viewcapture.data.ExportedData
+import com.android.app.viewcapture.data.MotionWindowData
 import junit.framework.Assert.assertEquals
 import org.junit.Rule
 import org.junit.Test
@@ -50,33 +50,33 @@
     @get:Rule val activityScenarioRule = ActivityScenarioRule<TestActivity>(activityIntent)
 
     @Test
-    fun testViewCaptureDumpsOneFrameAfterInvalidate() {
+    fun testWindowListenerDumpsOneFrameAfterInvalidate() {
         activityScenarioRule.scenario.onActivity { activity ->
             Choreographer.getInstance().postFrameCallback {
                 val closeable = startViewCaptureAndInvalidateNTimes(1, activity)
                 val rootView = activity.findViewById<View>(android.R.id.content)
-                val exportedData = viewCapture.getDumpTask(rootView).get().get()
+                val data = viewCapture.getDumpTask(rootView).get().get()
 
-                assertEquals(1, exportedData.frameDataList.size)
-                verifyTestActivityViewHierarchy(exportedData)
+                assertEquals(1, data.frameDataList.size)
+                verifyTestActivityViewHierarchy(data)
                 closeable.close()
             }
         }
     }
 
     @Test
-    fun testViewCaptureDumpsCorrectlyAfterRecyclingStarted() {
+    fun testWindowListenerDumpsCorrectlyAfterRecyclingStarted() {
         activityScenarioRule.scenario.onActivity { activity ->
             Choreographer.getInstance().postFrameCallback {
                 val closeable = startViewCaptureAndInvalidateNTimes(memorySize + 5, activity)
                 val rootView = activity.findViewById<View>(android.R.id.content)
-                val exportedData = viewCapture.getDumpTask(rootView).get().get()
+                val data = viewCapture.getDumpTask(rootView).get().get()
 
                 // since ViewCapture MEMORY_SIZE is [viewCaptureMemorySize], only
                 // [viewCaptureMemorySize] frames are exported, although the view is invalidated
                 // [viewCaptureMemorySize + 5] times
-                assertEquals(memorySize, exportedData.frameDataList.size)
-                verifyTestActivityViewHierarchy(exportedData)
+                assertEquals(memorySize, data.frameDataList.size)
+                verifyTestActivityViewHierarchy(data)
                 closeable.close()
             }
         }
@@ -96,7 +96,7 @@
         }
     }
 
-    private fun verifyTestActivityViewHierarchy(exportedData: ExportedData) {
+    private fun verifyTestActivityViewHierarchy(exportedData: MotionWindowData) {
         for (frame in exportedData.frameDataList) {
             val testActivityRoot =
                 frame.node // FrameLayout (android.R.id.content)