Commit 5248df46 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Do not use Android's configured HTTP proxy by default

parent 153a89ea
......@@ -444,6 +444,12 @@ extern "C" JNIEXPORT void JNICALL Java_org_linphone_core_tools_AndroidPlatformHe
androidPlatformHelper->getCore()->doLater(fun);
}
extern "C" JNIEXPORT jboolean JNICALL Java_org_linphone_core_tools_AndroidPlatformHelper_useSystemHttpProxy(JNIEnv* env, jobject thiz, jlong ptr) {
AndroidPlatformHelpers *androidPlatformHelper = static_cast<AndroidPlatformHelpers *>((void *)ptr);
LpConfig *config = linphone_core_get_config(androidPlatformHelper->getCore()->getCCore());
return !!lp_config_get_int(config, "sip", "use_system_http_proxy", 0);
}
extern "C" JNIEXPORT jboolean JNICALL Java_org_linphone_core_tools_AndroidPlatformHelper_isInBackground(JNIEnv *env, jobject thiz, jlong ptr) {
AndroidPlatformHelpers *androidPlatformHelper = static_cast<AndroidPlatformHelpers *>((void *)ptr);
return androidPlatformHelper->getCore()->isInBackground();
......
......@@ -102,6 +102,7 @@ public class AndroidPlatformHelper {
private native void setHttpProxy(long nativePtr, String host, int port);
private native boolean isInBackground(long nativePtr);
private native void enableKeepAlive(long nativePtr, boolean enable);
private native boolean useSystemHttpProxy(long nativePtr);
public AndroidPlatformHelper(long nativePtr, Object ctx_obj, boolean wifiOnly) {
mNativePtr = nativePtr;
......@@ -502,14 +503,18 @@ public class AndroidPlatformHelper {
setNetworkReachable(mNativePtr, false);
} else {
if (mNetworkManager.hasHttpProxy(mContext, mConnectivityManager)) {
String host = mNetworkManager.getProxyHost(mContext, mConnectivityManager);
int port = mNetworkManager.getProxyPort(mContext, mConnectivityManager);
setHttpProxy(mNativePtr, host, port);
if (!mUsingHttpProxy) {
Log.i("[Platform Helper] Proxy wasn't set before, disabling network reachability first");
setNetworkReachable(mNativePtr, false);
if (useSystemHttpProxy(mNativePtr)) {
String host = mNetworkManager.getProxyHost(mContext, mConnectivityManager);
int port = mNetworkManager.getProxyPort(mContext, mConnectivityManager);
setHttpProxy(mNativePtr, host, port);
if (!mUsingHttpProxy) {
Log.i("[Platform Helper] Proxy wasn't set before, disabling network reachability first");
setNetworkReachable(mNativePtr, false);
}
mUsingHttpProxy = true;
} else {
Log.w("[Platform Helper] Proxy available but forbidden by linphone core [sip] use_system_http_proxy setting");
}
mUsingHttpProxy = true;
} else {
setHttpProxy(mNativePtr, "", 0);
if (mUsingHttpProxy) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment