[CM] Fix NPE due to unvalidated callback value
When unregistering callback due to ON_UNAVAILABLE did not check for a non-null callback. Bug: 132950880 Test: atest ConnectivityServiceTest Change-Id: I8f3322963f322e6690f1403681bf66e8b38b35f8
This commit is contained in:
parent
06df06fdaf
commit
bc3a4eb54c
1 changed files with 34 additions and 13 deletions
|
|
@ -3449,6 +3449,11 @@ public class ConnectivityManager {
|
|||
final NetworkCallback callback;
|
||||
synchronized (sCallbacks) {
|
||||
callback = sCallbacks.get(request);
|
||||
if (callback == null) {
|
||||
Log.w(TAG,
|
||||
"callback not found for " + getCallbackName(message.what) + " message");
|
||||
return;
|
||||
}
|
||||
if (message.what == CALLBACK_UNAVAIL) {
|
||||
sCallbacks.remove(request);
|
||||
callback.networkRequest = ALREADY_UNREGISTERED;
|
||||
|
|
@ -3457,10 +3462,6 @@ public class ConnectivityManager {
|
|||
if (DBG) {
|
||||
Log.d(TAG, getCallbackName(message.what) + " for network " + network);
|
||||
}
|
||||
if (callback == null) {
|
||||
Log.w(TAG, "callback not found for " + getCallbackName(message.what) + " message");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (message.what) {
|
||||
case CALLBACK_PRECHECK: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue