Merge "Setting MTU size for specific network." into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ecd0db5a73
@@ -66,6 +66,7 @@ public class LinkProperties implements Parcelable {
|
||||
private String mDomains;
|
||||
private Collection<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
|
||||
private ProxyProperties mHttpProxy;
|
||||
private int mMtu;
|
||||
|
||||
// Stores the properties of links that are "stacked" above this link.
|
||||
// Indexed by interface name to allow modification and to prevent duplicates being added.
|
||||
@@ -104,6 +105,7 @@ public class LinkProperties implements Parcelable {
|
||||
for (LinkProperties l: source.mStackedLinks.values()) {
|
||||
addStackedLink(l);
|
||||
}
|
||||
setMtu(source.getMtu());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +225,14 @@ public class LinkProperties implements Parcelable {
|
||||
mDomains = domains;
|
||||
}
|
||||
|
||||
public void setMtu(int mtu) {
|
||||
mMtu = mtu;
|
||||
}
|
||||
|
||||
public int getMtu() {
|
||||
return mMtu;
|
||||
}
|
||||
|
||||
private RouteInfo routeWithInterface(RouteInfo route) {
|
||||
return new RouteInfo(
|
||||
route.getDestination(),
|
||||
@@ -322,6 +332,7 @@ public class LinkProperties implements Parcelable {
|
||||
mRoutes.clear();
|
||||
mHttpProxy = null;
|
||||
mStackedLinks.clear();
|
||||
mMtu = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,6 +357,8 @@ public class LinkProperties implements Parcelable {
|
||||
|
||||
String domainName = "Domains: " + mDomains;
|
||||
|
||||
String mtu = "MTU: " + mMtu;
|
||||
|
||||
String routes = " Routes: [";
|
||||
for (RouteInfo route : mRoutes) routes += route.toString() + ",";
|
||||
routes += "] ";
|
||||
@@ -359,7 +372,8 @@ public class LinkProperties implements Parcelable {
|
||||
}
|
||||
stacked += "] ";
|
||||
}
|
||||
return "{" + ifaceName + linkAddresses + routes + dns + domainName + proxy + stacked + "}";
|
||||
return "{" + ifaceName + linkAddresses + routes + dns + domainName + mtu
|
||||
+ proxy + stacked + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -474,6 +488,16 @@ public class LinkProperties implements Parcelable {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this {@code LinkProperties} MTU against the target
|
||||
*
|
||||
* @@param target LinkProperties to compare.
|
||||
* @return {@code true} if both are identical, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isIdenticalMtu(LinkProperties target) {
|
||||
return getMtu() == target.getMtu();
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Compares this {@code LinkProperties} instance against the target
|
||||
@@ -505,7 +529,8 @@ public class LinkProperties implements Parcelable {
|
||||
isIdenticalDnses(target) &&
|
||||
isIdenticalRoutes(target) &&
|
||||
isIdenticalHttpProxy(target) &&
|
||||
isIdenticalStackedLinks(target);
|
||||
isIdenticalStackedLinks(target) &&
|
||||
isIdenticalMtu(target);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -607,7 +632,8 @@ public class LinkProperties implements Parcelable {
|
||||
+ ((null == mDomains) ? 0 : mDomains.hashCode())
|
||||
+ mRoutes.size() * 41
|
||||
+ ((null == mHttpProxy) ? 0 : mHttpProxy.hashCode())
|
||||
+ mStackedLinks.hashCode() * 47);
|
||||
+ mStackedLinks.hashCode() * 47)
|
||||
+ mMtu * 51;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,7 +651,7 @@ public class LinkProperties implements Parcelable {
|
||||
dest.writeByteArray(d.getAddress());
|
||||
}
|
||||
dest.writeString(mDomains);
|
||||
|
||||
dest.writeInt(mMtu);
|
||||
dest.writeInt(mRoutes.size());
|
||||
for(RouteInfo route : mRoutes) {
|
||||
dest.writeParcelable(route, flags);
|
||||
@@ -664,6 +690,7 @@ public class LinkProperties implements Parcelable {
|
||||
} catch (UnknownHostException e) { }
|
||||
}
|
||||
netProp.setDomains(in.readString());
|
||||
netProp.setMtu(in.readInt());
|
||||
addressCount = in.readInt();
|
||||
for (int i=0; i<addressCount; i++) {
|
||||
netProp.addRoute((RouteInfo)in.readParcelable(null));
|
||||
|
||||
@@ -198,6 +198,8 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
|
||||
loge("CONNECTED event did not supply link properties.");
|
||||
mLinkProperties = new LinkProperties();
|
||||
}
|
||||
mLinkProperties.setMtu(mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_mobile_mtu));
|
||||
mLinkCapabilities = intent.getParcelableExtra(
|
||||
PhoneConstants.DATA_LINK_CAPABILITIES_KEY);
|
||||
if (mLinkCapabilities == null) {
|
||||
|
||||
@@ -117,6 +117,11 @@ interface INetworkManagementService
|
||||
*/
|
||||
void removeSecondaryRoute(String iface, in RouteInfo route);
|
||||
|
||||
/**
|
||||
* Set the specified MTU size
|
||||
*/
|
||||
void setMtu(String iface, int mtu);
|
||||
|
||||
/**
|
||||
* Shuts down the service
|
||||
*/
|
||||
|
||||
28
core/res/res/values-mcc204-mnc04/config.xml
Normal file
28
core/res/res/values-mcc204-mnc04/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1358</integer>
|
||||
|
||||
</resources>
|
||||
@@ -36,4 +36,8 @@
|
||||
note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
|
||||
<string translatable="false" name="config_tether_apndata">Fido LTE Tethering,ltedata.apn,,,,,,,,,302,370,,DUN</string>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1410</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -22,4 +22,9 @@
|
||||
<string-array translatable="false" name="config_operatorConsideredNonRoaming">
|
||||
<item>302</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1358</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -35,4 +35,9 @@
|
||||
"name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
|
||||
note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
|
||||
<string translatable="false" name="config_tether_apndata">MTS -Tethering,internet.mts,,,,,,,,,302,660,,DUN</string>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1430</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -36,4 +36,8 @@
|
||||
note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
|
||||
<string translatable="false" name="config_tether_apndata">Rogers LTE Tethering,ltedata.apn,,,,,,,,,302,720,,DUN</string>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1430</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -41,4 +41,9 @@
|
||||
<string-array translatable="false" name="config_operatorConsideredNonRoaming">
|
||||
<item>302</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1358</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
28
core/res/res/values-mcc310-mnc120/config.xml
Normal file
28
core/res/res/values-mcc310-mnc120/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1422</integer>
|
||||
|
||||
</resources>
|
||||
@@ -37,4 +37,8 @@
|
||||
note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
|
||||
<string translatable="false" name="config_tether_apndata">T-Mobile Tethering,pcweb.tmobile.com,,,,,,,,,310,260,,DUN</string>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1440</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
28
core/res/res/values-mcc310-mnc410/config.xml
Normal file
28
core/res/res/values-mcc310-mnc410/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1410</integer>
|
||||
|
||||
</resources>
|
||||
28
core/res/res/values-mcc440-mnc20/config.xml
Normal file
28
core/res/res/values-mcc440-mnc20/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1340</integer>
|
||||
|
||||
</resources>
|
||||
28
core/res/res/values-mcc440-mnc50/config.xml
Normal file
28
core/res/res/values-mcc440-mnc50/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1420</integer>
|
||||
|
||||
</resources>
|
||||
28
core/res/res/values-mcc440-mnc54/config.xml
Normal file
28
core/res/res/values-mcc440-mnc54/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1420</integer>
|
||||
|
||||
</resources>
|
||||
28
core/res/res/values-mcc450-mnc05/config.xml
Normal file
28
core/res/res/values-mcc450-mnc05/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1440</integer>
|
||||
|
||||
</resources>
|
||||
28
core/res/res/values-mcc450-mnc06/config.xml
Normal file
28
core/res/res/values-mcc450-mnc06/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1428</integer>
|
||||
|
||||
</resources>
|
||||
28
core/res/res/values-mcc450-mnc08/config.xml
Normal file
28
core/res/res/values-mcc450-mnc08/config.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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 my 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1450</integer>
|
||||
|
||||
</resources>
|
||||
@@ -37,4 +37,8 @@
|
||||
note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
|
||||
<string translatable="false" name="config_tether_apndata">Telstra Tethering,telstra.internet,,,,,,,,,505,01,,DUN</string>
|
||||
|
||||
<!-- Configure mobile network MTU. Carrier specific value is set here.
|
||||
-->
|
||||
<integer name="config_mobile_mtu">1400</integer>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1097,6 +1097,10 @@
|
||||
players. -->
|
||||
<integer name="config_safe_media_volume_index">10</integer>
|
||||
|
||||
<!-- Configure mobile network MTU. The standard default is set here but each carrier
|
||||
may have a specific value set in an overlay config.xml file. -->
|
||||
<integer name="config_mobile_mtu">1500</integer>
|
||||
|
||||
<!-- Whether WiFi display is supported by this device.
|
||||
There are many prerequisites for this feature to work correctly.
|
||||
Here are a few of them:
|
||||
|
||||
@@ -311,6 +311,8 @@
|
||||
<java-symbol type="integer" name="config_lockSoundVolumeDb" />
|
||||
<java-symbol type="integer" name="config_multiuserMaximumUsers" />
|
||||
<java-symbol type="integer" name="config_safe_media_volume_index" />
|
||||
<java-symbol type="integer" name="config_mobile_mtu" />
|
||||
|
||||
<java-symbol type="color" name="tab_indicator_text_v4" />
|
||||
|
||||
<java-symbol type="dimen" name="accessibility_touch_slop" />
|
||||
|
||||
@@ -33,6 +33,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
private static InetAddress GATEWAY1 = NetworkUtils.numericToInetAddress("75.208.8.1");
|
||||
private static InetAddress GATEWAY2 = NetworkUtils.numericToInetAddress("69.78.8.1");
|
||||
private static String NAME = "qmi0";
|
||||
private static int MTU = 1500;
|
||||
|
||||
private static LinkAddress LINKADDRV4 = new LinkAddress(ADDRV4, 32);
|
||||
private static LinkAddress LINKADDRV6 = new LinkAddress(ADDRV6, 128);
|
||||
@@ -57,6 +58,9 @@ public class LinkPropertiesTest extends TestCase {
|
||||
assertTrue(source.isIdenticalStackedLinks(target));
|
||||
assertTrue(target.isIdenticalStackedLinks(source));
|
||||
|
||||
assertTrue(source.isIdenticalMtu(target));
|
||||
assertTrue(target.isIdenticalMtu(source));
|
||||
|
||||
// Check result of equals().
|
||||
assertTrue(source.equals(target));
|
||||
assertTrue(target.equals(source));
|
||||
@@ -88,6 +92,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
// set 2 gateways
|
||||
source.addRoute(new RouteInfo(GATEWAY1));
|
||||
source.addRoute(new RouteInfo(GATEWAY2));
|
||||
source.setMtu(MTU);
|
||||
|
||||
LinkProperties target = new LinkProperties();
|
||||
|
||||
@@ -99,6 +104,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
target.addDns(DNS2);
|
||||
target.addRoute(new RouteInfo(GATEWAY1));
|
||||
target.addRoute(new RouteInfo(GATEWAY2));
|
||||
target.setMtu(MTU);
|
||||
|
||||
assertLinkPropertiesEqual(source, target);
|
||||
|
||||
@@ -111,6 +117,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
target.addDns(DNS2);
|
||||
target.addRoute(new RouteInfo(GATEWAY1));
|
||||
target.addRoute(new RouteInfo(GATEWAY2));
|
||||
target.setMtu(MTU);
|
||||
assertFalse(source.equals(target));
|
||||
|
||||
target.clear();
|
||||
@@ -123,6 +130,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
target.addDns(DNS2);
|
||||
target.addRoute(new RouteInfo(GATEWAY1));
|
||||
target.addRoute(new RouteInfo(GATEWAY2));
|
||||
target.setMtu(MTU);
|
||||
assertFalse(source.equals(target));
|
||||
|
||||
target.clear();
|
||||
@@ -134,6 +142,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
target.addDns(DNS2);
|
||||
target.addRoute(new RouteInfo(GATEWAY1));
|
||||
target.addRoute(new RouteInfo(GATEWAY2));
|
||||
target.setMtu(MTU);
|
||||
assertFalse(source.equals(target));
|
||||
|
||||
target.clear();
|
||||
@@ -145,6 +154,19 @@ public class LinkPropertiesTest extends TestCase {
|
||||
// change gateway
|
||||
target.addRoute(new RouteInfo(NetworkUtils.numericToInetAddress("75.208.8.2")));
|
||||
target.addRoute(new RouteInfo(GATEWAY2));
|
||||
target.setMtu(MTU);
|
||||
assertFalse(source.equals(target));
|
||||
|
||||
target.clear();
|
||||
target.setInterfaceName(NAME);
|
||||
target.addLinkAddress(LINKADDRV4);
|
||||
target.addLinkAddress(LINKADDRV6);
|
||||
target.addDns(DNS1);
|
||||
target.addDns(DNS2);
|
||||
target.addRoute(GATEWAY1);
|
||||
target.addRoute(GATEWAY2);
|
||||
// change mtu
|
||||
target.setMtu(1440);
|
||||
assertFalse(source.equals(target));
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -167,6 +189,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
// set 2 gateways
|
||||
source.addRoute(new RouteInfo(GATEWAY1));
|
||||
source.addRoute(new RouteInfo(GATEWAY2));
|
||||
source.setMtu(MTU);
|
||||
|
||||
LinkProperties target = new LinkProperties();
|
||||
// Exchange order
|
||||
@@ -177,6 +200,7 @@ public class LinkPropertiesTest extends TestCase {
|
||||
target.addDns(DNS1);
|
||||
target.addRoute(new RouteInfo(GATEWAY2));
|
||||
target.addRoute(new RouteInfo(GATEWAY1));
|
||||
target.setMtu(MTU);
|
||||
|
||||
assertLinkPropertiesEqual(source, target);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -2299,6 +2299,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
thisNet.setTeardownRequested(false);
|
||||
updateNetworkSettings(thisNet);
|
||||
updateMtuSizeSettings(thisNet);
|
||||
handleConnectivityChange(newNetType, false);
|
||||
sendConnectedBroadcastDelayed(info, getConnectivityChangeDelay());
|
||||
|
||||
@@ -2636,6 +2637,26 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
return routesChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the network specific MTU size from reources.
|
||||
* and set it on it's iface.
|
||||
*/
|
||||
private void updateMtuSizeSettings(NetworkStateTracker nt) {
|
||||
final String iface = nt.getLinkProperties().getInterfaceName();
|
||||
final int mtu = nt.getLinkProperties().getMtu();
|
||||
|
||||
if (mtu < 68 || mtu > 10000) {
|
||||
loge("Unexpected mtu value: " + nt);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (VDBG) log("Setting MTU size: " + iface + ", " + mtu);
|
||||
mNetd.setMtu(iface, mtu);
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "exception in setMtu()" + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the network specific TCP buffer sizes from SystemProperties
|
||||
@@ -4771,4 +4792,3 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, wakeupTime, intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -837,6 +837,18 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
||||
return routes.toArray(new RouteInfo[routes.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMtu(String iface, int mtu) {
|
||||
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
||||
|
||||
final NativeDaemonEvent event;
|
||||
try {
|
||||
event = mConnector.execute("interface", "setmtu", iface, mtu);
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw e.rethrowAsParcelableException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// TODO: remove from aidl if nobody calls externally
|
||||
|
||||
Reference in New Issue
Block a user