From 59b26173a750f450d5f85ec4888de57e0abcde97 Mon Sep 17 00:00:00 2001 From: hayaksi1 <193020925+hayaksi1@users.noreply.github.com> Date: Thu, 13 Aug 2026 17:36:51 +0300 Subject: [PATCH] Create the fake MediaStore directory without java.nio.file Files.createTempDirectory needs API 26 and the fake lives in the main source set of tests:testutils, so lint failed it against the minimum of 24. File.createTempFile has been available since API 1 and still gives each provider instance its own directory. --- .../tests/testutils/fake/FakeMediaStoreContentProvider.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/fake/FakeMediaStoreContentProvider.kt b/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/fake/FakeMediaStoreContentProvider.kt index 4a1ffcda29..13077db51f 100644 --- a/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/fake/FakeMediaStoreContentProvider.kt +++ b/tests/testutils/src/main/kotlin/io/element/android/tests/testutils/fake/FakeMediaStoreContentProvider.kt @@ -17,7 +17,6 @@ import android.provider.MediaStore import androidx.test.core.app.ApplicationProvider import org.robolectric.shadows.ShadowContentResolver import java.io.File -import java.nio.file.Files /** * Stands in for the MediaStore provider: it records the display names an insert is attempted with, @@ -25,7 +24,10 @@ import java.nio.file.Files * way MediaStore does once a directory already holds 32 files with the same name. */ class FakeMediaStoreContentProvider : ContentProvider() { - private val directory: File = Files.createTempDirectory("fake-media-store").toFile() + private val directory: File = File.createTempFile("fake-media-store", null).apply { + delete() + mkdir() + } val insertedDisplayNames = mutableListOf()