summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/providers/media/ConfigStore.java22
-rw-r--r--src/com/android/providers/media/MediaApplication.java6
-rw-r--r--tests/src/com/android/providers/media/MediaProviderTest.java6
3 files changed, 31 insertions, 3 deletions
diff --git a/src/com/android/providers/media/ConfigStore.java b/src/com/android/providers/media/ConfigStore.java
index 9094ccb92..cbf7670c0 100644
--- a/src/com/android/providers/media/ConfigStore.java
+++ b/src/com/android/providers/media/ConfigStore.java
@@ -258,6 +258,28 @@ public interface ConfigStore {
writer.println(" transcodeCompatStale=" + getTranscodeCompatStale());
}
+ static ConfigStore getDefaultConfigStore() {
+ return new ConfigStore() {
+ @NonNull
+ @Override
+ public List<String> getTranscodeCompatManifest() {
+ return Collections.emptyList();
+ }
+
+ @NonNull
+ @Override
+ public List<String> getTranscodeCompatStale() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void addOnChangeListener(@NonNull Executor executor,
+ @NonNull Runnable listener) {
+ // Do nothing
+ }
+ };
+ }
+
/**
* Implementation of the {@link ConfigStore} that reads "real" configs from
* {@link android.provider.DeviceConfig}. Meant to be used by the "production" code.
diff --git a/src/com/android/providers/media/MediaApplication.java b/src/com/android/providers/media/MediaApplication.java
index 3cef162f5..2bab13026 100644
--- a/src/com/android/providers/media/MediaApplication.java
+++ b/src/com/android/providers/media/MediaApplication.java
@@ -104,7 +104,8 @@ public class MediaApplication extends Application {
synchronized (MediaApplication.class) {
sInstance = this;
if (sConfigStore == null) {
- sConfigStore = new ConfigStore.ConfigStoreImpl(getResources());
+ sConfigStore = sIsTestProcess ? ConfigStore.getDefaultConfigStore() :
+ new ConfigStore.ConfigStoreImpl(getResources());
}
configStore = sConfigStore;
}
@@ -141,7 +142,8 @@ public class MediaApplication extends Application {
// Normally ConfigStore would be created in onCreate() above, but in some cases the
// framework may create ContentProvider-s *before* the Application#onCreate() is called.
// In this case we use the MediaProvider instance to create the ConfigStore.
- sConfigStore = new ConfigStore.ConfigStoreImpl(getAppContext().getResources());
+ sConfigStore = sIsTestProcess ? ConfigStore.getDefaultConfigStore() :
+ new ConfigStore.ConfigStoreImpl(getAppContext().getResources());
}
return sConfigStore;
}
diff --git a/tests/src/com/android/providers/media/MediaProviderTest.java b/tests/src/com/android/providers/media/MediaProviderTest.java
index a8191a17e..fb9be244d 100644
--- a/tests/src/com/android/providers/media/MediaProviderTest.java
+++ b/tests/src/com/android/providers/media/MediaProviderTest.java
@@ -81,6 +81,7 @@ import com.android.providers.media.util.SQLiteQueryBuilder;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Assume;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -113,7 +114,7 @@ public class MediaProviderTest {
private static ContentResolver sIsolatedResolver;
@BeforeClass
- public static void setUp() {
+ public static void setUpBeforeClass() {
InstrumentationRegistry.getInstrumentation().getUiAutomation()
.adoptShellPermissionIdentity(Manifest.permission.LOG_COMPAT_CHANGE,
Manifest.permission.READ_COMPAT_CHANGE_CONFIG,
@@ -124,7 +125,10 @@ public class MediaProviderTest {
// MANAGE_USERS permission for MediaProvider module.
Manifest.permission.CREATE_USERS,
Manifest.permission.INTERACT_ACROSS_USERS);
+ }
+ @Before
+ public void setUp() {
resetIsolatedContext();
}