When using Nearby Swap: Warn if user has VPN active
Some VPNs, but not all have an option to allow local LAN traffic. If that option isn't on or it doesn't exist, local LAN connections won't work. So it looks like we need to warn the user about an active VPN. This is how we can find out easily:
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetwork = connectivityManager.activeNetwork ?: return false
val networkCapabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)