Introduce vendor.mime.types
Like mime.types and android.mime.types, this file specifies mappings between MIME types and file extensions. Unlike those files, it can only be used to define _additional_ mapping but not modify (change, remove) any mappings defined by those files. This is done by prepending '?' to every line element from vendor.mime.types that doesn't already have one; when there is a leading "?", it is ignored so that it's okay to move a line from {android,vendor}.mime.types without necessarily changing it. Test: Checked manually that vendor.mime.types works as expected. Specifically, after adding these lines to vendor.mime.type: audio/mpeg testmpeg audio/testmpeg mp3 ?mime/foo ?fooext the following test passes: MimeTypeMap map = MimeTypeMap.getSingleton(); // Original mapping is unchanged assertEquals("mp3", map.getExtensionFromMimeType("audio/mpeg")); assertEquals("audio/mpeg", map.getMimeTypeFromExtension("mp3")); // Map from the key to existing value is added assertEquals("audio/mpeg", map.getMimeTypeFromExtension("testmpeg")); assertEquals("mp3", map.getExtensionFromMimeType("audio/testmpeg")); // Completely new mapping is added both ways assertEquals("mime/foo", map.getMimeTypeFromExtension("fooext")); assertEquals("fooext", map.getExtensionFromMimeType("mime/foo")); Bug: 141842825 Change-Id: Iaf918ce39324709ff58a8e0f9612e4827a673323
Loading
Please register or sign in to comment