mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Fix bug where we constantly cycled network stack when on network with PAC proxy.
This commit is contained in:
committed by
Cody Henthorne
parent
08509f6693
commit
e636a94de0
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.push
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.ProxyInfo
|
||||
import android.net.Uri
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil
|
||||
@@ -143,9 +144,15 @@ class SignalServiceNetworkAccess(context: Context) {
|
||||
private fun getSystemHttpProxy(context: Context): HttpProxy? {
|
||||
val connectivityManager = ContextCompat.getSystemService(context, ConnectivityManager::class.java) ?: return null
|
||||
|
||||
return connectivityManager
|
||||
val proxyInfo = connectivityManager
|
||||
.activeNetwork
|
||||
?.let { connectivityManager.getLinkProperties(it)?.httpProxy }
|
||||
|
||||
return proxyInfo.toApplicableSystemHttpProxy()
|
||||
}
|
||||
|
||||
fun ProxyInfo?.toApplicableSystemHttpProxy(): HttpProxy? {
|
||||
return this
|
||||
?.takeIf { !it.exclusionList.contains(BuildConfig.SIGNAL_URL.stripProtocol()) }
|
||||
// NB: Edit carefully, dear reader, as the line below is written from hard won experience.
|
||||
// It turns out, that despite being documented *nowhere*, if a PAC file is set
|
||||
@@ -156,7 +163,7 @@ class SignalServiceNetworkAccess(context: Context) {
|
||||
// So, if we do not explicitly check that a PAC file is not set, the proxy
|
||||
// we pass to libsignal may be syntactically invalid, and the user may be
|
||||
// rendered unable to connect.
|
||||
?.takeIf { proxyInfo -> proxyInfo.pacFileUrl.equals(Uri.EMPTY) }
|
||||
?.takeIf { it.pacFileUrl == Uri.EMPTY }
|
||||
?.let { proxy -> HttpProxy(proxy.host, proxy.port) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user