Commit 504d0131 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Have DNS information before linphone_core_start() on Android 8+

parent bbf60caa
......@@ -111,6 +111,9 @@ public class AndroidPlatformHelper {
mResources = mContext.getResources();
mMainHandler = new Handler(mContext.getMainLooper());
mIsInInteractiveMode = true;
mDozeModeEnabled = false;
MediastreamerAndroidContext.setContext(mContext);
Log.i("[Platform Helper] Created");
......@@ -151,7 +154,12 @@ public class AndroidPlatformHelper {
Log.w("[Platform Helper] Device is in bucket " + DeviceUtils.getAppStandbyBucketNameFromValue(bucket));
}
mIsInInteractiveMode = true;
// Update DNS servers lists
NetworkManagerInterface nm = createNetworkManager();
Network network = nm.getActiveNetwork(mConnectivityManager);
if (network != null) {
storeDnsServers(network);
}
}
public synchronized void onLinphoneCoreStart(boolean monitoringEnabled) {
......@@ -543,21 +551,26 @@ public class AndroidPlatformHelper {
enableKeepAlive(mNativePtr, mIsInInteractiveMode);
}
private synchronized void startNetworkMonitoring() {
if (!mMonitoringEnabled) return;
mNetworkManager = new NetworkManager(this);
private NetworkManagerInterface createNetworkManager() {
NetworkManagerInterface networkManager = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
mNetworkManager = new NetworkManager(this);
networkManager = new NetworkManager(this);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
mNetworkManager = new NetworkManagerAbove21(this);
networkManager = new NetworkManagerAbove21(this);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
mNetworkManager = new NetworkManagerAbove23(this);
networkManager = new NetworkManagerAbove23(this);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
mNetworkManager = new NetworkManagerAbove24(this);
networkManager = new NetworkManagerAbove24(this);
} else {
mNetworkManager = new NetworkManagerAbove26(this);
networkManager = new NetworkManagerAbove26(this);
}
return networkManager;
}
private synchronized void startNetworkMonitoring() {
if (!mMonitoringEnabled) return;
mNetworkManager = createNetworkManager();
Log.i("[Platform Helper] Registering network callbacks");
mNetworkManager.registerNetworkCallbacks(mContext, mConnectivityManager);
......
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