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
This commit is contained in:
Xiao Ma 2024-03-18 14:46:30 +09:00
commit f0959a78a2

View file

@ -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;