OSDN Git Service

Only AV formats should be handled by MediaPlayer (Java side)
authorIain Merrick <husky@google.com>
Wed, 27 Oct 2010 09:15:14 +0000 (10:15 +0100)
committerIain Merrick <husky@google.com>
Wed, 27 Oct 2010 10:28:30 +0000 (11:28 +0100)
Must be submitted with corresponding C++ change (I50da7599).

When opening a text file in the browser, WebKit was attempting to
display it as a movie. This is because the media player now reports
that it can handle various document formats, including plain text.

See http://b/issue?id=3132917

This CL updates WebViewCore.supportsMimeType() to explicitly check
for audio and video formats only. This is called from WebKit via
JNI, and doesn't seem to be used elsewhere, so it should be a safe
change to make. Renamed to isSupportedMediaMimeType() for clarity.

Test: push a text file to /sdcard/foo.txt, and open it in the
browser (as file:///sdcard/foo.txt).

Change-Id: Id39b770b05ced7c976d8043649845f26115b24c9

core/java/android/webkit/WebViewCore.java

index 1c8e2cd..cd6c81e 100644 (file)
@@ -260,9 +260,11 @@ final class WebViewCore {
      * Given mimeType, check whether it's supported in Android media framework.
      * mimeType could be such as "audio/ogg" and "video/mp4".
      */
-    /* package */ static boolean supportsMimeType(String mimeType) {
-        return MediaFile.getFileTypeForMimeType(mimeType) > 0;
+    /* package */ static boolean isSupportedMediaMimeType(String mimeType) {
+        int fileType = MediaFile.getFileTypeForMimeType(mimeType);
+        return MediaFile.isAudioFileType(fileType) || MediaFile.isVideoFileType(fileType);
     }
+
     /**
      * Add an error message to the client's console.
      * @param message The message to add