MPTCP-smartphone-thesis / MultipathControl

GUI to manage MPTCP settings and log statistics on Android devices
26 stars 21 forks source link

Android L support #1

Closed matttbe closed 6 years ago

matttbe commented 9 years ago

It is currently not planed to support Android 5 but it's possible that we will have to change a bit the way to use the cellular interface when the WiFi one is enabled.

Let's write here this tip to not forget it :-)

Src: http://stackoverflow.com/a/28696825

Well finally found solution for this.Trick was to use capability as NET_CAPABILITY_INTERNET.Which is same as "startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_HIPRI);"

See the Firmware design here

builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);

After this i am able to get onAvailable callback from system and later i set my process default network as mobile data.

Hence all the request goes over Mobile data even if wifi is on.WOW!

Note: This was not working in initial releases of Preview L.

tarunmangla commented 8 years ago

Can you direct on how to integrate this code to the existing code i.e. How to replace the deprecated startUsingNetworkFeature with this code?

matttbe commented 8 years ago

Hi @tarunmangla,

Two techniques are used to maintain active both LTE and WiFi connections:

Note that it is possible to check the version of Android in the code:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
     // see https://developer.android.com/reference/android/os/Build.VERSION_CODES.html
}
son2017 commented 6 years ago

@tarunmangla can you please specfy the code how to implement on that in below code.

    public void setMobileDataActive(boolean mEnabled) {
        if (Manager.DEBUG)
            Log.d(Manager.TAG, "setMobileDataActive " + new Date());

        ConnectivityManager cManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (isMobileDataEnabled() && isWifiConnected() && mEnabled)
            cManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
                    "enableHIPRI");
        else
            cManager.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
                    "enableHIPRI");
    }
matttbe commented 6 years ago

This should now be supported thanks to the new branch from @qdeconinck : https://github.com/MPTCP-smartphone-thesis/MultipathControl/tree/marshmallow