Detect if the current network is wifi or not and update webkit.
This info is passed to youtube.com via navigator.networkType

Fixes Bug: 2368650
diff --git a/core/java/android/webkit/JWebCoreJavaBridge.java b/core/java/android/webkit/JWebCoreJavaBridge.java
index f350d13..e496d97 100644
--- a/core/java/android/webkit/JWebCoreJavaBridge.java
+++ b/core/java/android/webkit/JWebCoreJavaBridge.java
@@ -247,4 +247,5 @@
     private native void nativeUpdatePluginDirectories(String[] directories,
             boolean reload);
     public native void setNetworkOnLine(boolean online);
+    public native void setNetworkType(String type, String subtype);
 }
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 09ed931..db5641c 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -80,6 +80,7 @@
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
 
 import junit.framework.Assert;
@@ -1132,6 +1133,16 @@
     }
 
     /**
+     * Inform WebView about the current network type.
+     * {@hide}
+     */
+    public void setNetworkType(String type, String subtype) {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("type", type);
+        map.put("subtype", subtype);
+        mWebViewCore.sendMessage(EventHub.SET_NETWORK_TYPE, map);
+    }
+    /**
      * Save the state of this WebView used in
      * {@link android.app.Activity#onSaveInstanceState}. Please note that this
      * method no longer stores the display data for this WebView. The previous
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 949b318..d509bb4 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -878,6 +878,8 @@
 
         static final int HIDE_FULLSCREEN = 182;
 
+        static final int SET_NETWORK_TYPE = 183;
+
         // private message ids
         private static final int DESTROY =     200;
 
@@ -1110,6 +1112,16 @@
                                     .setNetworkOnLine(msg.arg1 == 1);
                             break;
 
+                        case SET_NETWORK_TYPE:
+                            if (BrowserFrame.sJavaBridge == null) {
+                                throw new IllegalStateException("No WebView " +
+                                        "has been created in this process!");
+                            }
+                            Map<String, String> map = (Map<String, String>) msg.obj;
+                            BrowserFrame.sJavaBridge
+                                    .setNetworkType(map.get("type"), map.get("subtype"));
+                            break;
+
                         case CLEAR_CACHE:
                             clearCache(msg.arg1 == 1);
                             break;