okta-sdk-appauth-android
okta-sdk-appauth-android copied to clipboard
Provide mechanism to override usage of DefaultConnectionBuilder.INSTANCE
This is a feature request to allow an arbitrary ConnectionBuilder to be provided. There are a couple spots where this is used.
- DefaultConnectionBuilder.INSTANCE is used as part of the AuthorizationServiceConfiguration.fetchFromUrl call.
- AppAuthConfiguration.Builder() will use it by default, thus used as part of the createAuthorizationService call.
- Anything that uses URI openConnection (instead of ConnectionBuilder openConnection)
Will look into this. Any particular reason why you want to use your own connection? Changing the timeout etc.?
My use case is a bit convoluted, in many scenarios while using my app the "default network" (i.e WiFi) can't reach the Internet, and so I use the Android Network APIs to open connections on the cellular interface when I need to reach the Internet.
I still need to have the user disable WiFi if I detect it up and they actually want to sign in (otherwise the browser is going to have the same issue with the default network, yay Android networking) but at least I'm able to init and do a lot of setup in the background prior to actual login.
Google has changed how android determines what the default network should be on P (it seems), and favor interfaces that can reach the Internet. That helps with the browser bit, but I still need to bind my process' networking to WiFi so in general for connections it uses WiFi, and only in specific cases it uses cellular when I need it to.
Thanks for the insight. That is a use case we haven't thought about. It should be simple to add. But in the mean time have you tried using to specify a mobile network type to bind your app to?
https://developer.android.com/reference/android/net/ConnectivityManager#bindProcessToNetwork(android.net.Network)
So I do use that API to bind the app process to WiFi. Except the WiFi route does not have a gateway to the internet. I'm sort of required to do this because of other various native library dependencies that aren't as easily modified to bind to various network interfaces.
I rely on Network#openConnection / Network#bindSocket to reach the internet over cellular when needed.