From 914ea9c398853b0b3da7df68bd55274ea5f74db0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 22 Mar 2021 18:03:25 +0100 Subject: [PATCH] use http proxy below android 7.1 --- .../conversations/http/HttpConnectionManager.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java b/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java index 8186040c9..5d7f7f6c8 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java @@ -1,5 +1,6 @@ package eu.siacs.conversations.http; +import android.os.Build; import android.util.Log; import org.apache.http.conn.ssl.StrictHostnameVerifier; @@ -45,10 +46,16 @@ public class HttpConnectionManager extends AbstractConnectionManager { } public static Proxy getProxy() { + final InetAddress localhost; try { - return new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), 9050)); + localhost = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); } catch (final UnknownHostException e) { - throw new IllegalStateException(e); + throw new IllegalStateException(e); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(localhost, 9050)); + } else { + return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(localhost, 8118)); } }