Skip to content
Snippets Groups Projects
Commit 6a79d348 authored by Hyoungho Choi's avatar Hyoungho Choi Committed by Sahana Rao
Browse files

Add 'audio/mp3' to android.mime.types

MimeTypeMap.getSingleton().getExtensionFromMimeType() returns null since
MimeTypeMap doesn't have 'audio/mp3'. It makes
FileUtils#buildUniqueFile() returns a wrong file. For example, when
mimetype is 'audio/mp3' and filename is test.mp3 which already exists,
it returns test.mp3 (1).

Bug: 205774136
Test: atest FrameworksCoreTests:android.os.FileUtilsTest
Test: atest CtsMimeMapTestCases
Change-Id: I201a7955c735fe99813b5a99692525ace7b0f5fe
parent 5b2abf1c
No related branches found
No related tags found
No related merge requests found
......@@ -58,10 +58,10 @@ import android.provider.DocumentsContract.Document;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import libcore.io.Streams;
import com.google.android.collect.Sets;
import libcore.io.Streams;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......@@ -477,6 +477,14 @@ public class FileUtilsTest {
new File(mTarget, "test (1).jpg").createNewFile();
assertNameEquals("test (2).jpg",
FileUtils.buildUniqueFile(mTarget, "image/jpeg", "test.jpg"));
assertNameEquals("test.mp3", FileUtils.buildUniqueFile(mTarget, "audio/mp3", "test.mp3"));
new File(mTarget, "test.mp3").createNewFile();
assertNameEquals("test (1).mp3",
FileUtils.buildUniqueFile(mTarget, "audio/mp3", "test.mp3"));
new File(mTarget, "test (1).mp3").createNewFile();
assertNameEquals("test (2).mp3",
FileUtils.buildUniqueFile(mTarget, "audio/mp3", "test.mp3"));
}
@Test
......
......@@ -86,6 +86,7 @@
?audio/x-matroska mka
?audio/x-pn-realaudio ra
?audio/x-mpeg mp3
?audio/mp3 mp3
?image/bmp bmp
?image/gif gif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment