From 132650df28a22e61fe6db1206546acd6ddf16988 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Wed, 3 Dec 2014 10:04:54 -0500 Subject: [PATCH] CB-8112 Turn off mediaPlaybackRequiresUserGesture --- .../src/org/apache/cordova/CordovaWebView.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 4d01f586..62a641b5 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -215,8 +215,12 @@ public class CordovaWebView extends WebView { // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist // while we do this - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { Level16Apis.enableUniversalAccess(settings); + } + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + Level17Apis.setMediaPlaybackRequiresUserGesture(settings, false); + } // Enable database // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16 String databasePath = getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); @@ -831,12 +835,19 @@ public class CordovaWebView extends WebView { // Wrapping these functions in their own class prevents warnings in adb like: // VFY: unable to resolve virtual method 285: Landroid/webkit/WebSettings;.setAllowUniversalAccessFromFileURLs @TargetApi(16) - private static class Level16Apis { + private static final class Level16Apis { static void enableUniversalAccess(WebSettings settings) { settings.setAllowUniversalAccessFromFileURLs(true); } } - + + @TargetApi(17) + private static final class Level17Apis { + static void setMediaPlaybackRequiresUserGesture(WebSettings settings, boolean value) { + settings.setMediaPlaybackRequiresUserGesture(value); + } + } + public void printBackForwardList() { WebBackForwardList currentList = this.copyBackForwardList(); int currentSize = currentList.getSize();