Samsung devices: dual networking I have the following setup: a Wi-Fi device which is NOT connected to the internet, like a drone or IoT device. The data of the device shall be uploaded to the internet.

While it is possible to connect to both networks within an app using the ConnectivityManager, it is not possible to use the mobile internet outside of the app. The devices have Android 6.0 or higher, so it should be actually supported by the Android system. But it seems to me, that Samsung did not implemented that support.

How do I use the mobile internet for instance to receive mails or push notifications while I am connected to a Wi-Fi which has no internet itself.

Thanks.
Similar questions have been asked here: 


Can an android phone connect to both Wi-Fi and mobile data network at the same time?
How to enable dual networking in Android shell?
and
How do I connect to a wifi ap and 3g network simultaneously?


However due to the bounty description I will try to aggregate these facts and expand a bit since the answers were not marked as accepted.

Short answer it is possible to have dual networking but workarounds differ slightly.




From this source : Switch seamlessly between WiFi and Cellular with Multipath-TCP You can make use of Multi-TCP.


Multipath TCP (MPTCP) is Multipath-TCP is an extension to TCP that allows the parallel usage of multiple Internet connections.
Multipath-TCP is already implemented for the Linux Kernel, but not yet integrated into the official upstream kernel.

The source code (and some precompiled kernels, including Android builds) can be found here: http://multipath-tcp.org

Extra source with reference to Samsung device: MPTCP on Android Devices , and MultiPath TCP - Linux Kernel implementation. 




In another source,  enable wireless and 4g at the same time  Users claim they were able to enable dual networking with the following workaround (quoted):


Turn off wifi in the normal way (from the phone's user interface) if it's not already off.


All the following steps done in a root shell:


load the drivers

busybox insmod /system/lib/modules/cfg80211.ko
busybox insmod /system/lib/modules/wlan.ko
start wpa_supplicant to connect to the first available wireless network. The wpa_supplicant.conf file I list below is the one maintained automatically by the phone as you join new networks. If you want more control (e.g. connect to only a specific network), copy the wpa_supplicant.conf file somewhere, modify it as needed, and specify it on the command line.


wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf


dhcpcd 


busybox pkill dhcpcd
 rm /data/misc/dhcp/*
 dhcpcd wlan0


verify route


busybox route

For me this is showing the original default first on the list (goes through rmnet_usb0) followed by the new one configured for the wireless lan wlan0. Traceroute shows the traffic going out the first one.

Now, at this point if you try to enable wifi normally from the phone it will not work. To make it work:

ifconfig wlan0 down
 ifconfig wlan0 unplumb
 rmmod wlan
 rmmod cfg80211

And you can turn on wireless again


Alternatively with script:

# enable dual-networking:
pkill dhcpcd
svc wifi disable
svc data enable
netcfg wlan0 up
cd /data/misc/wifi/.
wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
dhcpcd wlan0
ip route add x.x.x.x via x.x.x.y # add any desired local route

# disable dual-networking:
ip route del x.x.x.x/x via x.x.x.y
pkill dhcpcd
pkill wpa_supplicant 
rm -rf /data/misc/wifi/wlan0
netcfg wlan0 down
svc wifi disable
svc data disable


(A script runner is needed to run these scripts and root; you can get one here: SH Script Runner

And they noted: 

It works perfectly but note that you don't actually see the wifi icon turning on, but if you run netcfg | grep UP you will see that the wlan0 interface is up and running (as well as the rmnet_usb0 mobile data interface, both of them will be up and will have the expected IP addresses) and you can access your local LAN while your mobile data 3g/4g whatever provides your default route to the outside world.




Other workarounds:


Using Super Download Lite

The developers of the app claim that it has the ability to perfom dual networking on android devices by combing 3G/4G and Wi-Fi networks.




Modifying the routing table


Another source: http://ironings4.rssing.com/chan-3701516/all_p2.html.

Provided details on creating a bash script in order to modify roting table to allow both 3G/4G work with Wi-Fi. Here is the script:

pkill com.android.phone sleep 30 route add -net 10.0.0.0 netmask 255.0.0.0 dev ppp0 route add -net 15.0.0.0 netmask 255.0.0.0 dev ppp0


The above is an example for a couple of address ranges to redirect to 3G connection  to the routing table via linux shell for using INTRANET via ppp0 for a few address ranges, while all the other destination addresses normally go via Wi-Fi.

The trick here is to force an application on the phone (or maybe it is a service, called com.android.phone) probably related to 3G radio interface to crash while you are connected to wifi, the 3G signal indicator will go down for a few seconds and soon after it will return to normal but this time with both H(SDPA) and Wifi icons showing on the notification area on the upper right of the screen.




In another article: Let WiFi and 3G connection work together by hacking ConnectivityService.java   (migrated to XDA forums)
The offered how to accomplish the task by hacking connectivity service:


Fully quoted:

“The goal of COIN project is to use WiFi and 3G connections simultaneously. So it conflicts with the policy of Connectivity Service, but there is no configuration to edit the policy, and it is hard coded. You can find the clue in ConnectivityService.java:handleConnect function.

Our current solution is quite brutal, which is to mask the eyes of Connectivity Service by modifying its message handler entry like the following:

// must be stateless – things change under us.
 private class MyHandler extends Handler {
 @Override
 public void handleMessage(Message msg) {
 NetworkInfo info;
 //added by COIN to disable Connectivity Service
 int networkState = 8; //not any following state
 /*use static google dns server for wifi and 3g*/
 if (msg.what == NetworkStateTracker.EVENT_STATE_CHANGED) {
 SystemProperties.set(“net.dns1″, “8.8.8.8″);
 SystemProperties.set(“net.dns2″, “8.8.4.4″);
 bumpDns();
 }
 //////////////////////////////////////////////
 //switch (msg.what) {
 switch (networkState) {
 case NetworkStateTracker.EVENT_STATE_CHANGED:
 info = (NetworkInfo) msg.obj;
 int type = info.getType();

…..

And then compile the modified ConnectivityService.java in the android source code tree, you can get an new services.jar file in framework directory. Replace the existing services.jar on the cell phone with the following adb commands, then reboot the phone

 adb shell “mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system”
adb shell “chmod 0777 /system/framework”
adb push services.jar /system/framework
 adb shell “chmod 0644 /system/framework/services.jar”
adb shell “chmod 0755 /system/framework”
.”




Conclusion

While I couldn’t test some of the workarounds myself, I have learnt most of these might have worked in earlier android builds (based on the evidence) so I am not   sure if the same is applicable in android 6. This feature seems likely to be implemented with emerging technologies evidenced by Multipath TCP technology described. For all the workarounds require root.

Hope this brings some light.

References

(Included in body text)