summaryrefslogtreecommitdiffstats
path: root/core/java/android/net
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2014-09-09 14:46:37 -0700
committerRobert Greenwalt <rgreenwalt@google.com>2014-09-10 10:39:37 -0700
commit35f7a94c846cfdaa75ed6bc58ec37bdef7a09be8 (patch)
treec16a982acd21d51932bc83920eb187363a10aa4b /core/java/android/net
parent36f32f1b97b7437c50bd0a71d7c2ebd5bcd8c2ae (diff)
downloadframeworks_base-35f7a94c846cfdaa75ed6bc58ec37bdef7a09be8.zip
frameworks_base-35f7a94c846cfdaa75ed6bc58ec37bdef7a09be8.tar.gz
frameworks_base-35f7a94c846cfdaa75ed6bc58ec37bdef7a09be8.tar.bz2
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. The core of 17361330 will be fixed when we stop sending scores for listens to NetworkFactories, but it exposed this issue too. Summary: 1 - add a network listener. This isn't a request so it's not sent to networks. 2 - alter your score (ethernet sets score to -1 when the link goes down) (16:07:39.782) 3 - a bug in ConnectivityService causes score changes to get sent for all network requests and network listeners causing NetworkFactories to no see 2 entities. This bug will be fixed by a pending change (https://googleplex-android-review.googlesource.com/#/c/540840/). This causes the ethernet NetworkFactory to see two entities, both served by networks of score -1. (16:07:39.989) 4 - disconnect Ethernet - this only sends 0 scores for known requests, not network listeners. Had it been sent for both entities they both would have evaluated that the networkfactory score (-1) was lower than the request score (0) and both released their refcount. (16:08:03.147) 5 - this means the listener is tracked by the EthernetNetworkFactory with a score of -1 while the factory itself has a score of -1 so the network release isn't called. bug:17361330 Change-Id: Ife34ca0f9c233dd3c3df80f6fea580af43afcdeb
Diffstat (limited to 'core/java/android/net')
-rw-r--r--core/java/android/net/NetworkAgent.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java
index 8df9916..80e5b91 100644
--- a/core/java/android/net/NetworkAgent.java
+++ b/core/java/android/net/NetworkAgent.java
@@ -223,6 +223,9 @@ public abstract class NetworkAgent extends Handler {
* Called by the bearer code when it has a new score for this network.
*/
public void sendNetworkScore(int score) {
+ if (score < 0) {
+ throw new IllegalArgumentException("Score must be >= 0");
+ }
queueOrSendMessage(EVENT_NETWORK_SCORE_CHANGED, new Integer(score));
}