Merge "ConnectivityManager: no double NetworkCallback registration"

This commit is contained in:
Treehugger Robot
2017-03-02 07:56:24 +00:00
committed by Gerrit Code Review
2 changed files with 57 additions and 9 deletions

View File

@@ -2884,11 +2884,14 @@ public class ConnectivityManager {
if (callback == null) {
throw new IllegalArgumentException("null NetworkCallback");
}
if (need == null && action != REQUEST) {
if ((need == null) && (action != REQUEST)) {
throw new IllegalArgumentException("null NetworkCapabilities");
}
// TODO: throw an exception if callback.networkRequest is not null.
// http://b/20701525
final int targetSdk = mContext.getApplicationInfo().targetSdkVersion;
if ((targetSdk > VERSION_CODES.N_MR1) && (callback.networkRequest != null)) {
// http://b/20701525
throw new IllegalArgumentException("NetworkCallback already registered");
}
final NetworkRequest request;
try {
synchronized(sCallbacks) {