Doesn´t network bindings apply to jni-code?

Viewed 91

I know that my users are connected to a wifi without Internet, so I bind the Android process to cellular:

 private fun bindProcessToCellular() {
        val req = NetworkRequest.Builder()
        req.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
        req.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)

        cm.requestNetwork(req.build(), object : ConnectivityManager.NetworkCallback() {
            override fun onAvailable(network: Network) {
                if (cm.bindProcessToNetwork(network)){
                    // YAY, process bound to cellular                    
                }
            }
        })
    }

Now, this works perfectly from Kotlin/Android - Internet requests are running as expected through cellular for Android/Kotlin code, -but not from my gomobile library. From within Go, requests simply times out. If I disconnect wifi, all Go-requests are successful, making me think that Go somehow resolves the wrong network.

My understanding is that gomobile runs on the Andoroid JNI interfaces, and my intuition is that the bindProcessToNetwork binds everything, including components running towards the JNI interfaces of that app.

Anyone got some ideas what might be going on here?

1 Answers

Possible workaround:

When user connects to this wifi (without internet) the first time, the os asks the user "This wifi doesn´t have internet, do you still want to connect?" If the user then cancels, the device is actually still connected to that wifi, but traffic is still routed through cellular, including requests created in Go..

Related