fix: Ignore global proxy settings if system thinks there's none (#4744)
Otherwise a :0 proxy would break in Rust SDK.
This commit is contained in:
parent
dbe75cd4ea
commit
b39100ef6f
1 changed files with 9 additions and 0 deletions
|
|
@ -8,7 +8,9 @@
|
||||||
package io.element.android.libraries.matrix.impl.proxy
|
package io.element.android.libraries.matrix.impl.proxy
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
import io.element.android.libraries.di.ApplicationContext
|
||||||
|
|
@ -32,6 +34,13 @@ class DefaultProxyProvider @Inject constructor(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) : ProxyProvider {
|
) : ProxyProvider {
|
||||||
override fun provides(): String? {
|
override fun provides(): String? {
|
||||||
|
val defaultProxy = context.getSystemService<ConnectivityManager>()?.defaultProxy
|
||||||
|
if (defaultProxy == null) {
|
||||||
|
// Note: can be tested by running:
|
||||||
|
// adb shell settings put global http_proxy :0
|
||||||
|
Timber.d("No default proxy")
|
||||||
|
return null
|
||||||
|
}
|
||||||
return Settings.Global.getString(context.contentResolver, Settings.Global.HTTP_PROXY)
|
return Settings.Global.getString(context.contentResolver, Settings.Global.HTTP_PROXY)
|
||||||
?.also {
|
?.also {
|
||||||
Timber.d("Using global proxy")
|
Timber.d("Using global proxy")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue