From cf0f619a5080670415693ca772e079a494aaf7f7 Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Wed, 10 Sep 2014 10:06:32 -0700 Subject: [PATCH] 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 --- .../android/server/ethernet/EthernetNetworkFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index 83a3fa7be0..a4711548cb 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -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; }