From f0959a78a22a7298252c4cb16ee8a06f07148fe0 Mon Sep 17 00:00:00 2001 From: Xiao Ma Date: Mon, 18 Mar 2024 14:46:30 +0900 Subject: [PATCH] Make PrefixInformationOption struct constructor visible for testing. PrefixInformationOption#build always gives the correct option length and type, visible constructor is easiler to verify the incorrect parameters in the test, for example, we will verify the code that parses the PIO option in RA as a ND user option in netlink message. Bug: 315069348 Test: TH Change-Id: I6b88e6718cb873b15936c1f518d357c36c41ffde --- .../net/module/util/structs/PrefixInformationOption.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/staticlibs/device/com/android/net/module/util/structs/PrefixInformationOption.java b/staticlibs/device/com/android/net/module/util/structs/PrefixInformationOption.java index 49d7654d3a..0fc85e4de0 100644 --- a/staticlibs/device/com/android/net/module/util/structs/PrefixInformationOption.java +++ b/staticlibs/device/com/android/net/module/util/structs/PrefixInformationOption.java @@ -21,6 +21,7 @@ import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION import android.net.IpPrefix; import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; import com.android.net.module.util.Struct; import com.android.net.module.util.Struct.Field; @@ -71,7 +72,8 @@ public class PrefixInformationOption extends Struct { @Field(order = 7, type = Type.ByteArray, arraysize = 16) public final byte[] prefix; - PrefixInformationOption(final byte type, final byte length, final byte prefixLen, + @VisibleForTesting + public PrefixInformationOption(final byte type, final byte length, final byte prefixLen, final byte flags, final long validLifetime, final long preferredLifetime, final int reserved, @NonNull final byte[] prefix) { this.type = type;