[Mainline] Core Platform APIs migration am: 869a7270f8 am: 39b53e77c5 am: 5ab66702f3
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1576332
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I22ed022f4130643509a3b5606c753d5ddd85ed68
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");
}