Running 3G and WiFi connections simultaneously

Cherilee

New member
May 7, 2012
4
1
0
Hello to all.

I was trying to start this thread in Android Software and Hacking General, but got a warning about not having enough posts to submit a thread there, so I'm going to try here.

I have a Samsung Galaxy S II phone with the newest Android version. My goal is to modify the system so that 3G and WiFi are able to run together, side-by-side, simultaneously without 3G being turned off. Now, every time I connect to a WLAN, 3G cuts.

[OK, the spam police won't let me post outside links; Google Mobisocial 3G Wifi Stanford to find the article I'm talking about.]
MobiSocial News wrote about a hack that modifies ConnectivityService.java in a rather crude way, but according to the author of that article, it works on a 2.x Android system. There's not much info about the hack, but it's at least something and sounds plausible.

I tried to follow the instructions; I downloaded newest Android source codes, modified ConnectivityService.java and built the kernel by following these instructions: [a link to source.android.com "Building the System"]. But unfortunately, make didn't produce a services.jar mentioned in the article.

---

Does anyone know anything about using 3G and WiFi at the same time? Is it even possible?

Every piece of information is valuable, so don't be afraid to post. Thanks!
 
  • Like
Reactions: 1ad_m12

Cherilee

New member
May 7, 2012
4
1
0
Anyone?

If I was misunderstood in my previous post; I'm not looking to have simultaneous connections, I just want the mobile network device to be online while I'm doing something with WiFi. And when WiFi cuts off, for example in a train tunnel or something, 3G takes its place.
 

cboursinos

New member
Mar 5, 2013
4
0
0
Athens
I want to do the same with you

Anyone?

If I was misunderstood in my previous post; I'm not looking to have simultaneous connections, I just want the mobile network device to be online while I'm doing something with WiFi. And when WiFi cuts off, for example in a train tunnel or something, 3G takes its place.
Hello from me. I done the same job with you! And the Service.jar was created and i pushed to my mobile phone. But still the same default use of the connectivity. You managed to do something?
 

sordna

Senior Member
Dec 12, 2012
1,262
646
113
Does anyone know anything about using 3G and WiFi at the same time? Is it even possible?
It's possible with a rooted phone.

Hello from me. I done the same job with you! And the Service.jar was created and i pushed to my mobile phone. But still the same default use of the connectivity. You managed to do something?
Read here:
http://forum.xda-developers.com/showthread.php?t=2197776

No it is not possible.
Actually it is, I found this thread that describes how to do it on an optimus G phone, and based on that I was able to do in on vanilla android 4.3 as well (my rooted nexus 4).
You need to put a couple of scripts together, since you need a series of shell commands for turning this on and off, I recommend the wonderful SH Script Runner for this.
Here is what I did on my Nexus 4. 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.

Code:
# 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
 

wlh03212

Senior Member
Oct 22, 2009
114
2
0
Hi guys. I am trying to do the same on my Xiaomi m2. Can someone point me to the correct direction. Much much much appreciated.

Sent from my MI 2 using Tapatalk
 

sordna

Senior Member
Dec 12, 2012
1,262
646
113
Hi guys. I am trying to do the same on my Xiaomi m2. Can someone point me to the correct direction. Much much much appreciated.
What's your Android version? Is the phone rooted? Did you try running the above commands I posted, and what was the output?
You could also try the similar commands that worked on another and post the output here.
 

wlh03212

Senior Member
Oct 22, 2009
114
2
0
What's your Android version? Is the phone rooted? Did you try running the above commands I posted, and what was the output?
You could also try the similar commands that worked on another and post the output here.

Hi I'm running on Miui v5 4.1.1

I did try the above commands. But I'm not sure about the ip route you mentioned in the coding x. X. X. X via y. Y. Y. Y.

The response of the script was permission denied. I am definitely rooted and I gave permission to SH script runner.

Sent from my MI 2 using Tapatalk
 

sordna

Senior Member
Dec 12, 2012
1,262
646
113
First try the commands on the terminal (adb shell, or terminal app) and make sure to type "su" first, so that all commands get executed with root permissions. After you get things working without errors on the terminal, you can put these commands in script runner.
The x.x.x stuff needs to be replaced with the subnet/netmask of your home LAN, such as 10.0.0.0/24 or whatever and the default gateway (your wireless router) to reach it via.The route stuff assumes a basic understanding of networking... Actually you can remove the route statements, they are only needed if your home LAN is on a different subnet than your WiFi subnet... most home routers put everything on the same subnet.

What is the end goal you are trying to achieve by connecting to 2 networks?
 
Last edited:
  • Like
Reactions: yosef_a

wlh03212

Senior Member
Oct 22, 2009
114
2
0
First try the commands on the terminal (adb shell, or terminal app) and make sure to type "su" first, so that all commands get executed with root permissions. After you get things working without errors on the terminal, you can put these commands in script runner.
The x.x.x stuff needs to be replaced with the subnet/netmask of your home LAN, such as 10.0.0.0/24 or whatever and the default gateway (your wireless router) to reach it via.The route stuff assumes a basic understanding of networking... Actually you can remove the route statements, they are only needed if your home LAN is on a different subnet than your WiFi subnet... most home routers put everything on the same subnet.

What is the end goal you are trying to achieve by connecting to 2 networks?
Thanks you for your reply. First of all my understanding of networking isn't anywhere basic . What i did with the xxx was replacing it with the internal ip assigned to me, aka 192.x.x.x

For the yyy, I replaced it with the ip of 3g connection. Not sure what I am doing here. Please guide me here (I know the su part which I an required to do in terminal)

