Add set dns server after a network changed
This commit is contained in:
parent
bc3bb94b7b
commit
0d16e8d7b7
4 changed files with 38 additions and 4 deletions
|
@ -27,6 +27,7 @@ import java.io.FileInputStream;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
|
@ -888,8 +889,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
}
|
||||
|
||||
public void updateNetworkReachability() {
|
||||
ConnectivityManager cm = (ConnectivityManager) mServiceContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
|
||||
if (mConnectivityManager == null) return;
|
||||
|
||||
NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
|
||||
|
||||
if (networkInfo == null || !networkInfo.isConnected()) {
|
||||
Log.i("No connectivity: setting network unreachable");
|
||||
|
@ -1612,6 +1614,26 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
dozeModeEnabled = b;
|
||||
}
|
||||
|
||||
public void setDnsServers() {
|
||||
if (mConnectivityManager == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return;
|
||||
|
||||
if (mConnectivityManager.getActiveNetwork() == null
|
||||
|| mConnectivityManager.getLinkProperties(mConnectivityManager.getActiveNetwork()) == null)
|
||||
return;
|
||||
|
||||
int i = 0;
|
||||
List<InetAddress> inetServers = null;
|
||||
inetServers = mConnectivityManager.getLinkProperties(mConnectivityManager.getActiveNetwork()).getDnsServers();
|
||||
|
||||
String[] servers = new String[inetServers.size()];
|
||||
|
||||
for (InetAddress address : inetServers) {
|
||||
servers[i++] = address.getHostAddress();
|
||||
}
|
||||
mLc.setDnsServers(servers);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class LinphoneConfigException extends LinphoneException {
|
||||
|
||||
|
@ -1733,6 +1755,13 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
public void friendListRemoved(LinphoneCore lc, LinphoneFriendList list) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
|
||||
Log.d("Set Dns servers");
|
||||
setDnsServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authInfoRequested(LinphoneCore lc, String realm,
|
||||
String username, String domain) {
|
||||
|
|
|
@ -194,6 +194,11 @@ public class TutorialCardDavSync extends Activity implements OnClickListener, Li
|
|||
myLog(msg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callStatsUpdated(LinphoneCore lc, LinphoneCall call,
|
||||
LinphoneCallStats stats) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit bcb9b2389c2e7f55813c59306bf42f58b3a6b633
|
||||
Subproject commit d95f3f9fc6e1a9bacd50c6b5c5e80e24a44796f6
|
|
@ -1 +1 @@
|
|||
Subproject commit 35d9eeb152c1305e9a79be9530c483148291afc4
|
||||
Subproject commit 583b0ed767f5fee20f1adc30b90847af2a62a73c
|
Loading…
Reference in a new issue