Don't accept score below 0.

Network Factories are allowed to go below, but networks need to be
constrained.  Allowing the network to go below 0 meant that -1 could
sometimes leak through and foul the logic.

bug:17361330
Change-Id: Ife34ca0f9c233dd3c3df80f6fea580af43afcdeb
This commit is contained in:
Robert Greenwalt
2014-09-10 10:06:32 -07:00
parent eee07beb92
commit cf0f619a50

View File

@@ -140,6 +140,9 @@ class EthernetNetworkFactory {
mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr);
}
updateAgent();
// set our score lower than any network could go
// so we get dropped. TODO - just unregister the factory
// when link goes down.
mFactory.setScoreFilter(up ? NETWORK_SCORE : -1);
}
}
@@ -246,7 +249,8 @@ class EthernetNetworkFactory {
mNetworkAgent.sendNetworkCapabilities(mNetworkCapabilities);
mNetworkAgent.sendNetworkInfo(mNetworkInfo);
mNetworkAgent.sendLinkProperties(mLinkProperties);
mNetworkAgent.sendNetworkScore(mLinkUp? NETWORK_SCORE : -1);
// never set the network score below 0.
mNetworkAgent.sendNetworkScore(mLinkUp? NETWORK_SCORE : 0);
}
}
@@ -277,6 +281,8 @@ class EthernetNetworkFactory {
// noticing.
if (!NetworkUtils.runDhcp(mIface, dhcpResults)) {
Log.e(TAG, "DHCP request error:" + NetworkUtils.getDhcpError());
// set our score lower than any network could go
// so we get dropped.
mFactory.setScoreFilter(-1);
return;
}