Snap for 11426876 from 076c7dc169c806a64d285c288fe46d1551d86dec to mainline-permission-release

Change-Id: Ida2d26b49c0817bf6e73f2fe862ed745d1516028
diff --git a/Android.bp b/Android.bp
index 37954c9..9af9da4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -126,9 +126,6 @@
     srcs: ["apishim/common/**/*.java"],
     sdk_version: "system_current",
     visibility: ["//visibility:private"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Each level of the shims (29, 30, ...) is its own java_library compiled against the corresponding
@@ -142,9 +139,6 @@
     ],
     sdk_version: "system_29",
     visibility: ["//visibility:private"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 java_library {
@@ -161,7 +155,7 @@
     visibility: ["//visibility:private"],
     lint: {
         strict_updatability_linting: true,
-        baseline_filename: "lint-baseline.xml",
+
     },
 }
 
@@ -185,9 +179,6 @@
     ],
     sdk_version: "module_31",
     visibility: ["//visibility:private"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 java_library {
@@ -208,9 +199,6 @@
     ],
     sdk_version: "module_33",
     visibility: ["//visibility:private"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 java_library {
@@ -232,9 +220,6 @@
     ],
     sdk_version: module_34_version,
     visibility: ["//visibility:private"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Shims for APIs being added to the current development version of Android. These APIs are not
@@ -268,9 +253,6 @@
     ],
     sdk_version: "module_current",
     visibility: ["//visibility:private"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // API current uses the API current shims directly.
@@ -298,9 +280,6 @@
         "//packages/modules/Connectivity/service-t",
         "//packages/modules/Connectivity/tests:__subpackages__",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // API stable uses jarjar to rename the latest stable apishim package from
@@ -327,9 +306,6 @@
         "//packages/modules/Connectivity/service-t",
         "//packages/modules/Connectivity/tests:__subpackages__",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Common defaults for android libraries containing network stack code, used to compile variants of
@@ -381,10 +357,6 @@
         "//packages/modules/NetworkStack/tests/unit",
         "//packages/modules/NetworkStack/tests/integration",
     ],
-    lint: {
-        strict_updatability_linting: true,
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 android_library {
@@ -409,10 +381,6 @@
         "//packages/modules/NetworkStack/tests/unit",
         "//packages/modules/NetworkStack/tests/integration",
     ],
-    lint: {
-        strict_updatability_linting: true,
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 java_library {
@@ -438,9 +406,6 @@
         "//packages/modules/Connectivity/Tethering/tests/integration",
         "//packages/modules/Connectivity/tests/cts/net",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 java_genrule {
@@ -509,9 +474,6 @@
     required: [
         "PlatformCaptivePortalLogin",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
@@ -524,9 +486,6 @@
     ],
     static_libs: ["NetworkStackApiCurrentLib"],
     manifest: "AndroidManifest.xml",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // NetworkStack build targeting the current API release, for testing on in-development SDK
@@ -544,10 +503,6 @@
         "privapp_whitelist_com.android.networkstack",
     ],
     updatable: true,
-    lint: {
-        strict_updatability_linting: true,
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Updatable network stack for finalized API
@@ -564,10 +519,6 @@
         "privapp_whitelist_com.android.networkstack",
     ],
     updatable: true,
-    lint: {
-        strict_updatability_linting: true,
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 cc_library_shared {
@@ -650,9 +601,6 @@
     required: [
         "privapp_whitelist_com.android.networkstack",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // When adding or modifying protos, the jarjar rules and possibly proguard rules need
@@ -669,7 +617,4 @@
         "networkstackprotos",
     ],
     defaults: ["NetworkStackReleaseApiLevel"],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
diff --git a/common/networkstackclient/Android.bp b/common/networkstackclient/Android.bp
index 4dada8d..c566715 100644
--- a/common/networkstackclient/Android.bp
+++ b/common/networkstackclient/Android.bp
@@ -232,9 +232,6 @@
         "com.android.tethering",
         "com.android.wifi",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 java_library {
@@ -279,7 +276,4 @@
         "com.android.tethering",
         "com.android.wifi",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
diff --git a/common/networkstackclient/lint-baseline.xml b/common/networkstackclient/lint-baseline.xml
deleted file mode 100644
index 046b948..0000000
--- a/common/networkstackclient/lint-baseline.xml
+++ /dev/null
@@ -1,169 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.0.0-dev" type="baseline" dependencies="true" variant="all" version="8.0.0-dev">
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getDstAddress`"
-        errorLine1="        final InetAddress dstAddress = pkt.getDstAddress();"
-        errorLine2="                                           ~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="54"
-            column="44"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getDstAddress`"
-        errorLine1="        final InetAddress dstAddress = pkt.getDstAddress();"
-        errorLine2="                                           ~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="70"
-            column="44"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getDstAddress`"
-        errorLine1="        p.dstAddress = data.getDstAddress().getAddress();"
-        errorLine2="                            ~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="136"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getDstPort`"
-        errorLine1="        p.dstPort = data.getDstPort();"
-        errorLine2="                         ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="137"
-            column="26"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getDstPort`"
-        errorLine1="        parcel.dstPort = pkt.getDstPort();"
-        errorLine2="                             ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="58"
-            column="30"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getDstPort`"
-        errorLine1="        parcel.dstPort = pkt.getDstPort();"
-        errorLine2="                             ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="74"
-            column="30"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getPacket`"
-        errorLine1="        final ByteBuffer buffer = ByteBuffer.wrap(data.getPacket());"
-        errorLine2="                                                       ~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="110"
-            column="56"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getSrcAddress`"
-        errorLine1="        final InetAddress srcAddress = pkt.getSrcAddress();"
-        errorLine2="                                           ~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="53"
-            column="44"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getSrcAddress`"
-        errorLine1="        final InetAddress srcAddress = pkt.getSrcAddress();"
-        errorLine2="                                           ~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="69"
-            column="44"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getSrcAddress`"
-        errorLine1="        p.srcAddress = data.getSrcAddress().getAddress();"
-        errorLine2="                            ~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="134"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getSrcPort`"
-        errorLine1="        p.srcPort = data.getSrcPort();"
-        errorLine2="                         ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="135"
-            column="26"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getSrcPort`"
-        errorLine1="        parcel.srcPort = pkt.getSrcPort();"
-        errorLine2="                             ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="56"
-            column="30"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.KeepalivePacketData#getSrcPort`"
-        errorLine1="        parcel.srcPort = pkt.getSrcPort();"
-        errorLine2="                             ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/util/KeepalivePacketDataUtil.java"
-            line="72"
-            column="30"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.NetworkStack#getService`"
-        errorLine1="            while ((nss = NetworkStack.getService()) == null) {"
-        errorLine2="                                       ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/networkstack/ModuleNetworkStackClient.java"
-            line="87"
-            column="40"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.NetworkStack#getService`"
-        errorLine1="        final IBinder nss = NetworkStack.getService();"
-        errorLine2="                                         ~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/common/networkstackclient/src/android/net/networkstack/ModuleNetworkStackClient.java"
-            line="68"
-            column="42"/>
-    </issue>
-
-</issues>
\ No newline at end of file
diff --git a/lint-baseline.xml b/lint-baseline.xml
deleted file mode 100644
index 1517328..0000000
--- a/lint-baseline.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.0.0-dev" type="baseline" dependencies="true" variant="all" version="8.0.0-dev">
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.CaptivePortalData#getUserPortalUrl`"
-        errorLine1="                                mLinkProperties.getCaptivePortalData().getUserPortalUrl()"
-        errorLine2="                                                                       ~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java"
-            line="1734"
-            column="72"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.CaptivePortalData#getUserPortalUrl`"
-        errorLine1="                        mLinkProperties.getCaptivePortalData().getUserPortalUrl()"
-        errorLine2="                                                               ~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java"
-            line="1370"
-            column="64"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getCaptivePortalData`"
-        errorLine1="                                mLinkProperties.getCaptivePortalData().getUserPortalUrl()"
-        errorLine2="                                                ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java"
-            line="1734"
-            column="49"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getCaptivePortalData`"
-        errorLine1="                        mLinkProperties.getCaptivePortalData().getUserPortalUrl()"
-        errorLine2="                                        ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/modules/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java"
-            line="1370"
-            column="41"/>
-    </issue>
-
-</issues>
\ No newline at end of file
diff --git a/src/android/net/apf/ApfFilter.java b/src/android/net/apf/ApfFilter.java
index 5fe19fd..ccb2b55 100644
--- a/src/android/net/apf/ApfFilter.java
+++ b/src/android/net/apf/ApfFilter.java
@@ -598,10 +598,6 @@
             if (type == Type.MATCH && (lifetime != 0 || min != 0)) {
                 throw new IllegalArgumentException("lifetime, min must be 0 for MATCH sections");
             }
-            // Clamp the lifetime to INT_MAX to prevent it from ever going negative.
-            if (lifetime > Integer.MAX_VALUE) {
-                lifetime = Integer.MAX_VALUE;
-            }
             this.lifetime = lifetime;
 
             // It has already been asserted that min is 0 for MATCH sections.
diff --git a/src/android/net/apf/ApfV4Generator.java b/src/android/net/apf/ApfV4Generator.java
index 54a95a1..90bcd4c 100644
--- a/src/android/net/apf/ApfV4Generator.java
+++ b/src/android/net/apf/ApfV4Generator.java
@@ -313,7 +313,8 @@
         // When mOpcode == Opcodes.LABEL:
         private String mLabel;
         private byte[] mBytesImm;
-        // Offset in bytes from the beginning of this program. Set by {@link ApfGenerator#generate}.
+        // Offset in bytes from the beginning of this program.
+        // Set by {@link ApfV4Generator#generate}.
         int offset;
 
         Instruction(Opcodes opcode, Rbit rbit) {
@@ -661,7 +662,7 @@
     private boolean mGenerated;
 
     /**
-     * Creates an ApfGenerator instance which is able to emit instructions for the specified
+     * Creates an ApfV4Generator instance which is able to emit instructions for the specified
      * {@code version} of the APF interpreter. Throws {@code IllegalInstructionException} if
      * the requested version is unsupported.
      */
@@ -672,7 +673,7 @@
     }
 
     /**
-     * Returns true if the ApfGenerator supports the specified {@code version}, otherwise false.
+     * Returns true if the ApfV4Generator supports the specified {@code version}, otherwise false.
      */
     public static boolean supportsVersion(int version) {
         return version >= MIN_APF_VERSION;
diff --git a/src/android/net/apf/ApfV6Generator.java b/src/android/net/apf/ApfV6Generator.java
index 5ca41f7..f123d36 100644
--- a/src/android/net/apf/ApfV6Generator.java
+++ b/src/android/net/apf/ApfV6Generator.java
@@ -43,7 +43,7 @@
      * Add an instruction to the end of the program to increment the counter value and
      * immediately return PASS.
      */
-    public ApfV4Generator addCountAndPass(int cnt) {
+    public ApfV6Generator addCountAndPass(int cnt) {
         checkRange("CounterNumber", cnt /* value */, 1 /* lowerBound */,
                 1000 /* upperBound */);
         // PASS requires using Rbit0 because it shares opcode with DROP
@@ -53,7 +53,7 @@
     /**
      * Add an instruction to the end of the program to let the program immediately return DROP.
      */
-    public ApfV4Generator addDrop() {
+    public ApfV6Generator addDrop() {
         // DROP requires using Rbit1 because it shares opcode with PASS
         return append(new Instruction(Opcodes.PASSDROP, Rbit1));
     }
@@ -62,7 +62,7 @@
      * Add an instruction to the end of the program to increment the counter value and
      * immediately return DROP.
      */
-    public ApfV4Generator addCountAndDrop(int cnt) {
+    public ApfV6Generator addCountAndDrop(int cnt) {
         checkRange("CounterNumber", cnt /* value */, 1 /* lowerBound */,
                 1000 /* upperBound */);
         // DROP requires using Rbit1 because it shares opcode with PASS
@@ -73,7 +73,7 @@
      * Add an instruction to the end of the program to call the apf_allocate_buffer() function.
      * Buffer length to be allocated is stored in register 0.
      */
-    public ApfV4Generator addAllocateR0() {
+    public ApfV6Generator addAllocateR0() {
         return append(new Instruction(ExtendedOpcodes.ALLOCATE));
     }
 
@@ -82,7 +82,7 @@
      *
      * @param size the buffer length to be allocated.
      */
-    public ApfV4Generator addAllocate(int size) {
+    public ApfV6Generator addAllocate(int size) {
         // Rbit1 means the extra be16 immediate is present
         return append(new Instruction(ExtendedOpcodes.ALLOCATE, Rbit1).addU16(size));
     }
@@ -91,7 +91,7 @@
      * Add an instruction to the beginning of the program to reserve the data region.
      * @param data the actual data byte
      */
-    public ApfV4Generator addData(byte[] data) throws IllegalInstructionException {
+    public ApfV6Generator addData(byte[] data) throws IllegalInstructionException {
         if (!mInstructions.isEmpty()) {
             throw new IllegalInstructionException("data instruction has to come first");
         }
@@ -102,7 +102,7 @@
     /**
      * Add an instruction to the end of the program to transmit the allocated buffer.
      */
-    public ApfV4Generator addTransmit() {
+    public ApfV6Generator addTransmit() {
         // TRANSMIT requires using Rbit0 because it shares opcode with DISCARD
         return append(new Instruction(ExtendedOpcodes.TRANSMITDISCARD, Rbit0));
     }
@@ -110,7 +110,7 @@
     /**
      * Add an instruction to the end of the program to discard the allocated buffer.
      */
-    public ApfV4Generator addDiscard() {
+    public ApfV6Generator addDiscard() {
         // DISCARD requires using Rbit1 because it shares opcode with TRANSMIT
         return append(new Instruction(ExtendedOpcodes.TRANSMITDISCARD, Rbit1));
     }
@@ -118,21 +118,21 @@
     /**
      * Add an instruction to the end of the program to write 1 byte value to output buffer.
      */
-    public ApfV4Generator addWriteU8(int val) {
+    public ApfV6Generator addWriteU8(int val) {
         return append(new Instruction(Opcodes.WRITE).overrideLenField(1).addU8(val));
     }
 
     /**
      * Add an instruction to the end of the program to write 2 bytes value to output buffer.
      */
-    public ApfV4Generator addWriteU16(int val) {
+    public ApfV6Generator addWriteU16(int val) {
         return append(new Instruction(Opcodes.WRITE).overrideLenField(2).addU16(val));
     }
 
     /**
      * Add an instruction to the end of the program to write 4 bytes value to output buffer.
      */
-    public ApfV4Generator addWriteU32(long val) {
+    public ApfV6Generator addWriteU32(long val) {
         return append(new Instruction(Opcodes.WRITE).overrideLenField(4).addU32(val));
     }
 
@@ -140,7 +140,7 @@
      * Add an instruction to the end of the program to write 1 byte value from register to output
      * buffer.
      */
-    public ApfV4Generator addWriteU8(Register reg) {
+    public ApfV6Generator addWriteU8(Register reg) {
         return append(new Instruction(ExtendedOpcodes.EWRITE1, reg));
     }
 
@@ -148,7 +148,7 @@
      * Add an instruction to the end of the program to write 2 byte value from register to output
      * buffer.
      */
-    public ApfV4Generator addWriteU16(Register reg) {
+    public ApfV6Generator addWriteU16(Register reg) {
         return append(new Instruction(ExtendedOpcodes.EWRITE2, reg));
     }
 
@@ -156,7 +156,7 @@
      * Add an instruction to the end of the program to write 4 byte value from register to output
      * buffer.
      */
-    public ApfV4Generator addWriteU32(Register reg) {
+    public ApfV6Generator addWriteU32(Register reg) {
         return append(new Instruction(ExtendedOpcodes.EWRITE4, reg));
     }
 
@@ -167,9 +167,9 @@
      * @param src the offset inside the APF program/data region for where to start copy.
      * @param len the length of bytes needed to be copied, only <= 255 bytes can be copied at
      *               one time.
-     * @return the ApfGenerator object
+     * @return the ApfV6Generator object
      */
-    public ApfV4Generator addDataCopy(int src, int len) {
+    public ApfV6Generator addDataCopy(int src, int len) {
         return append(new Instruction(Opcodes.PKTDATACOPY, Rbit1).addDataOffset(src).addU8(len));
     }
 
@@ -180,9 +180,9 @@
      * @param src the offset inside the input packet for where to start copy.
      * @param len the length of bytes needed to be copied, only <= 255 bytes can be copied at
      *               one time.
-     * @return the ApfGenerator object
+     * @return the ApfV6Generator object
      */
-    public ApfV4Generator addPacketCopy(int src, int len) {
+    public ApfV6Generator addPacketCopy(int src, int len) {
         return append(new Instruction(Opcodes.PKTDATACOPY, Rbit0).addPacketOffset(src).addU8(len));
     }
 
@@ -192,9 +192,9 @@
      * Source offset is stored in R0.
      *
      * @param len the number of bytes to be copied, only <= 255 bytes can be copied at once.
-     * @return the ApfGenerator object
+     * @return the ApfV6Generator object
      */
-    public ApfV4Generator addDataCopyFromR0(int len) {
+    public ApfV6Generator addDataCopyFromR0(int len) {
         return append(new Instruction(ExtendedOpcodes.EPKTDATACOPYIMM, Rbit1).addU8(len));
     }
 
@@ -204,9 +204,9 @@
      * Source offset is stored in R0.
      *
      * @param len the number of bytes to be copied, only <= 255 bytes can be copied at once.
-     * @return the ApfGenerator object
+     * @return the ApfV6Generator object
      */
-    public ApfV4Generator addPacketCopyFromR0(int len) {
+    public ApfV6Generator addPacketCopyFromR0(int len) {
         return append(new Instruction(ExtendedOpcodes.EPKTDATACOPYIMM, Rbit0).addU8(len));
     }
 
@@ -216,9 +216,9 @@
      * Source offset is stored in R0.
      * Copy length is stored in R1.
      *
-     * @return the ApfGenerator object
+     * @return the ApfV6Generator object
      */
-    public ApfV4Generator addDataCopyFromR0LenR1() {
+    public ApfV6Generator addDataCopyFromR0LenR1() {
         return append(new Instruction(ExtendedOpcodes.EPKTDATACOPYR1, Rbit1));
     }
 
@@ -228,9 +228,9 @@
      * Source offset is stored in R0.
      * Copy length is stored in R1.
      *
-     * @return the ApfGenerator object
+     * @return the ApfV6Generator object
      */
-    public ApfV4Generator addPacketCopyFromR0LenR1() {
+    public ApfV6Generator addPacketCopyFromR0LenR1() {
         return append(new Instruction(ExtendedOpcodes.EPKTDATACOPYR1, Rbit0));
     }
 
@@ -240,7 +240,7 @@
      * equals {@code qtype}. Examines the payload starting at the offset in R0.
      * R = 0 means check for "does not contain".
      */
-    public ApfV4Generator addJumpIfPktAtR0DoesNotContainDnsQ(@NonNull byte[] qnames, int qtype,
+    public ApfV6Generator addJumpIfPktAtR0DoesNotContainDnsQ(@NonNull byte[] qnames, int qtype,
                                                              @NonNull String tgt) {
         validateNames(qnames);
         return append(new Instruction(ExtendedOpcodes.JDNSQMATCH, Rbit0).setTargetLabel(tgt).addU8(
@@ -253,7 +253,7 @@
      * equals {@code qtype}. Examines the payload starting at the offset in R0.
      * R = 1 means check for "contain".
      */
-    public ApfV4Generator addJumpIfPktAtR0ContainDnsQ(@NonNull byte[] qnames, int qtype,
+    public ApfV6Generator addJumpIfPktAtR0ContainDnsQ(@NonNull byte[] qnames, int qtype,
                                                       @NonNull String tgt) {
         validateNames(qnames);
         return append(new Instruction(ExtendedOpcodes.JDNSQMATCH, Rbit1).setTargetLabel(tgt).addU8(
@@ -266,7 +266,7 @@
      * specified in {@code Names}. Examines the payload starting at the offset in R0.
      * R = 0 means check for "does not contain".
      */
-    public ApfV4Generator addJumpIfPktAtR0DoesNotContainDnsA(@NonNull byte[] names,
+    public ApfV6Generator addJumpIfPktAtR0DoesNotContainDnsA(@NonNull byte[] names,
                                                              @NonNull String tgt) {
         validateNames(names);
         return append(new Instruction(ExtendedOpcodes.JDNSAMATCH, Rbit0).setTargetLabel(tgt)
@@ -279,7 +279,7 @@
      * specified in {@code Names}. Examines the payload starting at the offset in R0.
      * R = 1 means check for "contain".
      */
-    public ApfV4Generator addJumpIfPktAtR0ContainDnsA(@NonNull byte[] names,
+    public ApfV6Generator addJumpIfPktAtR0ContainDnsA(@NonNull byte[] names,
                                                       @NonNull String tgt) {
         validateNames(names);
         return append(new Instruction(ExtendedOpcodes.JDNSAMATCH, Rbit1).setTargetLabel(
@@ -324,4 +324,9 @@
             throw new IllegalArgumentException(errorMessage);
         }
     }
+
+    ApfV6Generator append(Instruction instruction) {
+        super.append(instruction);
+        return this;
+    }
 }
diff --git a/src/android/net/dhcp/DhcpClient.java b/src/android/net/dhcp/DhcpClient.java
index 7fff1e9..e415698 100644
--- a/src/android/net/dhcp/DhcpClient.java
+++ b/src/android/net/dhcp/DhcpClient.java
@@ -566,7 +566,7 @@
      * check whether or not to support DHCP Rapid Commit option.
      */
     public boolean isDhcpRapidCommitEnabled() {
-        return mDependencies.isFeatureEnabled(mContext, DHCP_RAPID_COMMIT_VERSION);
+        return mDependencies.isFeatureNotChickenedOut(mContext, DHCP_RAPID_COMMIT_VERSION);
     }
 
     /**
diff --git a/src/android/net/dhcp/DhcpServer.java b/src/android/net/dhcp/DhcpServer.java
index 041417d..276fee1 100644
--- a/src/android/net/dhcp/DhcpServer.java
+++ b/src/android/net/dhcp/DhcpServer.java
@@ -195,6 +195,14 @@
          * @param name Specific experimental flag name.
          */
         boolean isFeatureEnabled(@NonNull Context context, @NonNull String name);
+
+        /**
+         * Check whether one specific experimental feature for connectivity namespace is not
+         * disabled.
+         * @param context The global context information about an app environment.
+         * @param name Specific experimental flag name.
+         */
+        boolean isFeatureNotChickenedOut(@NonNull Context context, @NonNull String name);
     }
 
     private class DependenciesImpl implements Dependencies {
@@ -234,6 +242,11 @@
         public boolean isFeatureEnabled(@NonNull Context context, @NonNull String name) {
             return DeviceConfigUtils.isNetworkStackFeatureEnabled(context, name);
         }
+
+        @Override
+        public boolean isFeatureNotChickenedOut(final Context context, final String name) {
+            return DeviceConfigUtils.isNetworkStackFeatureNotChickenedOut(context, name);
+        }
     }
 
     private static class MalformedPacketException extends Exception {
@@ -262,7 +275,8 @@
         mDeps = deps;
         mClock = deps.makeClock();
         mLeaseRepo = deps.makeLeaseRepository(mServingParams, mLog, mClock);
-        mDhcpRapidCommitEnabled = deps.isFeatureEnabled(context, DHCP_RAPID_COMMIT_VERSION);
+        mDhcpRapidCommitEnabled =
+                deps.isFeatureNotChickenedOut(context, DHCP_RAPID_COMMIT_VERSION);
 
         // CHECKSTYLE:OFF IndentationCheck
         addState(mStoppedState);
diff --git a/src/com/android/networkstack/ipmemorystore/IpMemoryStoreService.java b/src/com/android/networkstack/ipmemorystore/IpMemoryStoreService.java
index aa7d698..76ed56c 100644
--- a/src/com/android/networkstack/ipmemorystore/IpMemoryStoreService.java
+++ b/src/com/android/networkstack/ipmemorystore/IpMemoryStoreService.java
@@ -424,6 +424,12 @@
             @Nullable final IOnStatusAndCountListener listener) {
         mExecutor.execute(() -> {
             try {
+                if (null == mDb) {
+                    if (null != listener) {
+                        listener.onComplete(makeStatus(ERROR_DATABASE_CANNOT_BE_OPENED), 0);
+                    }
+                    return;
+                }
                 final StatusAndCount res = IpMemoryStoreDatabase.delete(mDb, l2Key, needWipe);
                 if (null != listener) listener.onComplete(makeStatus(res.status), res.count);
             } catch (final RemoteException e) {
@@ -450,6 +456,12 @@
             @Nullable final IOnStatusAndCountListener listener) {
         mExecutor.execute(() -> {
             try {
+                if (null == mDb) {
+                    if (null != listener) {
+                        listener.onComplete(makeStatus(ERROR_DATABASE_CANNOT_BE_OPENED), 0);
+                    }
+                    return;
+                }
                 final StatusAndCount res =
                         IpMemoryStoreDatabase.deleteCluster(mDb, cluster, needWipe);
                 if (null != listener) listener.onComplete(makeStatus(res.status), res.count);
@@ -464,7 +476,12 @@
      */
     @Override
     public void factoryReset() {
-        mExecutor.execute(() -> IpMemoryStoreDatabase.wipeDataUponNetworkReset(mDb));
+        mExecutor.execute(() -> {
+            if (null == mDb) {
+                return;
+            }
+            IpMemoryStoreDatabase.wipeDataUponNetworkReset(mDb);
+        });
     }
 
     /** Get db size threshold. */
@@ -474,6 +491,9 @@
     }
 
     private long getDbSize() {
+        if (null == mDb) {
+            return 0;
+        }
         final File dbFile = new File(mDb.getPath());
         try {
             return dbFile.length();
diff --git a/tests/integration/Android.bp b/tests/integration/Android.bp
index 0d2e19e..65a94f3 100644
--- a/tests/integration/Android.bp
+++ b/tests/integration/Android.bp
@@ -69,9 +69,6 @@
     static_libs: [
         "NetworkStackApiStableLib",
     ],
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Network stack integration tests.
@@ -88,9 +85,6 @@
     jarjar_rules: ":NetworkStackJarJarRules",
     host_required: ["net-tests-utils-host-common"],
     test_config_template: "AndroidTestTemplate_Integration.xml",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Network stack next integration tests.
@@ -114,9 +108,6 @@
     jarjar_rules: ":NetworkStackJarJarRules",
     host_required: ["net-tests-utils-host-common"],
     test_config_template: "AndroidTestTemplate_Integration.xml",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Network stack integration root tests.
@@ -143,9 +134,6 @@
     jarjar_rules: ":NetworkStackJarJarRules",
     host_required: ["net-tests-utils-host-common"],
     test_config_template: "AndroidTestTemplate_Integration.xml",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Special version of the network stack tests that includes all tests necessary for code coverage
@@ -173,7 +161,4 @@
     compile_multilib: "both",
     manifest: "AndroidManifest_coverage.xml",
     jarjar_rules: ":NetworkStackJarJarRules",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
diff --git a/tests/integration/lint-baseline.xml b/tests/integration/lint-baseline.xml
deleted file mode 100644
index edc9dac..0000000
--- a/tests/integration/lint-baseline.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getDhcpServerAddress`">
-        <location
-            file="packages/modules/NetworkStack/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java"
-            line="1574"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getNat64Prefix`">
-        <location
-            file="packages/modules/NetworkStack/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java"
-            line="2014"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getNat64Prefix`">
-        <location
-            file="packages/modules/NetworkStack/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java"
-            line="2020"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getNat64Prefix`">
-        <location
-            file="packages/modules/NetworkStack/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java"
-            line="2050"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.LinkProperties#getNat64Prefix`">
-        <location
-            file="packages/modules/NetworkStack/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java"
-            line="2051"/>
-    </issue>
-
-</issues>
\ No newline at end of file
diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp
index ad6c078..88d995f 100644
--- a/tests/unit/Android.bp
+++ b/tests/unit/Android.bp
@@ -70,9 +70,6 @@
     static_libs: ["NetworkStackApiCurrentLib"],
     compile_multilib: "both", // Workaround for b/147785146 for mainline-presubmit
     jarjar_rules: ":NetworkStackJarJarRules",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Library containing the unit tests. This is used by the coverage test target to pull in the
@@ -85,7 +82,7 @@
     static_libs: ["NetworkStackApiStableLib"],
     lint: {
         test: true,
-        baseline_filename: "lint-baseline.xml",
+
     },
     visibility: [
         "//packages/modules/NetworkStack/tests/integration",
@@ -108,9 +105,6 @@
     static_libs: ["NetworkStackApiStableLib"],
     compile_multilib: "both",
     jarjar_rules: ":NetworkStackJarJarRules",
-    lint: {
-        baseline_filename: "lint-baseline.xml",
-    },
 }
 
 // Additional dependencies of libnetworkstackutilsjni that are not provided by the system when
diff --git a/tests/unit/lint-baseline.xml b/tests/unit/lint-baseline.xml
deleted file mode 100644
index f8b1c29..0000000
--- a/tests/unit/lint-baseline.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.NetworkCapabilities()`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/NetworkStackNotifierTest.kt"
-            line="136"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `android.net.NetworkCapabilities()`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/NetworkStackNotifierTest.kt"
-            line="137"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `new android.net.NetworkCapabilities`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/metrics/NetworkValidationMetricsTest.java"
-            line="57"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `new android.net.NetworkCapabilities`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/metrics/NetworkValidationMetricsTest.java"
-            line="109"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `new android.net.NetworkCapabilities`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/metrics/NetworkValidationMetricsTest.java"
-            line="117"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `new android.net.NetworkCapabilities`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/metrics/NetworkValidationMetricsTest.java"
-            line="123"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 30 (current min is 29): `new android.net.NetworkCapabilities`">
-        <location
-            file="packages/modules/NetworkStack/tests/unit/src/com/android/networkstack/metrics/NetworkValidationMetricsTest.java"
-            line="129"/>
-    </issue>
-
-</issues>
\ No newline at end of file
diff --git a/tests/unit/src/android/net/apf/ApfTest.java b/tests/unit/src/android/net/apf/ApfTest.java
index 37b9060..fa4f722 100644
--- a/tests/unit/src/android/net/apf/ApfTest.java
+++ b/tests/unit/src/android/net/apf/ApfTest.java
@@ -2801,6 +2801,70 @@
         apfFilter.shutdown();
     }
 
+    @Test
+    public void testProcessRaWithInfiniteLifeTimeWithoutCrash() throws Exception {
+        final MockIpClientCallback ipClientCallback = new MockIpClientCallback();
+        // configure accept_ra_min_lft
+        final ApfConfiguration config = getDefaultConfig();
+        config.acceptRaMinLft = 180;
+        TestApfFilter apfFilter;
+        // Template packet:
+        // Frame 1: 150 bytes on wire (1200 bits), 150 bytes captured (1200 bits)
+        // Ethernet II, Src: Netgear_23:67:2c (28:c6:8e:23:67:2c), Dst: IPv6mcast_01 (33:33:00:00:00:01)
+        // Internet Protocol Version 6, Src: fe80::2ac6:8eff:fe23:672c, Dst: ff02::1
+        // Internet Control Message Protocol v6
+        //   Type: Router Advertisement (134)
+        //   Code: 0
+        //   Checksum: 0x0acd [correct]
+        //   Checksum Status: Good
+        //   Cur hop limit: 64
+        //   Flags: 0xc0, Managed address configuration, Other configuration, Prf (Default Router Preference): Medium
+        //   Router lifetime (s): 7000
+        //   Reachable time (ms): 0
+        //   Retrans timer (ms): 0
+        //   ICMPv6 Option (Source link-layer address : 28:c6:8e:23:67:2c)
+        //     Type: Source link-layer address (1)
+        //     Length: 1 (8 bytes)
+        //     Link-layer address: Netgear_23:67:2c (28:c6:8e:23:67:2c)
+        //     Source Link-layer address: Netgear_23:67:2c (28:c6:8e:23:67:2c)
+        //   ICMPv6 Option (MTU : 1500)
+        //     Type: MTU (5)
+        //     Length: 1 (8 bytes)
+        //     Reserved
+        //     MTU: 1500
+        //   ICMPv6 Option (Prefix information : 2401:fa00:480:f000::/64)
+        //     Type: Prefix information (3)
+        //     Length: 4 (32 bytes)
+        //     Prefix Length: 64
+        //     Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
+        //     Valid Lifetime: Infinity (4294967295)
+        //     Preferred Lifetime: Infinity (4294967295)
+        //     Reserved
+        //     Prefix: 2401:fa00:480:f000::
+        //   ICMPv6 Option (Recursive DNS Server 2401:fa00:480:f000::1)
+        //     Type: Recursive DNS Server (25)
+        //     Length: 3 (24 bytes)
+        //     Reserved
+        //     Lifetime: 7000
+        //     Recursive DNS Servers: 2401:fa00:480:f000::1
+        //   ICMPv6 Option (Advertisement Interval : 600000)
+        //     Type: Advertisement Interval (7)
+        //     Length: 1 (8 bytes)
+        //     Reserved
+        //     Advertisement Interval: 600000
+        final String packetStringFmt = "33330000000128C68E23672C86DD60054C6B00603AFFFE800000000000002AC68EFFFE23672CFF02000000000000000000000000000186000ACD40C01B580000000000000000010128C68E23672C05010000000005DC030440C0%s000000002401FA000480F00000000000000000001903000000001B582401FA000480F000000000000000000107010000000927C0";
+        final List<String> lifetimes = List.of("FFFFFFFF", "00000000", "00000001", "00001B58");
+        for (String lifetime : lifetimes) {
+            apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mNetworkQuirkMetrics);
+            final byte[] ra = hexStringToByteArray(
+                    String.format(packetStringFmt, lifetime + lifetime));
+            // feed the RA into APF and generate the filter, the filter shouldn't crash.
+            apfFilter.pretendPacketReceived(ra);
+            ipClientCallback.assertProgramUpdateAndGet();
+            apfFilter.shutdown();
+        }
+    }
+
     // Test for go/apf-ra-filter Case 1a.
     // Old lifetime is 0
     @Test
@@ -3827,4 +3891,183 @@
         final String referenceProgramHexString = "6bfcb03a01b8120c6b9494014a06006b907c014388a27c013e88a47c013988b87c013488cd7c012f88e17c012a88e384003f08066a0e6bdca40110000600010800060412147a1c016bd884010400021a1c6b8c7c01010000686bd4a2ef06ffffffffffff6a266bbca2ea04c0a801be6bf872e0120c84008d08000a17821e1112149c00171fffab0d2a108210446a3239a20406ea42226789c06bf472b60a1e52f06bac7ab3e06bb41a1e7e000000a6ffffffff6bb07e0000009bc0a801ff0a178230116a1aa223086b7a1f1fc0a801beaa0d3a08aa221210ab2139821501aa0d3a0ea20a041194ceca3a08a20401ff6b8072666be868a25406ffffffffffff6bb872566bf0724c7c001086dd686bd0a23b06ffffffffffff6bc8723d0a147a32007a0b3a6b980a267a2eff6be072240a366ba87a23858218886a26a2040fff02000000000000000000000000006ba472086be4b03a01b87206b03a01b87201";
         assertEquals(referenceProgramHexString, programString);
     }
+
+    @Test
+    public void testInfiniteLifetimeFullApfV4ProgramGeneration() throws IllegalInstructionException {
+        ApfV4Generator gen = new ApfV4Generator(APF_VERSION_4);
+        gen.addLoadImmediate(R1, -8);
+        gen.addLoadData(R0, 0);
+        gen.addAdd(1);
+        gen.addStoreData(R0, 0);
+        gen.addLoad16(R0, 12);
+        gen.addLoadImmediate(R1, -120);
+        gen.addJumpIfR0LessThan(0x600, "LABEL_582");
+        gen.addLoadImmediate(R1, -124);
+        gen.addJumpIfR0Equals(0x88a2, "LABEL_582");
+        gen.addJumpIfR0Equals(0x88a4, "LABEL_582");
+        gen.addJumpIfR0Equals(0x88b8, "LABEL_582");
+        gen.addJumpIfR0Equals(0x88cd, "LABEL_582");
+        gen.addJumpIfR0Equals(0x88e1, "LABEL_582");
+        gen.addJumpIfR0Equals(0x88e3, "LABEL_582");
+        gen.addJumpIfR0NotEquals(0x806, "LABEL_122");
+        gen.addLoadImmediate(R0, 14);
+        gen.addLoadImmediate(R1, -152);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("000108000604"), "LABEL_582");
+        gen.addLoad16(R0, 20);
+        gen.addJumpIfR0Equals(0x1, "LABEL_104");
+        gen.addLoadImmediate(R1, -156);
+        gen.addJumpIfR0NotEquals(0x2, "LABEL_582");
+        gen.addLoad32(R0, 28);
+        gen.addLoadImmediate(R1, -128);
+        gen.addJumpIfR0Equals(0x0, "LABEL_582");
+        gen.addLoadImmediate(R0, 0);
+        gen.addLoadImmediate(R1, -56);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("ffffffffffff"), "LABEL_576");
+
+        gen.defineLabel("LABEL_104");
+        gen.addLoadImmediate(R0, 38);
+        gen.addLoadImmediate(R1, -80);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("c0a801ec"), "LABEL_582");
+        gen.addLoadImmediate(R1, -20);
+        gen.addJump("LABEL_576");
+
+        gen.defineLabel("LABEL_122");
+        gen.addLoad16(R0, 12);
+        gen.addJumpIfR0NotEquals(0x800, "LABEL_249");
+        gen.addLoad8(R0, 23);
+        gen.addJumpIfR0NotEquals(0x11, "LABEL_165");
+        gen.addLoad16(R0, 20);
+        gen.addJumpIfR0AnyBitsSet(0x1fff, "LABEL_165");
+        gen.addLoadFromMemory(R1, 13);
+        gen.addLoad16Indexed(R0, 16);
+        gen.addJumpIfR0NotEquals(0x44, "LABEL_165");
+        gen.addLoadImmediate(R0, 50);
+        gen.addAddR1();
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("7e9046bc7008"), "LABEL_165");
+        gen.addLoadImmediate(R1, -24);
+        gen.addJump("LABEL_576");
+
+        gen.defineLabel("LABEL_165");
+        gen.addLoad8(R0, 30);
+        gen.addAnd(240);
+        gen.addLoadImmediate(R1, -96);
+        gen.addJumpIfR0Equals(0xe0, "LABEL_582");
+        gen.addLoadImmediate(R1, -88);
+        gen.addLoad32(R0, 30);
+        gen.addJumpIfR0Equals(0xffffffff, "LABEL_582");
+        gen.addLoadImmediate(R1, -92);
+        gen.addJumpIfR0Equals(0xc0a801ff, "LABEL_582");
+        gen.addLoad8(R0, 23);
+        gen.addJumpIfR0NotEquals(0x6, "LABEL_225");
+        gen.addLoad16(R0, 20);
+        gen.addJumpIfR0AnyBitsSet(0x1fff, "LABEL_225");
+        gen.addLoadFromMemory(R1, 13);
+        gen.addLoad16Indexed(R0, 16);
+        gen.addJumpIfR0NotEquals(0x7, "LABEL_225");
+        gen.addLoadImmediate(R1, -148);
+        gen.addJump("LABEL_582");
+
+        gen.defineLabel("LABEL_225");
+        gen.addLoadImmediate(R1, -36);
+        gen.addLoadImmediate(R0, 0);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("ffffffffffff"), "LABEL_576");
+        gen.addLoadImmediate(R1, -84);
+        gen.addJump("LABEL_582");
+        gen.addLoadImmediate(R1, -28);
+        gen.addJump("LABEL_576");
+
+        gen.defineLabel("LABEL_249");
+        gen.addJumpIfR0Equals(0x86dd, "LABEL_273");
+        gen.addLoadImmediate(R0, 0);
+        gen.addLoadImmediate(R1, -60);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("ffffffffffff"), "LABEL_576");
+        gen.addLoadImmediate(R1, -68);
+        gen.addJump("LABEL_582");
+
+        gen.defineLabel("LABEL_273");
+        gen.addLoad8(R0, 20);
+        gen.addJumpIfR0Equals(0x0, "LABEL_576");
+        gen.addJumpIfR0Equals(0x3a, "LABEL_297");
+        gen.addLoadImmediate(R1, -116);
+        gen.addLoad8(R0, 38);
+        gen.addJumpIfR0Equals(0xff, "LABEL_582");
+        gen.addLoadImmediate(R1, -44);
+        gen.addJump("LABEL_576");
+
+        gen.defineLabel("LABEL_297");
+        gen.addLoad8(R0, 54);
+        gen.addLoadImmediate(R1, -100);
+        gen.addJumpIfR0Equals(0x85, "LABEL_582");
+        gen.addJumpIfR0NotEquals(0x88, "LABEL_333");
+        gen.addLoadImmediate(R0, 38);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("ff0200000000000000000000000000"), "LABEL_333");
+        gen.addLoadImmediate(R1, -104);
+        gen.addJump("LABEL_582");
+
+        gen.defineLabel("LABEL_333");
+        gen.addLoadFromMemory(R0, 14);
+        gen.addJumpIfR0NotEquals(0x96, "LABEL_574");
+        gen.addLoadFromMemory(R0, 15);
+        gen.addJumpIfR0GreaterThan(0x48e, "LABEL_574");
+        gen.addLoadImmediate(R0, 0);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("7e9046bc700828c68e23672c86dd60"), "LABEL_574");
+        gen.addLoadImmediate(R0, 18);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("00603afffe800000000000002ac68efffe23672c"), "LABEL_574");
+        gen.addLoadImmediate(R0, 54);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("8600"), "LABEL_574");
+        gen.addLoadImmediate(R0, 58);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("40c0"), "LABEL_574");
+        gen.addLoad16(R0, 60);
+        gen.addJumpIfR0Equals(0x0, "LABEL_574");
+        gen.addJumpIfR0LessThan(0xb4, "LABEL_421");
+        gen.addJumpIfR0LessThan(0x91e, "LABEL_574");
+        gen.addJumpIfR0GreaterThan(0x1b58, "LABEL_574");
+
+        gen.defineLabel("LABEL_421");
+        gen.addLoadImmediate(R0, 62);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("0000000000000000010128c68e23672c05010000000005dc030440c0"), "LABEL_574");
+        gen.addLoad32(R0, 90);
+        gen.addJumpIfR0Equals(0x0, "LABEL_574");
+        gen.addJumpIfR0LessThan(0xb4, "LABEL_480");
+        gen.addJumpIfR0LessThan(0x55555555, "LABEL_574");
+        gen.addJumpIfR0GreaterThan(0xffffffffL, "LABEL_574");
+
+        gen.defineLabel("LABEL_480");
+        gen.addLoad32(R0, 94);
+        gen.addJumpIfR0LessThan(0x55555555, "LABEL_574");
+        gen.addJumpIfR0GreaterThan(0xffffffffL, "LABEL_574");
+        gen.addLoadImmediate(R0, 98);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("000000002401fa000480f000000000000000000019030000"), "LABEL_574");
+        gen.addLoad32(R0, 122);
+        gen.addJumpIfR0Equals(0x0, "LABEL_574");
+        gen.addJumpIfR0LessThan(0x78, "LABEL_547");
+        gen.addJumpIfR0LessThan(0x91e, "LABEL_574");
+        gen.addJumpIfR0GreaterThan(0x1b58, "LABEL_574");
+
+        gen.defineLabel("LABEL_547");
+        gen.addLoadImmediate(R0, 126);
+        gen.addJumpIfBytesAtR0NotEqual(hexStringToByteArray("2401fa000480f00000000000000000010701"), "LABEL_574");
+        gen.addLoadImmediate(R1, -72);
+        gen.addJump("LABEL_582");
+
+        gen.defineLabel("LABEL_574");
+        gen.addLoadImmediate(R1, -40);
+
+        gen.defineLabel("LABEL_576");
+        gen.addLoadData(R0, 0);
+        gen.addAdd(1);
+        gen.addStoreData(R0, 0);
+        gen.addJump(PASS_LABEL);
+
+        gen.defineLabel("LABEL_582");
+        gen.addLoadData(R0, 0);
+        gen.addAdd(1);
+        gen.addStoreData(R0, 0);
+        gen.addJump(DROP_LABEL);
+
+        byte[] program = gen.generate();
+        final String programString = toHexString(program).toLowerCase();
+        final String referenceProgramHexString = "6bf8b03a01b8120c6b8894023706006b847c023088a27c022b88a47c022688b87c022188cd7c021c88e17c021788e384004608066a0e6dff68a40202000600010800060412147a1f016dff648401f500021a1c6b807c01ec0000686bc8a401d80006ffffffffffff6a266bb0a401d10004c0a801ec6bec7401c6120c84007808000a17821f1112149c00181fffab0d2a108211446a3239a205067e9046bc70086be874019b0a1e52f06ba07c019600e06ba81a1e7e00000189ffffffff6ba47e0000017ec0a801ff0a1782140612149c000d1fffab0d2a108206076dff6c7401656bdc68a401510006ffffffffffff6bac7401526be47401477c001386dd686bc4a401340006ffffffffffff6bbc7401350a147c012800007a0e3a6b8c0a267c012200ff6bd47401170a366b9c7c011400858218886a26a2040fff02000000000000000000000000006b9872f9aa0e82ec96aa0f8c00e5048e68a2d20f7e9046bc700828c68e23672c86dd606a12a2b91400603afffe800000000000002ac68efffe23672c6a36a2b20286006a3aa2ab0240c0123c7aa600920ab494009e091e8c00991b586a3ea2781c0000000000000000010128c68e23672c05010000000005dc030440c01a5a7a73009212b49600000067555555558e0000005effffffff1a5e9600000053555555558e0000004affffffff6a62a22d18000000002401fa000480f0000000000000000000190300001a7a7a2800920a78940020091e8c001b1b586a7ea204122401fa000480f000000000000000000107016bb872086bd8b03a01b87206b03a01b87201";
+        assertEquals(referenceProgramHexString, programString);
+    }
 }
diff --git a/tests/unit/src/android/net/apf/ApfV5Test.kt b/tests/unit/src/android/net/apf/ApfV5Test.kt
index b867191..779a1b3 100644
--- a/tests/unit/src/android/net/apf/ApfV5Test.kt
+++ b/tests/unit/src/android/net/apf/ApfV5Test.kt
@@ -36,6 +36,9 @@
 @SmallTest
 class ApfV5Test {
 
+    private val testPacket = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8,
+                                         9, 10, 11, 12, 13, 14, 15, 16)
+
     @Test
     fun testDataInstructionMustComeFirst() {
         var gen = ApfV6Generator()
@@ -286,9 +289,9 @@
                 0x03.toByte(), 0xe8.toByte(), 0xff.toByte(),
         ), program)
         assertContentEquals(listOf(
-                "0: dcopy       src=0, len=10",
-                "2: dcopy       src=1, len=5",
-                "5: pcopy       src=1000, len=255"
+                "0: datacopy    src=0, len=10",
+                "2: datacopy    src=1, len=5",
+                "5: pktcopy     src=1000, len=255"
         ),
         ApfJniUtils.disassembleApf(program).map { it.trim() })
 
@@ -331,8 +334,8 @@
                 encodeInstruction(21, 1, 1), 43, 1, 0x0c.toByte(),
         ) + qnames, program)
         assertContentEquals(listOf(
-            "0: jdnsqne     r0, DROP, 12, 014101420000",
-            "10: jdnsqeq     r0, DROP, 12, 014101420000"),
+            "0: jdnsqne     r0, DROP, 12, (1)A(1)B(0)(0)",
+            "10: jdnsqeq     r0, DROP, 12, (1)A(1)B(0)(0)"),
             ApfJniUtils.disassembleApf(program).map{ it.trim() })
 
         gen = ApfV6Generator()
@@ -344,22 +347,40 @@
         ) + qnames + byteArrayOf(
                 encodeInstruction(21, 1, 1), 44, 1,
         ) + qnames, program)
+        assertContentEquals(listOf(
+            "0: jdnsane     r0, DROP, (1)A(1)B(0)(0)",
+            "9: jdnsaeq     r0, DROP, (1)A(1)B(0)(0)"),
+            ApfJniUtils.disassembleApf(program).map{ it.trim() })
     }
 
     @Test
     fun testWriteToTxBuffer() {
-        val gen = ApfV6Generator()
-        gen.addAllocate(74)
-        gen.addWriteU8(0x01)
-        gen.addWriteU16(0x0102)
-        gen.addWriteU32(0x01020304)
-        gen.addTransmit()
-        val program = gen.generate()
+        val program = ApfV6Generator()
+            .addAllocate(74)
+            .addWriteU8(0x01)
+            .addWriteU16(0x0102)
+            .addWriteU32(0x01020304)
+            .addTransmit()
+            .generate()
         assertPass(MIN_APF_VERSION_IN_DEV, program, ByteArray(MIN_PKT_SIZE))
         assertContentEquals(byteArrayOf(0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x04),
           ApfJniUtils.getTransmittedPacket())
     }
 
+    @Test
+    fun testCopyToTxBuffer() {
+        val program = ApfV6Generator()
+            .addData(byteArrayOf(33, 34, 35))
+            .addAllocate(74)
+            .addDataCopy(2, 2)
+            .addPacketCopy(0, 1)
+            .addPacketCopy(1, 2)
+            .addTransmit()
+            .generate()
+        assertPass(MIN_APF_VERSION_IN_DEV, program, testPacket)
+        assertContentEquals(byteArrayOf(33, 34, 1, 2, 3), ApfJniUtils.getTransmittedPacket())
+    }
+
     private fun encodeInstruction(opcode: Int, immLength: Int, register: Int): Byte {
         val immLengthEncoding = if (immLength == 4) 3 else immLength
         return opcode.shl(3).or(immLengthEncoding.shl(1)).or(register).toByte()
diff --git a/tests/unit/src/android/net/dhcp/DhcpServerTest.java b/tests/unit/src/android/net/dhcp/DhcpServerTest.java
index 6d4bc13..1853071 100644
--- a/tests/unit/src/android/net/dhcp/DhcpServerTest.java
+++ b/tests/unit/src/android/net/dhcp/DhcpServerTest.java
@@ -197,7 +197,8 @@
         when(mDeps.makeLeaseRepository(any(), any(), any())).thenReturn(mRepository);
         when(mDeps.makeClock()).thenReturn(mClock);
         when(mDeps.makePacketListener(any())).thenReturn(mPacketListener);
-        when(mDeps.isFeatureEnabled(eq(mContext), eq(DHCP_RAPID_COMMIT_VERSION))).thenReturn(true);
+        when(mDeps.isFeatureNotChickenedOut(eq(mContext), eq(DHCP_RAPID_COMMIT_VERSION)))
+                .thenReturn(true);
         doNothing().when(mDeps)
                 .sendPacket(any(), mSentPacketCaptor.capture(), mResponseDstAddrCaptor.capture());
         when(mClock.elapsedRealtime()).thenReturn(TEST_CLOCK_TIME);
@@ -253,7 +254,8 @@
     public void testDiscover_RapidCommit() throws Exception {
         startServer();
 
-        when(mDeps.isFeatureEnabled(eq(mContext), eq(DHCP_RAPID_COMMIT_VERSION))).thenReturn(true);
+        when(mDeps.isFeatureNotChickenedOut(eq(mContext), eq(DHCP_RAPID_COMMIT_VERSION)))
+                .thenReturn(true);
         when(mRepository.getCommittedLease(isNull() /* clientId */, eq(TEST_CLIENT_MAC),
                 eq(INADDR_ANY) /* relayAddr */, isNull() /* hostname */)).thenReturn(TEST_LEASE);
 
diff --git a/tests/unit/src/com/android/networkstack/ipmemorystore/IpMemoryStoreServiceTest.java b/tests/unit/src/com/android/networkstack/ipmemorystore/IpMemoryStoreServiceTest.java
index 37bd808..d192425 100644
--- a/tests/unit/src/com/android/networkstack/ipmemorystore/IpMemoryStoreServiceTest.java
+++ b/tests/unit/src/com/android/networkstack/ipmemorystore/IpMemoryStoreServiceTest.java
@@ -937,4 +937,43 @@
             assertEquals(testCase.first, Utils.byteArrayToString(testCase.second));
         }
     }
+
+    @Test
+    public void testNullDb() throws Exception {
+        // Init IpMemoryStoreService with a file that can't be opened
+        final File file = new File("/", TEST_DATABASE_NAME);
+        doReturn(file).when(mMockContext).getDatabasePath(anyString());
+        final IpMemoryStoreService ipMemoryStoreService =
+                new IpMemoryStoreService(mMockContext);
+
+        //test delete, no NullPointerException, got expected status and deleting count
+        doLatched("Did not get fail callback", latch ->
+                ipMemoryStoreService.delete("key", false /* needWipe */,
+                        onDeleteStatus((status, deleted) -> {
+                            assertEquals("Unexpected status: ",
+                                    Status.ERROR_DATABASE_CANNOT_BE_OPENED,
+                                    status.resultCode);
+                            assertEquals("Deleting count != 1 :" +
+                                    deleted, 0, deleted.intValue());
+                            latch.countDown();
+                        })), LONG_TIMEOUT_MS);
+
+        //Test deleteCluster, no NullPointerException, got expected status and deletedCount
+        doLatched("Did not get fail callback", latch ->
+                ipMemoryStoreService.deleteCluster("key", false /* needWipe */,
+                        onDeleteStatus((status, deletedCount) -> {
+                            assertEquals("Unexpected status: ",
+                                    Status.ERROR_DATABASE_CANNOT_BE_OPENED,
+                                    status.resultCode);
+                            assertEquals("Unexpected deleted count : ",
+                                    0, deletedCount.intValue());
+                            latch.countDown();
+                        })), LONG_TIMEOUT_MS);
+
+        // Try to wipe all data in tables, no NullPointerException
+        ipMemoryStoreService.factoryReset();
+
+        //db is null, the db size could not over the threshold.
+        assertFalse(ipMemoryStoreService.isDbSizeOverThreshold());
+    }
 }