Add DeviceProfile dump files into artifacts

Artifacts are collected from:

    <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
        <option name="directory-keys" value="/data/user/0/com.google.android.apps.nexuslauncher/files" />
        <option name="collect-on-run-ended-only" value="true" />
    </metrics_collector>

Defined in NexusLauncherTests.xml, by writing the files into that
directory the files should show in the artifacts section when a
test fails.

Bug: 390496167
Flag: TEST_ONLY
Test: all dumpTest
Test: dump files should now be available in test artifacts
Change-Id: I046b1482afaea647351462983c4cbab5f3bc29bc
diff --git a/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt b/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
index 8cdf380..3658989 100644
--- a/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
@@ -364,7 +364,13 @@
         context.assets.open("dumpTests/$fileName").bufferedReader().use(BufferedReader::readText)
 
     private fun writeToDevice(context: Context, fileName: String, content: String) {
-        File(context.getDir("dumpTests", Context.MODE_PRIVATE), fileName).writeText(content)
+        val dir =
+            File(context.filesDir, "dumpTests").also {
+                if (!it.exists()) {
+                    it.mkdirs()
+                }
+            }
+        File(dir, fileName).writeText(content)
     }
 
     protected fun Float.dpToPx(): Float {