ConnectivityManager: no double NetworkCallback registration
Test: new test in ConnectivityManagerTest Bug: 20701525 Change-Id: I205333d31d43e6e6c7fe704ce63b458065f345ce
This commit is contained in:
parent
4f89af67b2
commit
ca4bf6edc3
1 changed files with 58 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue