Merge "API changes for IPv6 MTU support"
diff --git a/api/system-current.txt b/api/system-current.txt
index 695d3d4..a6f4e81 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6253,6 +6253,8 @@
public final class RouteInfo implements android.os.Parcelable {
ctor public RouteInfo(@Nullable android.net.IpPrefix, @Nullable java.net.InetAddress, @Nullable String, int);
+ ctor public RouteInfo(@Nullable android.net.IpPrefix, @Nullable java.net.InetAddress, @Nullable String, int, int);
+ method public int getMtu();
method public int getType();
field public static final int RTN_THROW = 9; // 0x9
field public static final int RTN_UNICAST = 1; // 0x1
@@ -12146,7 +12148,9 @@
method public int getId();
method @NonNull public String getInterfaceName();
method public int getLinkStatus();
- method public int getMtu();
+ method @Deprecated public int getMtu();
+ method public int getMtuV4();
+ method public int getMtuV6();
method @NonNull public java.util.List<java.net.InetAddress> getPcscfAddresses();
method public int getProtocolType();
method public int getSuggestedRetryTime();
@@ -12168,7 +12172,9 @@
method @NonNull public android.telephony.data.DataCallResponse.Builder setId(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setInterfaceName(@NonNull String);
method @NonNull public android.telephony.data.DataCallResponse.Builder setLinkStatus(int);
- method @NonNull public android.telephony.data.DataCallResponse.Builder setMtu(int);
+ method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setMtu(int);
+ method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV4(int);
+ method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV6(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List<java.net.InetAddress>);
method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int);
@@ -12179,7 +12185,9 @@
method @NonNull public String getApn();
method public int getAuthType();
method public int getBearerBitmask();
- method public int getMtu();
+ method @Deprecated public int getMtu();
+ method public int getMtuV4();
+ method public int getMtuV6();
method @Nullable public String getPassword();
method public int getProfileId();
method public int getProtocolType();
@@ -12204,7 +12212,9 @@
method @NonNull public android.telephony.data.DataProfile.Builder setApn(@NonNull String);
method @NonNull public android.telephony.data.DataProfile.Builder setAuthType(int);
method @NonNull public android.telephony.data.DataProfile.Builder setBearerBitmask(int);
- method @NonNull public android.telephony.data.DataProfile.Builder setMtu(int);
+ method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setMtu(int);
+ method @NonNull public android.telephony.data.DataProfile.Builder setMtuV4(int);
+ method @NonNull public android.telephony.data.DataProfile.Builder setMtuV6(int);
method @NonNull public android.telephony.data.DataProfile.Builder setPassword(@NonNull String);
method @NonNull public android.telephony.data.DataProfile.Builder setPersistent(boolean);
method @NonNull public android.telephony.data.DataProfile.Builder setPreferred(boolean);
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java
index e088094..2b9e9fe 100644
--- a/core/java/android/net/RouteInfo.java
+++ b/core/java/android/net/RouteInfo.java
@@ -105,6 +105,11 @@
*/
private final int mType;
+ /**
+ * The maximum transmission unit size for this route.
+ */
+ private final int mMtu;
+
// Derived data members.
// TODO: remove these.
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
@@ -133,6 +138,31 @@
@TestApi
public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway,
@Nullable String iface, @RouteType int type) {
+ this(destination, gateway, iface, type, 0);
+ }
+
+ /**
+ * Constructs a RouteInfo object.
+ *
+ * If destination is null, then gateway must be specified and the
+ * constructed route is either the IPv4 default route <code>0.0.0.0</code>
+ * if the gateway is an instance of {@link Inet4Address}, or the IPv6 default
+ * route <code>::/0</code> if gateway is an instance of
+ * {@link Inet6Address}.
+ * <p>
+ * destination and gateway may not both be null.
+ *
+ * @param destination the destination prefix
+ * @param gateway the IP address to route packets through
+ * @param iface the interface name to send packets on
+ * @param type the type of this route
+ * @param mtu the maximum transmission unit size for this route
+ *
+ * @hide
+ */
+ @SystemApi
+ public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway,
+ @Nullable String iface, @RouteType int type, int mtu) {
switch (type) {
case RTN_UNICAST:
case RTN_UNREACHABLE:
@@ -162,7 +192,7 @@
} else {
// no destination, no gateway. invalid.
throw new IllegalArgumentException("Invalid arguments passed in: " + gateway + "," +
- destination);
+ destination);
}
}
// TODO: set mGateway to null if there is no gateway. This is more correct, saves space, and
@@ -177,10 +207,10 @@
}
mHasGateway = (!gateway.isAnyLocalAddress());
- if ((destination.getAddress() instanceof Inet4Address &&
- (gateway instanceof Inet4Address == false)) ||
- (destination.getAddress() instanceof Inet6Address &&
- (gateway instanceof Inet6Address == false))) {
+ if ((destination.getAddress() instanceof Inet4Address
+ && !(gateway instanceof Inet4Address))
+ || (destination.getAddress() instanceof Inet6Address
+ && !(gateway instanceof Inet6Address))) {
throw new IllegalArgumentException("address family mismatch in RouteInfo constructor");
}
mDestination = destination; // IpPrefix objects are immutable.
@@ -188,6 +218,7 @@
mInterface = iface; // Strings are immutable.
mType = type;
mIsHost = isHost();
+ mMtu = mtu;
}
/**
@@ -374,6 +405,17 @@
}
/**
+ * Retrieves the MTU size for this route.
+ *
+ * @return The MTU size, or 0 if it has not been set.
+ * @hide
+ */
+ @SystemApi
+ public int getMtu() {
+ return mMtu;
+ }
+
+ /**
* Indicates if this route is a default route (ie, has no destination specified).
*
* @return {@code true} if the destination has a prefix length of 0.
@@ -463,6 +505,7 @@
val += " unknown type " + mType;
}
}
+ val += " mtu " + mMtu;
return val;
}
@@ -480,7 +523,7 @@
return Objects.equals(mDestination, target.getDestination()) &&
Objects.equals(mGateway, target.getGateway()) &&
Objects.equals(mInterface, target.getInterface()) &&
- mType == target.getType();
+ mType == target.getType() && mMtu == target.getMtu();
}
/**
@@ -490,7 +533,7 @@
return (mDestination.hashCode() * 41)
+ (mGateway == null ? 0 :mGateway.hashCode() * 47)
+ (mInterface == null ? 0 :mInterface.hashCode() * 67)
- + (mType * 71);
+ + (mType * 71) + (mMtu * 89);
}
/**
@@ -509,6 +552,7 @@
dest.writeByteArray(gatewayBytes);
dest.writeString(mInterface);
dest.writeInt(mType);
+ dest.writeInt(mMtu);
}
/**
@@ -527,8 +571,9 @@
String iface = in.readString();
int type = in.readInt();
+ int mtu = in.readInt();
- return new RouteInfo(dest, gateway, iface, type);
+ return new RouteInfo(dest, gateway, iface, type, mtu);
}
public RouteInfo[] newArray(int size) {
diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java
index 49625bb..a116c07 100644
--- a/telephony/java/android/telephony/data/DataCallResponse.java
+++ b/telephony/java/android/telephony/data/DataCallResponse.java
@@ -78,6 +78,9 @@
private final List<InetAddress> mGatewayAddresses;
private final List<InetAddress> mPcscfAddresses;
private final int mMtu;
+ private final int mMtuV4;
+ private final int mMtuV6;
+ private final int mVersion;
/**
* @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error.
@@ -97,9 +100,8 @@
* "192.0.1.11 2001:db8::1". When null, the addresses represent point to point connections.
* @param pcscfAddresses A list of Proxy Call State Control Function address via PCO (Protocol
* Configuration Option) for IMS client.
- * @param mtu MTU (maximum transmission unit) in bytes received from network. Zero or negative
- * values means network has either not sent a value or sent an invalid value.
- * either not sent a value or sent an invalid value.
+ * @param mtu MTU (maximum transmission unit) in bytes received from network.
+ * Zero or negative values means network has either not sent a value or sent an invalid value.
*
* @removed Use the {@link Builder()} instead.
*/
@@ -125,6 +127,34 @@
mPcscfAddresses = (pcscfAddresses == null)
? new ArrayList<>() : new ArrayList<>(pcscfAddresses);
mMtu = mtu;
+ mMtuV4 = mMtuV6 = 0;
+ mVersion = 0;
+ }
+
+ /** @hide */
+ private DataCallResponse(@DataFailureCause int cause, int suggestedRetryTime, int id,
+ @LinkStatus int linkStatus, @ProtocolType int protocolType,
+ @Nullable String interfaceName, @Nullable List<LinkAddress> addresses,
+ @Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses,
+ @Nullable List<InetAddress> pcscfAddresses, int mtuV4, int mtuV6, int version) {
+ mCause = cause;
+ mSuggestedRetryTime = suggestedRetryTime;
+ mId = id;
+ mLinkStatus = linkStatus;
+ mProtocolType = protocolType;
+ mInterfaceName = (interfaceName == null) ? "" : interfaceName;
+ mAddresses = (addresses == null)
+ ? new ArrayList<>() : new ArrayList<>(addresses);
+ mDnsAddresses = (dnsAddresses == null)
+ ? new ArrayList<>() : new ArrayList<>(dnsAddresses);
+ mGatewayAddresses = (gatewayAddresses == null)
+ ? new ArrayList<>() : new ArrayList<>(gatewayAddresses);
+ mPcscfAddresses = (pcscfAddresses == null)
+ ? new ArrayList<>() : new ArrayList<>(pcscfAddresses);
+ mMtu = 0;
+ mMtuV4 = mtuV4;
+ mMtuV6 = mtuV6;
+ mVersion = version;
}
/** @hide */
@@ -145,6 +175,9 @@
mPcscfAddresses = new ArrayList<>();
source.readList(mPcscfAddresses, InetAddress.class.getClassLoader());
mMtu = source.readInt();
+ mMtuV4 = source.readInt();
+ mMtuV6 = source.readInt();
+ mVersion = source.readInt();
}
/**
@@ -210,8 +243,29 @@
/**
* @return MTU (maximum transmission unit) in bytes received from network. Zero or negative
* values means network has either not sent a value or sent an invalid value.
+ * @deprecated For IRadio 1.5 and up, use {@link #getMtuV4} or {@link #getMtuV6} instead.
*/
- public int getMtu() { return mMtu; }
+ @Deprecated
+ public int getMtu() {
+ return mVersion < 5 ? mMtu : 0;
+ }
+
+ /**
+ * This replaces the deprecated method getMtu.
+ * @return MTU (maximum transmission unit) in bytes received from network, for IPv4.
+ * Zero or negative values means network has either not sent a value or sent an invalid value.
+ */
+ public int getMtuV4() {
+ return mVersion < 5 ? 0 : mMtuV4;
+ }
+
+ /**
+ * @return MTU (maximum transmission unit) in bytes received from network, for IPv6.
+ * Zero or negative values means network has either not sent a value or sent an invalid value.
+ */
+ public int getMtuV6() {
+ return mVersion < 5 ? 0 : mMtuV6;
+ }
@NonNull
@Override
@@ -229,6 +283,9 @@
.append(" gateways=").append(mGatewayAddresses)
.append(" pcscf=").append(mPcscfAddresses)
.append(" mtu=").append(mMtu)
+ .append(" mtuV4=").append(mMtuV4)
+ .append(" mtuV6=").append(mMtuV6)
+ .append(" version=").append(mVersion)
.append("}");
return sb.toString();
}
@@ -256,14 +313,17 @@
&& mGatewayAddresses.containsAll(other.mGatewayAddresses)
&& mPcscfAddresses.size() == other.mPcscfAddresses.size()
&& mPcscfAddresses.containsAll(other.mPcscfAddresses)
- && mMtu == other.mMtu;
+ && mMtu == other.mMtu
+ && mMtuV4 == other.mMtuV4
+ && mMtuV6 == other.mMtuV6
+ && mVersion == other.mVersion;
}
@Override
public int hashCode() {
return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
- mMtu);
+ mMtu, mMtuV4, mMtuV6, mVersion);
}
@Override
@@ -284,6 +344,9 @@
dest.writeList(mGatewayAddresses);
dest.writeList(mPcscfAddresses);
dest.writeInt(mMtu);
+ dest.writeInt(mMtuV4);
+ dest.writeInt(mMtuV6);
+ dest.writeInt(mVersion);
}
public static final @android.annotation.NonNull Parcelable.Creator<DataCallResponse> CREATOR =
@@ -336,6 +399,12 @@
private int mMtu;
+ private int mMtuV4;
+
+ private int mMtuV6;
+
+ private int mVersion;
+
/**
* Default constructor for Builder.
*/
@@ -460,6 +529,7 @@
* negative values means network has either not sent a value or sent an invalid value.
*
* @return The same instance of the builder.
+ * @deprecated For IRadio 1.5 and up, use {@link #setMtuV4} or {@link #setMtuV6} instead.
*/
public @NonNull Builder setMtu(int mtu) {
mMtu = mtu;
@@ -467,14 +537,55 @@
}
/**
+ * Set maximum transmission unit of the data connection, for IPv4.
+ *
+ * @param mtu MTU (maximum transmission unit) in bytes received from network. Zero or
+ * negative values means network has either not sent a value or sent an invalid value.
+ *
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setMtuV4(int mtu) {
+ mMtuV4 = mtu;
+ return this;
+ }
+
+ /**
+ * Set maximum transmission unit of the data connection, for IPv6.
+ *
+ * @param mtu MTU (maximum transmission unit) in bytes received from network. Zero or
+ * negative values means network has either not sent a value or sent an invalid value.
+ *
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setMtuV6(int mtu) {
+ mMtuV6 = mtu;
+ return this;
+ }
+
+ /**
+ * Set the IRadio version for this DataCallResponse
+ * @hide
+ */
+ public @NonNull Builder setVersion(int version) {
+ mVersion = version;
+ return this;
+ }
+
+ /**
* Build the DataCallResponse.
*
* @return the DataCallResponse object.
*/
public @NonNull DataCallResponse build() {
- return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
- mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
- mPcscfAddresses, mMtu);
+ if (mVersion >= 5) {
+ return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
+ mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
+ mPcscfAddresses, mMtuV4, mMtuV6, mVersion);
+ } else {
+ return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
+ mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
+ mPcscfAddresses, mMtu);
+ }
}
}
}
diff --git a/telephony/java/android/telephony/data/DataProfile.java b/telephony/java/android/telephony/data/DataProfile.java
index 96a5a81..f2a1249 100644
--- a/telephony/java/android/telephony/data/DataProfile.java
+++ b/telephony/java/android/telephony/data/DataProfile.java
@@ -96,7 +96,9 @@
@NetworkTypeBitMask
private final int mBearerBitmask;
- private final int mMtu;
+ private final int mMtuV4;
+
+ private final int mMtuV6;
private final boolean mPersistent;
@@ -104,12 +106,11 @@
/** @hide */
private DataProfile(int profileId, String apn, @ProtocolType int protocolType, int authType,
- String userName, String password, int type, int maxConnectionsTime,
- int maxConnections, int waitTime, boolean enabled,
- @ApnType int supportedApnTypesBitmask,
- @ProtocolType int roamingProtocolType,
- @NetworkTypeBitMask int bearerBitmask, int mtu, boolean persistent,
- boolean preferred) {
+ String userName, String password, int type, int maxConnectionsTime,
+ int maxConnections, int waitTime, boolean enabled,
+ @ApnType int supportedApnTypesBitmask, @ProtocolType int roamingProtocolType,
+ @NetworkTypeBitMask int bearerBitmask, int mtuV4, int mtuV6, boolean persistent,
+ boolean preferred) {
this.mProfileId = profileId;
this.mApn = apn;
this.mProtocolType = protocolType;
@@ -128,7 +129,8 @@
this.mSupportedApnTypesBitmask = supportedApnTypesBitmask;
this.mRoamingProtocolType = roamingProtocolType;
this.mBearerBitmask = bearerBitmask;
- this.mMtu = mtu;
+ this.mMtuV4 = mtuV4;
+ this.mMtuV6 = mtuV6;
this.mPersistent = persistent;
this.mPreferred = preferred;
}
@@ -148,7 +150,8 @@
mSupportedApnTypesBitmask = source.readInt();
mRoamingProtocolType = source.readInt();
mBearerBitmask = source.readInt();
- mMtu = source.readInt();
+ mMtuV4 = source.readInt();
+ mMtuV6 = source.readInt();
mPersistent = source.readBoolean();
mPreferred = source.readBoolean();
}
@@ -237,8 +240,21 @@
/**
* @return The maximum transmission unit (MTU) size in bytes.
+ * @deprecated use {@link #getMtuV4} or {@link #getMtuV6} instead.
*/
- public int getMtu() { return mMtu; }
+ @Deprecated
+ public int getMtu() { return mMtuV4; }
+
+ /**
+ * This replaces the deprecated method getMtu.
+ * @return The maximum transmission unit (MTU) size in bytes, for IPv4.
+ */
+ public int getMtuV4() { return mMtuV4; }
+
+ /**
+ * @return The maximum transmission unit (MTU) size in bytes, for IPv6.
+ */
+ public int getMtuV6() { return mMtuV6; }
/**
* @return {@code true} if modem must persist this data profile.
@@ -265,8 +281,8 @@
(mApn + "/" + mUserName + "/" + mPassword)) + "/" + mType + "/"
+ mMaxConnectionsTime + "/" + mMaxConnections + "/"
+ mWaitTime + "/" + mEnabled + "/" + mSupportedApnTypesBitmask + "/"
- + mRoamingProtocolType + "/" + mBearerBitmask + "/" + mMtu + "/" + mPersistent + "/"
- + mPreferred;
+ + mRoamingProtocolType + "/" + mBearerBitmask + "/" + mMtuV4 + "/" + mMtuV6 + "/"
+ + mPersistent + "/" + mPreferred;
}
@Override
@@ -285,7 +301,8 @@
dest.writeInt(mSupportedApnTypesBitmask);
dest.writeInt(mRoamingProtocolType);
dest.writeInt(mBearerBitmask);
- dest.writeInt(mMtu);
+ dest.writeInt(mMtuV4);
+ dest.writeInt(mMtuV6);
dest.writeBoolean(mPersistent);
dest.writeBoolean(mPreferred);
}
@@ -319,7 +336,8 @@
&& mSupportedApnTypesBitmask == that.mSupportedApnTypesBitmask
&& mRoamingProtocolType == that.mRoamingProtocolType
&& mBearerBitmask == that.mBearerBitmask
- && mMtu == that.mMtu
+ && mMtuV4 == that.mMtuV4
+ && mMtuV6 == that.mMtuV6
&& mPersistent == that.mPersistent
&& mPreferred == that.mPreferred
&& Objects.equals(mApn, that.mApn)
@@ -331,8 +349,8 @@
public int hashCode() {
return Objects.hash(mProfileId, mApn, mProtocolType, mAuthType, mUserName, mPassword, mType,
mMaxConnectionsTime, mMaxConnections, mWaitTime, mEnabled,
- mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtu, mPersistent,
- mPreferred);
+ mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtuV4, mMtuV6,
+ mPersistent, mPreferred);
}
/**
@@ -384,7 +402,9 @@
@NetworkTypeBitMask
private int mBearerBitmask;
- private int mMtu;
+ private int mMtuV4;
+
+ private int mMtuV6;
private boolean mPersistent;
@@ -567,9 +587,33 @@
*
* @param mtu The maximum transmission unit (MTU) size in bytes.
* @return The same instance of the builder.
+ * @deprecated use {@link #setMtuV4} or {@link #setMtuV6} instead.
*/
public @NonNull Builder setMtu(int mtu) {
- mMtu = mtu;
+ mMtuV4 = mMtuV6 = mtu;
+ return this;
+ }
+
+ /**
+ * Set the maximum transmission unit (MTU) size in bytes, for IPv4.
+ * This replaces the deprecated method setMtu.
+ *
+ * @param mtu The maximum transmission unit (MTU) size in bytes.
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setMtuV4(int mtu) {
+ mMtuV4 = mtu;
+ return this;
+ }
+
+ /**
+ * Set the maximum transmission unit (MTU) size in bytes, for IPv6.
+ *
+ * @param mtu The maximum transmission unit (MTU) size in bytes.
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setMtuV6(int mtu) {
+ mMtuV6 = mtu;
return this;
}
@@ -606,7 +650,7 @@
public @NonNull DataProfile build() {
return new DataProfile(mProfileId, mApn, mProtocolType, mAuthType, mUserName, mPassword,
mType, mMaxConnectionsTime, mMaxConnections, mWaitTime, mEnabled,
- mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtu,
+ mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtuV4, mMtuV6,
mPersistent, mPreferred);
}
}
diff --git a/tests/net/common/java/android/net/RouteInfoTest.java b/tests/net/common/java/android/net/RouteInfoTest.java
index 5ce8436..fe51b3a 100644
--- a/tests/net/common/java/android/net/RouteInfoTest.java
+++ b/tests/net/common/java/android/net/RouteInfoTest.java
@@ -258,6 +258,16 @@
assertParcelingIsLossless(r);
r = new RouteInfo(Prefix("192.0.2.0/24"), null, "wlan0");
- assertParcelSane(r, 6);
+ assertParcelSane(r, 7);
+ }
+
+ public void testMtu() {
+ RouteInfo r;
+ r = new RouteInfo(Prefix("0.0.0.0/0"), Address("0.0.0.0"), "wlan0",
+ RouteInfo.RTN_UNICAST, 1500);
+ assertEquals(1500, r.getMtu());
+
+ r = new RouteInfo(Prefix("0.0.0.0/0"), Address("0.0.0.0"), "wlan0");
+ assertEquals(0, r.getMtu());
}
}