Added support for multiple DNS servers.
Also increased delay on repeat checks for WWSM.
Change-Id: Ic11b1f37a910c483f48e04dadb539b39fe50e622
diff --git a/core/java/android/net/DnsPinger.java b/core/java/android/net/DnsPinger.java
index 6115fef..3e27b0d 100644
--- a/core/java/android/net/DnsPinger.java
+++ b/core/java/android/net/DnsPinger.java
@@ -67,7 +67,7 @@
private final Context mContext;
private final int mConnectionType;
private final Handler mTarget;
- private final InetAddress mDefaultDns;
+ private final ArrayList<InetAddress> mDefaultDns;
private String TAG;
private static final int BASE = Protocol.BASE_DNS_PINGER;
@@ -113,7 +113,8 @@
throw new IllegalArgumentException("Invalid connectionType in constructor: "
+ connectionType);
}
- mDefaultDns = getDefaultDns();
+ mDefaultDns = new ArrayList<InetAddress>();
+ mDefaultDns.add(getDefaultDns());
mEventCounter = 0;
}
@@ -213,17 +214,16 @@
for (ActivePing activePing : mActivePings)
activePing.socket.close();
mActivePings.clear();
- removeMessages(ACTION_PING_DNS);
break;
}
}
/**
- * @return The first DNS in the link properties of the specified connection
- * type or the default system DNS if the link properties has null
- * dns set. Should not be null.
+ * Returns a list of DNS addresses, coming from either the link properties of the
+ * specified connection or the default system DNS if the link properties has no dnses.
+ * @return a non-empty non-null list
*/
- public InetAddress getDns() {
+ public List<InetAddress> getDnsList() {
LinkProperties curLinkProps = getCurrentLinkProperties();
if (curLinkProps == null) {
Slog.e(TAG, "getCurLinkProperties:: LP for type" + mConnectionType + " is null!");
@@ -236,7 +236,7 @@
return mDefaultDns;
}
- return dnses.iterator().next();
+ return new ArrayList<InetAddress>(dnses);
}
/**