diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index 47c1acb31a..bf3d996260 100644 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -6908,7 +6908,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 */); }