[Mainline] Core Platform APIs migration
* java/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;
* libcore/io/IoUtils;->closeQuietly(Ljava/io/FileDescriptor;)V
* libcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V
* libcore/io/IoUtils;->setBlocking(Ljava/io/FileDescriptor;Z)V
* java/net/Inet4Address;->ANY:Ljava/net/InetAddress;
* java/net/Inet6Address;->ANY:Ljava/net/InetAddress;
Bug: 177260833
Test: mma
Change-Id: I1357dba41beb27df17a7631317c4b05f98854f27
diff --git a/staticlibs/framework/com/android/net/module/util/NetworkStackConstants.java b/staticlibs/framework/com/android/net/module/util/NetworkStackConstants.java
index a227505..b656ed2 100644
--- a/staticlibs/framework/com/android/net/module/util/NetworkStackConstants.java
+++ b/staticlibs/framework/com/android/net/module/util/NetworkStackConstants.java
@@ -17,6 +17,7 @@
package com.android.net.module.util;
import java.net.Inet4Address;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -98,7 +99,11 @@
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff);
public static final Inet4Address IPV4_ADDR_ANY = makeInet4Address(
(byte) 0, (byte) 0, (byte) 0, (byte) 0);
-
+ public static final Inet6Address IPV6_ADDR_ANY = makeInet6Address(new byte[]{
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0 });
/**
* IPv6 constants.
*
@@ -182,6 +187,16 @@
}
}
+ /**
+ * Make an Inet6Address from 16 bytes in network byte order.
+ */
+ private static Inet6Address makeInet6Address(byte[] bytes) {
+ try {
+ return (Inet6Address) InetAddress.getByAddress(bytes);
+ } catch (UnknownHostException e) {
+ throw new IllegalArgumentException("addr must be 16 bytes: this should never happen");
+ }
+ }
private NetworkStackConstants() {
throw new UnsupportedOperationException("This class is not to be instantiated");
}