summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author Dipankar Bhardwaj <dipankarb@google.com> 2025-02-18 07:11:38 -0800
committer Dipankar Bhardwaj <dipankarb@google.com> 2025-02-18 07:11:38 -0800
commit26826390d285b57a0af3eed540d6e6a082d3d0e7 (patch)
treed665c0d343f8353cd9fc701e362f96b8b67bb52c /tests
parent1f01a45bbf0c7606809df3c2586eaac2084fefa9 (diff)
Use fixed thread pool for calls to OemMetadataService
Instead of creating a new thread everytime we want to fetch OEM metadata, updating code to use a fixed thread pool of 3 threads. We do not expect lot of concurrent requests to this as scanner code is currently serialised, hence keeping thread pool size low. Also guarded oem metadata connection code with try-catch to avoid onCreate() crash. Test: atest OemMetadataServiceTest Bug: 377432406 Change-Id: I70a0b6ca6ae43f7ba7ab086103365cc16b3497fa Flag: EXEMPT minor fix
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/media/oemmetadataservices/OemMetadataServiceTest.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/src/com/android/providers/media/oemmetadataservices/OemMetadataServiceTest.java b/tests/src/com/android/providers/media/oemmetadataservices/OemMetadataServiceTest.java
index c01e06f00..774635be4 100644
--- a/tests/src/com/android/providers/media/oemmetadataservices/OemMetadataServiceTest.java
+++ b/tests/src/com/android/providers/media/oemmetadataservices/OemMetadataServiceTest.java
@@ -36,15 +36,13 @@ import android.os.Build;
import android.os.Environment;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
-import android.platform.test.annotations.RequiresFlagsEnabled;
-import android.platform.test.flag.junit.CheckFlagsRule;
-import android.platform.test.flag.junit.DeviceFlagsValueProvider;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.IOemMetadataService;
import android.provider.MediaStore;
import android.provider.MediaStore.Files.FileColumns;
import android.provider.OemMetadataService;
import android.provider.OemMetadataServiceWrapper;
-import android.provider.media.internal.flags.Flags;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SdkSuppress;
@@ -73,12 +71,11 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Supplier;
@RunWith(AndroidJUnit4.class)
-@RequiresFlagsEnabled(com.android.providers.media.flags.Flags.FLAG_ENABLE_OEM_METADATA)
+@EnableFlags(com.android.providers.media.flags.Flags.FLAG_ENABLE_OEM_METADATA)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
public class OemMetadataServiceTest {
- @Rule
- public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+ @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private static final long POLLING_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
private static final long POLLING_SLEEP_MILLIS = 100;
@@ -179,6 +176,7 @@ public class OemMetadataServiceTest {
}
} finally {
audioFile.delete();
+ isolatedContext.unbindService(modernMediaScanner.getOemMetadataServiceConnection());
}
}