diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2015-06-05 17:55:36 -0700 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2015-06-10 14:44:34 -0700 |
commit | 348e98dba046a33c4ba6069ef7a6ac18c2040fe2 (patch) | |
tree | a6f8393c5dd54c36297820c5d5e9f22699d5f1d3 /core/java/android/net | |
parent | 0dd7ddc414971732b962352c7ad4a8fb111272c4 (diff) | |
download | frameworks_base-348e98dba046a33c4ba6069ef7a6ac18c2040fe2.zip frameworks_base-348e98dba046a33c4ba6069ef7a6ac18c2040fe2.tar.gz frameworks_base-348e98dba046a33c4ba6069ef7a6ac18c2040fe2.tar.bz2 |
Remove network requests properly.
We used to only remove requests that we'd acted on but that's
just wrong.
Also adds test case which exposed the problem but passes with the fix.
bug:20731384
Change-Id: I581a005560cc71167b857abf2452769399a9e1b7
Diffstat (limited to 'core/java/android/net')
-rw-r--r-- | core/java/android/net/NetworkFactory.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/java/android/net/NetworkFactory.java b/core/java/android/net/NetworkFactory.java index e47220b..71fda1c 100644 --- a/core/java/android/net/NetworkFactory.java +++ b/core/java/android/net/NetworkFactory.java @@ -24,6 +24,7 @@ import android.os.Messenger; import android.util.Log; import android.util.SparseArray; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Protocol; /** @@ -176,9 +177,9 @@ public class NetworkFactory extends Handler { private void handleRemoveRequest(NetworkRequest request) { NetworkRequestInfo n = mNetworkRequests.get(request.requestId); - if (n != null && n.requested) { + if (n != null) { mNetworkRequests.remove(request.requestId); - releaseNetworkFor(n.request); + if (n.requested) releaseNetworkFor(n.request); } } @@ -273,6 +274,11 @@ public class NetworkFactory extends Handler { sendMessage(obtainMessage(CMD_SET_FILTER, new NetworkCapabilities(netCap))); } + @VisibleForTesting + protected int getRequestCount() { + return mNetworkRequests.size(); + } + protected void log(String s) { Log.d(LOG_TAG, s); } |