Connecting Android to multiple network interfaces (WiFi/4G and bluetooth PAN) - android

I am writing an app which I want to connect to a closed (no internet access) bluetooth PAN to access a local data server. When connecting to the PAN I want the user to still have internet access via their existing 4G/WiFi data connection.
I have set up DNSMasq on the PAN gateway and have configured the dns options to not provide a gateway/DNS server for the interface.
Using reflection I can connect a phone to the PAN but the phone then drops any other network connections.
With the new Android api's (NetworkBuilder & ConnectivityManager.requestNetwork) I can request a WiFi connection before connecting to the PAN and the phone will keep both connections up. The problem is that other apps on the phone still do not have internet access. It would appear that the device is adding a default route for the bt-pan interface, even though dhcp has not provided a router option (confirmed via Wireshark).
Is it possible to connect to a network without setting a default gateway so other apps will continue to use 4G/WiFi interface?

Related

Android app access local WiFi device with no Internet while phone mobile data is on

I’m working on an Android application that communicates with a Socket to a hardware device that serves a WiFi access point. This WiFi access point does not provide access to the Internet. I’m unable to connect to the socket while Mobile Data on the phone is turned on.
How can I communicate with this device without requiring the user to turn off mobile data? I don’t need to communicate with the Internet over the mobile data connection at the same time as I am communicating with the device over WiFi, but I would like to be able to switch back and forth.
I’ve tried binding the socket to the IP address associated with the network interface connected to the WiFi access point, but that didn’t work.

Using a local Wifi that has no gateway/internet connection while using mobile data for internet access in an android app (Flutter)

I am trying to connect a hardware (ifm ecomat) in a local wifi network that has no internet gateway/access.
Nevertheless, I need internet connection for the rest of the app using mobile data.
On the Android 9 Samsung Active Tab Pro I am not able to leave the gateway field empty (static ip configuration). If I try to remove it it automatically enters the first IP of the subnet as gateway.
Therefore, when I try to connect to the internet with mobile data and wifi. It tries to communicate over the wifi network with the gateway that is not existent.
If I switch "allways prefere mobile data for this app" on, I'm not able to communicate with my local network anymore.
Any idea how to get rid of the gateay or implement a routing table in the flutter app?

Ignore Captive Portal and use WIFI as is

We have a service that displays a user captive portal when a users IP address changes on their WIFI. We are building an app which automates the login. The issue is while android is in a state of 'Wifi requires signin' any network activity is done through the cell connection and the wifi is not accessible.
So when we ping a script on our server to determine the users new IP address it returns the cell network IP. How can we utilize the WIFI connection that is available and still have it make a request? I see the option when trying to sign in manually to 'use the network as is', but need to do this programmatically.
OK so the solution we found was the following which enables us to use the WIFI to ping a script of ours.
To direct all the network requests from your app to an external Wi-Fi device, call ConnectivityManager#setProcessDefaultNetwork on Lollipop devices, and on Marshmallow call ConnectivityManager#bindProcessToNetwork instead, which is a direct API replacement.
as seen here

Properly route non internet Wifi sockets & Cellular Internet request (Android L & M)

Is it possible to dedicate a WiFi network (to a device with no internet access) to a socket in an app and keep Cellular network as the default internet connection for the Android device (and other network requests from the app)? (Android 5 & 6)
I can easily switch between WiFi and Cellular within the app but the main issue is when WiFi is up, Internet is not accessible anymore for the app and all apps already running on the device (i.e. streaming music, web browser, ...)
I have tried to bind the Wifi network to the process or a socket but I can't find any way to do that with getting the network active (and at this point Android just try to route all the internet traffic to the device...).
My understanding is that Android 5 & 6 provides more flexibility to route traffic to multiple networks at the same time but I think I'm missing something here...
As per the Connecting your App to a Wi-Fi Device blog post:
Alternatively, if you’d like to route some of your app traffic to the Wi-Fi device and some to the Internet over the mobile network:
For HTTP requests you can use Network#openConnection(java.net.URL), directly routing your request to this network.
For low-level socket communication, open a socket and call Network#bindSocket(java.net.Socket), or alternatively use Network#getSocketFactory.

Multipath TCP on Android / IPhone

I have a device that creates a WiFi network that is not connected to the internet. This device hosts a website using IIS. To operate the device, a smartphone connects to the WiFi and browses the site. The smartphone needs to get data from an api (internet) and pass it to the website on the device.
I have tried to remove the default gateway setting from the DHCP server on the local WiFi, but this is not permitted on the device.
I have not been able to find an app that will allow both WiFi and Cellular data to be used simultaneously.
If I were to allow the device to connect to a hot spot that the smartphone creates, the smart phone cannot access the device's WAP.
The next option I'm considering is to toggle the WiFi Off and On during the process.
I'm wondering if anyone has another solution to this issue?

Categories

Resources