Merge "[Thread] tell ot-daemon about the DNS servers on the infra link" into main
diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
index d5d24ac..ba4eeaf 100644
--- a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
+++ b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
@@ -145,11 +145,13 @@
import java.io.IOException;
import java.net.Inet6Address;
+import java.net.InetAddress;
import java.security.SecureRandom;
import java.time.Clock;
import java.time.DateTimeException;
import java.time.Instant;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -1342,6 +1344,7 @@
}
setInfraLinkInterfaceName(newInfraLinkState.interfaceName);
setInfraLinkNat64Prefix(newInfraLinkState.nat64Prefix);
+ setInfraLinkDnsServers(newInfraLinkState.dnsServers);
mInfraLinkState = newInfraLinkState;
}
@@ -1375,6 +1378,16 @@
}
}
+ private void setInfraLinkDnsServers(List<String> newDnsServers) {
+ try {
+ getOtDaemon()
+ .setInfraLinkDnsServers(
+ newDnsServers, new LoggingOtStatusReceiver("setInfraLinkDnsServers"));
+ } catch (RemoteException | ThreadNetworkException e) {
+ LOG.e("Failed to set infra link DNS servers " + newDnsServers, e);
+ }
+ }
+
private void handleThreadInterfaceStateChanged(boolean isUp) {
try {
mTunIfController.setInterfaceUp(isUp);
@@ -1520,7 +1533,17 @@
}
return new InfraLinkState.Builder()
.setInterfaceName(linkProperties.getInterfaceName())
- .setNat64Prefix(nat64Prefix);
+ .setNat64Prefix(nat64Prefix)
+ .setDnsServers(addressesToStrings(linkProperties.getDnsServers()));
+ }
+
+ private static List<String> addressesToStrings(List<InetAddress> addresses) {
+ List<String> strings = new ArrayList<>();
+
+ for (InetAddress address : addresses) {
+ strings.add(address.getHostAddress());
+ }
+ return strings;
}
private static final class CallbackMetadata {