Merge "Don't accept score below 0." into lmp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2ea88e8ece
@@ -223,6 +223,9 @@ public abstract class NetworkAgent extends Handler {
|
|||||||
* Called by the bearer code when it has a new score for this network.
|
* Called by the bearer code when it has a new score for this network.
|
||||||
*/
|
*/
|
||||||
public void sendNetworkScore(int score) {
|
public void sendNetworkScore(int score) {
|
||||||
|
if (score < 0) {
|
||||||
|
throw new IllegalArgumentException("Score must be >= 0");
|
||||||
|
}
|
||||||
queueOrSendMessage(EVENT_NETWORK_SCORE_CHANGED, new Integer(score));
|
queueOrSendMessage(EVENT_NETWORK_SCORE_CHANGED, new Integer(score));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4746,6 +4746,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private void updateNetworkScore(NetworkAgentInfo nai, int score) {
|
private void updateNetworkScore(NetworkAgentInfo nai, int score) {
|
||||||
if (DBG) log("updateNetworkScore for " + nai.name() + " to " + score);
|
if (DBG) log("updateNetworkScore for " + nai.name() + " to " + score);
|
||||||
|
if (score < 0) {
|
||||||
|
loge("updateNetworkScore for " + nai.name() + " got a negative score (" + score +
|
||||||
|
"). Bumping score to min of 0");
|
||||||
|
score = 0;
|
||||||
|
}
|
||||||
|
|
||||||
nai.currentScore = score;
|
nai.currentScore = score;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user