Merge "Add isFeatureSupported and isTetheringFeatureForceDisabled methods" into main
diff --git a/staticlibs/device/com/android/net/module/util/DomainUtils.java b/staticlibs/device/com/android/net/module/util/DomainUtils.java
index 80e0b64..b327fd0 100644
--- a/staticlibs/device/com/android/net/module/util/DomainUtils.java
+++ b/staticlibs/device/com/android/net/module/util/DomainUtils.java
@@ -123,7 +123,7 @@
      * @return domain name(s) string array with space separated, or empty string if decode fails.
      */
     @NonNull
-    public static String[] decode(@NonNull final ByteBuffer buffer, boolean compression) {
+    public static ArrayList<String> decode(@NonNull final ByteBuffer buffer, boolean compression) {
         final ArrayList<String> domainList = new ArrayList<>();
         while (buffer.remaining() > 0) {
             try {
@@ -138,6 +138,6 @@
                 break;
             }
         }
-        return domainList.toArray(new String[0]);
+        return domainList;
     }
 }
diff --git a/staticlibs/device/com/android/net/module/util/structs/Ipv6PktInfo.java b/staticlibs/device/com/android/net/module/util/structs/Ipv6PktInfo.java
new file mode 100644
index 0000000..0dccb72
--- /dev/null
+++ b/staticlibs/device/com/android/net/module/util/structs/Ipv6PktInfo.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.net.module.util.structs;
+
+import com.android.net.module.util.Struct;
+import com.android.net.module.util.Struct.Field;
+import com.android.net.module.util.Struct.Type;
+
+import java.net.Inet6Address;
+
+/**
+ * structure in6_pktinfo
+ *
+ * see also:
+ *
+ *     include/uapi/linux/ipv6.h
+ */
+public class Ipv6PktInfo extends Struct {
+    @Field(order = 0, type = Type.Ipv6Address)
+    public final Inet6Address addr; // IPv6 source or destination address
+    @Field(order = 1, type = Type.S32)
+    public final int ifindex;       // interface index
+
+    public Ipv6PktInfo(final Inet6Address addr, final int ifindex) {
+        this.addr = addr;
+        this.ifindex = ifindex;
+    }
+}
diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/DomainUtilsTest.java b/staticlibs/tests/unit/src/com/android/net/module/util/DomainUtilsTest.java
index 606ed5f..5eaf2ad 100644
--- a/staticlibs/tests/unit/src/com/android/net/module/util/DomainUtilsTest.java
+++ b/staticlibs/tests/unit/src/com/android/net/module/util/DomainUtilsTest.java
@@ -30,6 +30,9 @@
 import org.junit.runner.RunWith;
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
 
 @RunWith(AndroidJUnit4.class)
 @SmallTest
@@ -168,39 +171,40 @@
 
     @Test
     public void testDecodeDomainNames() {
+        ArrayList<String> suffixStringList;
         String suffixes = "06676F6F676C6503636F6D00" // google.com
                 + "076578616D706C6503636F6D00"       // example.com
                 + "06676F6F676C6500";                // google
-        String[] expected = new String[] {"google.com", "example.com"};
+        List<String> expected = Arrays.asList("google.com", "example.com");
         ByteBuffer buffer = ByteBuffer.wrap(HexEncoding.decode(suffixes));
-        String[] suffixString = DomainUtils.decode(buffer, false /* compression */);
-        assertArrayEquals(expected, suffixString);
+        suffixStringList = DomainUtils.decode(buffer, false /* compression */);
+        assertEquals(expected, suffixStringList);
 
         // include suffix with invalid length: 64
         suffixes = "06676F6F676C6503636F6D00"        // google.com
                 + "406578616D706C6503636F6D00"       // example.com(length=64)
                 + "06676F6F676C6500";                // google
-        expected = new String[] {"google.com"};
+        expected = Arrays.asList("google.com");
         buffer = ByteBuffer.wrap(HexEncoding.decode(suffixes));
-        suffixString = DomainUtils.decode(buffer, false /* compression */);
-        assertArrayEquals(expected, suffixString);
+        suffixStringList = DomainUtils.decode(buffer, false /* compression */);
+        assertEquals(expected, suffixStringList);
 
         // include suffix with invalid length: 0
         suffixes = "06676F6F676C6503636F6D00"         // google.com
                 + "076578616D706C6503636F6D00"        // example.com
                 + "00676F6F676C6500";                 // google(length=0)
-        expected = new String[] {"google.com", "example.com"};
+        expected = Arrays.asList("google.com", "example.com");
         buffer = ByteBuffer.wrap(HexEncoding.decode(suffixes));
-        suffixString = DomainUtils.decode(buffer, false /* compression */);
-        assertArrayEquals(expected, suffixString);
+        suffixStringList = DomainUtils.decode(buffer, false /* compression */);
+        assertEquals(expected, suffixStringList);
 
         suffixes =
                 "076578616D706C6504636F727006676F6F676C6503636F6D00"  // example.corp.google.com
                 + "C008"                                              // corp.google.com
                 + "C00D";                                             // google.com
-        expected = new String[] {"example.corp.google.com", "corp.google.com", "google.com"};
+        expected = Arrays.asList("example.corp.google.com", "corp.google.com", "google.com");
         buffer = ByteBuffer.wrap(HexEncoding.decode(suffixes));
-        suffixString = DomainUtils.decode(buffer, true /* compression */);
-        assertArrayEquals(expected, suffixString);
+        suffixStringList = DomainUtils.decode(buffer, true /* compression */);
+        assertEquals(expected, suffixStringList);
     }
 }
diff --git a/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/ConnectivityCheckTest.kt b/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/ConnectivityCheckTest.kt
index 6bcb8fc..f1f0975 100644
--- a/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/ConnectivityCheckTest.kt
+++ b/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/ConnectivityCheckTest.kt
@@ -72,7 +72,7 @@
         val cb = TestableNetworkCallback()
         val cm = context.getSystemService(ConnectivityManager::class.java)
                 ?: fail("Could not get ConnectivityManager")
-        cm.registerNetworkCallback(
+        cm.requestNetwork(
                 NetworkRequest.Builder()
                         .addTransportType(TRANSPORT_CELLULAR)
                         .addCapability(NET_CAPABILITY_INTERNET).build(), cb)