Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5dba888 authored by Andrei Popescu's avatar Andrei Popescu
Browse files

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
parent 843e8975
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -247,4 +247,5 @@ final class JWebCoreJavaBridge extends Handler {
    private native void nativeUpdatePluginDirectories(String[] directories,
            boolean reload);
    public native void setNetworkOnLine(boolean online);
    public native void setNetworkType(String type, String subtype);
}
+11 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;

import junit.framework.Assert;
@@ -1131,6 +1132,16 @@ public class WebView extends AbsoluteLayout
                networkUp ? 1 : 0, 0);
    }

    /**
     * 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
+12 −0
Original line number Diff line number Diff line
@@ -878,6 +878,8 @@ final class WebViewCore {

        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 @@ final class WebViewCore {
                                    .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;