mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Use different authorities for AssetContentProvider
Otherwise it's impossible to install the androidTest apk of both lib-datasource and lib-exoplayer on the same device #cherrypick PiperOrigin-RevId: 727867871
This commit is contained in:
parent
18f3864773
commit
527e1d52ae
@ -27,7 +27,7 @@
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="MissingApplicationIcon,HardcodedDebugMode">
|
||||
<provider
|
||||
android:authorities="androidx.media3.test.utils.AssetContentProvider"
|
||||
android:authorities="androidx.media3.datasource.test.AssetContentProvider"
|
||||
android:name="androidx.media3.test.utils.AssetContentProvider"/>
|
||||
</application>
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class ContentDataSourceContractTest extends DataSourceContractTest {
|
||||
|
||||
private static final String AUTHORITY = "androidx.media3.datasource.test.AssetContentProvider";
|
||||
private static final String DATA_PATH = "media/mp3/1024_incrementing_bytes.mp3";
|
||||
|
||||
@Override
|
||||
@ -42,18 +43,18 @@ public final class ContentDataSourceContractTest extends DataSourceContractTest
|
||||
return ImmutableList.of(
|
||||
new TestResource.Builder()
|
||||
.setName("simple (pipe=false)")
|
||||
.setUri(AssetContentProvider.buildUri(DATA_PATH, /* pipeMode= */ false))
|
||||
.setUri(AssetContentProvider.buildUri(AUTHORITY, DATA_PATH, /* pipeMode= */ false))
|
||||
.setExpectedBytes(completeData)
|
||||
.build(),
|
||||
new TestResource.Builder()
|
||||
.setName("simple (pipe=true)")
|
||||
.setUri(AssetContentProvider.buildUri(DATA_PATH, /* pipeMode= */ true))
|
||||
.setUri(AssetContentProvider.buildUri(AUTHORITY, DATA_PATH, /* pipeMode= */ true))
|
||||
.setExpectedBytes(completeData)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Uri getNotFoundUri() {
|
||||
return AssetContentProvider.buildUri("not/a/real/path", /* pipeMode= */ false);
|
||||
return AssetContentProvider.buildUri(AUTHORITY, "not/a/real/path", /* pipeMode= */ false);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class ContentDataSourceTest {
|
||||
|
||||
private static final String AUTHORITY = "androidx.media3.datasource.test.AssetContentProvider";
|
||||
private static final String DATA_PATH = "media/mp3/1024_incrementing_bytes.mp3";
|
||||
|
||||
@Test
|
||||
@ -70,7 +71,7 @@ public final class ContentDataSourceTest {
|
||||
public void readInvalidUri() throws Exception {
|
||||
ContentDataSource dataSource =
|
||||
new ContentDataSource(ApplicationProvider.getApplicationContext());
|
||||
Uri contentUri = AssetContentProvider.buildUri("does/not.exist", false);
|
||||
Uri contentUri = AssetContentProvider.buildUri(AUTHORITY, "does/not.exist", false);
|
||||
DataSpec dataSpec = new DataSpec(contentUri);
|
||||
try {
|
||||
dataSource.open(dataSpec);
|
||||
@ -84,7 +85,7 @@ public final class ContentDataSourceTest {
|
||||
}
|
||||
|
||||
private static void assertData(int offset, int length, boolean pipeMode) throws IOException {
|
||||
Uri contentUri = AssetContentProvider.buildUri(DATA_PATH, pipeMode);
|
||||
Uri contentUri = AssetContentProvider.buildUri(AUTHORITY, DATA_PATH, pipeMode);
|
||||
ContentDataSource dataSource =
|
||||
new ContentDataSource(ApplicationProvider.getApplicationContext());
|
||||
try {
|
||||
|
@ -27,7 +27,7 @@
|
||||
tools:ignore="MissingApplicationIcon,HardcodedDebugMode"
|
||||
android:usesCleartextTraffic="true">
|
||||
<provider
|
||||
android:authorities="androidx.media3.test.utils.AssetContentProvider"
|
||||
android:authorities="androidx.media3.exoplayer.test.AssetContentProvider"
|
||||
android:name="androidx.media3.test.utils.AssetContentProvider"/>
|
||||
</application>
|
||||
|
||||
|
@ -72,6 +72,8 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
@RunWith(Parameterized.class)
|
||||
public class MediaExtractorContractTest {
|
||||
|
||||
private static final String AUTHORITY = "androidx.media3.exoplayer.test.AssetContentProvider";
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static ImmutableList<Function<Context, MediaExtractorProxy>>
|
||||
mediaExtractorProxyFactories() {
|
||||
@ -226,7 +228,8 @@ public class MediaExtractorContractTest {
|
||||
|
||||
@Test
|
||||
public void setDataSource_withContentUri_returnsCorrectTrackCount() throws IOException {
|
||||
Uri contentUri = AssetContentProvider.buildUri("media/mp4/sample.mp4", /* pipeMode= */ false);
|
||||
Uri contentUri =
|
||||
AssetContentProvider.buildUri(AUTHORITY, "media/mp4/sample.mp4", /* pipeMode= */ false);
|
||||
|
||||
mediaExtractorProxy.setDataSource(context, contentUri, /* headers= */ null);
|
||||
|
||||
|
@ -21,8 +21,5 @@
|
||||
android:allowBackup="false"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="MissingApplicationIcon,HardcodedDebugMode">
|
||||
<provider
|
||||
android:authorities="androidx.media3.test.utils.AssetContentProvider"
|
||||
android:name="androidx.media3.test.utils.AssetContentProvider"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -38,14 +38,13 @@ import java.io.IOException;
|
||||
public final class AssetContentProvider extends ContentProvider
|
||||
implements ContentProvider.PipeDataWriter<Object> {
|
||||
|
||||
private static final String AUTHORITY = "androidx.media3.test.utils.AssetContentProvider";
|
||||
private static final String PARAM_PIPE_MODE = "pipe-mode";
|
||||
|
||||
public static Uri buildUri(String filePath, boolean pipeMode) {
|
||||
public static Uri buildUri(String authority, String filePath, boolean pipeMode) {
|
||||
Uri.Builder builder =
|
||||
new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(AUTHORITY)
|
||||
.authority(authority)
|
||||
.path(filePath);
|
||||
if (pipeMode) {
|
||||
builder.appendQueryParameter(PARAM_PIPE_MODE, "1");
|
||||
|
Loading…
x
Reference in New Issue
Block a user