Fix NetworkOffer Death link does not exist

unregisterNetworkProvider is being called from binderDied()
and handleUnregisterNetworkProvider() at the same time. This results
in NoSuchElementException being thrown.

Check than noi can be removed from network offers before unregistering
death link.

Bug: 196423150
Change-Id: If5bd5f2894fa0509a89340efdc85180c54e72e0e
This commit is contained in:
Tyler Wear 2021-08-17 18:25:50 -07:00
commit 3ec7e6d9fb

View file

@ -6901,7 +6901,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (DBG) {
log("unregister offer from providerId " + noi.offer.providerId + " : " + noi.offer);
}
mNetworkOffers.remove(noi);
// If the provider removes the offer and dies immediately afterwards this
// function may be called twice in a row, but the array will no longer contain
// the offer.
if (!mNetworkOffers.remove(noi)) return;
noi.offer.callback.asBinder().unlinkToDeath(noi, 0 /* flags */);
}