And finally my goal. I have Seagate wireless plus and itself is a portable wifi hotspot to its own content. I am able to stream pictures music and video from the battery operated hardisk. I can bridge the connection of the portable hotspot to my home wifi gaining xs to the Internet.

However while I am connected to the Seagate wireless plus, I cannot connect to my 3g. That meaning I can't have Internet on the go which is a very big limitation.



Sent from my MI 2 using Tapatalk


Sent from my MI 2 using Tapatalk
 

sordna

Senior Member
Dec 12, 2012
1,262
646
113
OK. You don't need the "ip route" command, since your WiFi interface will give you access to the Seagate as soon as you connect to it. And the 3G interface, at least in my case, provided default gateway to the internet.

Anyway, try the other commands one by one and see which of them, if any, give you any errors. The netcfg command should show you that 2 interfaces (apart from the lo - 127.0.0.1) are UP and with expected IP addresses if everything goes well.
 

wlh03212

Senior Member
Oct 22, 2009
114
2
0
OK. You don't need the "ip route" command, since your WiFi interface will give you access to the Seagate as soon as you connect to it. And the 3G interface, at least in my case, provided default gateway to the internet.

Anyway, try the other commands one by one and see which of them, if any, give you any errors. The netcfg command should show you that 2 interfaces (apart from the lo - 127.0.0.1) are UP and with expected IP addresses if everything goes well.
# enable dual-networking:
............
............
.............
..........
...........
..............
..........
ip route add x.x.x.x via x.x.x.y # add any desired local route -------->( do i remove this row of code entirely? What do i do with this row of coding? Provide my default gateway? I'm not sure what's my default gateway or how i do find out my default gateway or how should i edit this coding to my default gateway.)


Anyway, try the other commands one by one and see which of them, if any, give you any errors. The netcfg command should show you that 2 interfaces (apart from the lo - 127.0.0.1) are UP and with expected IP addresses if everything goes well (In short if the i execute the above commands correctly with the correct default gateway of my 3G, the netcfg command should show my default gateway correctly? is my understanding correct?)
 

sordna

Senior Member
Dec 12, 2012
1,262
646
113
As I said before, you don't need the ip route command, remove that line entirely!

When all is working, netcfg | grep UP should show you your wlan interface with the IP address given to it by the Seagate, and your mobile data interface with the IP address given to it by your cellular provider.
 

wlh03212

Senior Member
Oct 22, 2009
114
2
0
As I said before, you don't need the ip route command, remove that line entirely!

When all is working, netcfg | grep UP should show you your wlan interface with the IP address given to it by the Seagate, and your mobile data interface with the IP address given to it by your cellular provider.
Thanks you much! Going to try out when I get home.

Sent from my MI 2 using Tapatalk
 

wlh03212

Senior Member
Oct 22, 2009
114
2
0
OK. Please hit the thanks buttons :)
When i run the code line by line in terminal, i get an error message wlan0: interface not found or invalid

Do I run the code when connected to my hardisk hotspot? When exactly do I run the code.
 
Last edited:

sordna

Senior Member
Dec 12, 2012
1,262
646
113
When i run the code line by line in terminal, i get an error message wlan0: interface not found or invalid

Do I run the code when connected to my hardisk hotspot? When exactly do I run the code.
If you try to understand the code you will notice it turns off your Wi-Fi and then turns it on. So actually you don't need to connect to the hotspot first.
Regarding the interface name, here is where you need to do your own investigation and figure the WiFi interface name for your own phone.
The netcfg command without any arguments displays all interfaces, and whenever you are on Wi-Fi, the relevant interface will be UP and will have your assigned IP address next to it.

Look at how much stuff I changed compared to the things posted by the other guy for the optimus phone. Look at his solution and be prepared to investigate and come up with similar amount of changes for your phone. I spent several hours trying different stuff for my Nexus 4, with my only info being the other guy's post. I read about netcfg and everything else googling various websites. You need to do the same and learn a bit about that stuff.

For all I know, the Optimus phone method could be closer to your phone than my method, perhaps. You have to do your own research and figure out the differences, then post them here to help other owners with the same device as yours.
 
  • Like
Reactions: wlh03212

wlh03212

Senior Member
Oct 22, 2009
114
2
0
If you try to understand the code you will notice it turns off your Wi-Fi and then turns it on. So actually you don't need to connect to the hotspot first.
Regarding the interface name, here is where you need to do your own investigation and figure the WiFi interface name for your own phone.
The netcfg command without any arguments displays all interfaces, and whenever you are on Wi-Fi, the relevant interface will be UP and will have your assigned IP address next to it.

Look at how much stuff I changed compared to the things posted by the other guy for the optimus phone. Look at his solution and be prepared to investigate and come up with similar amount of changes for your phone. I spent several hours trying different stuff for my Nexus 4, with my only info being the other guy's post. I read about netcfg and everything else googling various websites. You need to do the same and learn a bit about that stuff.

For all I know, the Optimus phone method could be closer to your phone than my method, perhaps. You have to do your own research and figure out the differences, then post them here to help other owners with the same device as yours.
Yes. I notice that the wifi switched off and then turns on again. Alright I do some research on my own! Thanks again.

Hope that I will get some breakthrough soon

Sent from my MI 2 using Tapatalk
 

wlh03212

Senior Member
Oct 22, 2009
114
2
0
Hi

I finally got it working. When I am connected to seagate wireless, I have to fiddle with the connection settings inside wifi settings. I assigned a static ip and assigned the gateway to 0.0.0.0

As for the ip, I set a different internal ip with the last digit increased by one. Example 172.25.0.2

Now I am connected to both 3G and LAN.


Sent from my iPhone using Tapatalk