summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Greenwalt <rgreenwalt@google.com> 2014-06-03 16:43:57 -0700
committer Robert Greenwalt <rgreenwalt@google.com> 2014-06-04 19:15:17 +0000
commit8ae980dcef1265f69fe41338f17266c2a8ec8d20 (patch)
tree38f620a734ada649679cf9e93a114c63fa31a92f
parent94236c56ddef7f0a3db010c38940f6eae75f67b4 (diff)
DO NOT MERGE Report new network scores back to factories.
This is a first order approx of what we want - should probably be good enough in most cases. bug:15277751 Change-Id: I10e3b25f6ad5c7e022ba966ed514d4e6a999180d (cherry picked from commit 94a5c61cb82401dd777d0a7ac43183d92d955323)
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index abb8cc5e255e..bd4576115b75 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -3103,7 +3103,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
break;
}
Integer score = (Integer) msg.obj;
- updateNetworkScore(nai, score);
+ if (score != null) updateNetworkScore(nai, score.intValue());
break;
}
case NetworkMonitor.EVENT_NETWORK_VALIDATED: {
@@ -5915,9 +5915,30 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
- private void updateNetworkScore(NetworkAgentInfo nai, Integer scoreInteger) {
- int score = scoreInteger.intValue();
- // TODO
+ private void updateNetworkScore(NetworkAgentInfo nai, int score) {
+ if (DBG) log("updateNetworkScore for " + nai.name() + " to " + score);
+
+ nai.currentScore = score;
+
+ // TODO - This will not do the right thing if this network is lowering
+ // its score and has requests that can be served by other
+ // currently-active networks, or if the network is increasing its
+ // score and other networks have requests that can be better served
+ // by this network.
+ //
+ // Really we want to see if any of our requests migrate to other
+ // active/lingered networks and if any other requests migrate to us (depending
+ // on increasing/decreasing currentScore. That's a bit of work and probably our
+ // score checking/network allocation code needs to be modularized so we can understand
+ // (see handleConnectionValided for an example).
+ //
+ // As a first order approx, lets just advertise the new score to factories. If
+ // somebody can beat it they will nominate a network and our normal net replacement
+ // code will fire.
+ for (int i = 0; i < nai.networkRequests.size(); i++) {
+ NetworkRequest nr = nai.networkRequests.valueAt(i);
+ sendUpdatedScoreToFactories(nr, score);
+ }
}
// notify only this one new request of the current state