Merge changes Ia930b3d3,If614da81,I975a9439
* changes: [NS04.8] Address comments from NS04 and NS04.5 [NS04.7] Reinstate a necessary change [NS04.5] Have NetworkOffer embark a provider ID
This commit is contained in:
@@ -6233,11 +6233,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offerNetwork(@NonNull final Messenger providerMessenger,
|
||||
public void offerNetwork(final int providerId,
|
||||
@NonNull final NetworkScore score, @NonNull final NetworkCapabilities caps,
|
||||
@NonNull final INetworkOfferCallback callback) {
|
||||
final NetworkOffer offer = new NetworkOffer(
|
||||
FullScore.makeProspectiveScore(score, caps), caps, callback, providerMessenger);
|
||||
FullScore.makeProspectiveScore(score, caps), caps, callback, providerId);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_OFFER, offer));
|
||||
}
|
||||
|
||||
@@ -6255,7 +6255,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
// Unregister all the offers from this provider
|
||||
final ArrayList<NetworkOfferInfo> toRemove = new ArrayList<>();
|
||||
for (final NetworkOfferInfo noi : mNetworkOffers) {
|
||||
if (noi.offer.provider == messenger) {
|
||||
if (noi.offer.providerId == npi.providerId) {
|
||||
// Can't call handleUnregisterNetworkOffer here because iteration is in progress
|
||||
toRemove.add(noi);
|
||||
}
|
||||
@@ -6640,6 +6640,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNetworkProviderWithIdRegistered(final int providerId) {
|
||||
for (final NetworkProviderInfo npi : mNetworkProviderInfos.values()) {
|
||||
if (npi.providerId == providerId) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register or update a network offer.
|
||||
* @param newOffer The new offer. If the callback member is the same as an existing
|
||||
@@ -6647,7 +6654,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
*/
|
||||
private void handleRegisterNetworkOffer(@NonNull final NetworkOffer newOffer) {
|
||||
ensureRunningOnConnectivityServiceThread();
|
||||
if (null == mNetworkProviderInfos.get(newOffer.provider)) {
|
||||
if (!isNetworkProviderWithIdRegistered(newOffer.providerId)) {
|
||||
// This may actually happen if a provider updates its score or registers and then
|
||||
// immediately unregisters. The offer would still be in the handler queue, but the
|
||||
// provider would have been removed.
|
||||
@@ -6662,7 +6669,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
final NetworkOfferInfo noi = new NetworkOfferInfo(newOffer);
|
||||
try {
|
||||
noi.offer.provider.getBinder().linkToDeath(noi, 0 /* flags */);
|
||||
noi.offer.callback.asBinder().linkToDeath(noi, 0 /* flags */);
|
||||
} catch (RemoteException e) {
|
||||
noi.binderDied();
|
||||
return;
|
||||
@@ -6674,7 +6681,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
private void handleUnregisterNetworkOffer(@NonNull final NetworkOfferInfo noi) {
|
||||
ensureRunningOnConnectivityServiceThread();
|
||||
mNetworkOffers.remove(noi);
|
||||
noi.offer.provider.getBinder().unlinkToDeath(noi, 0 /* flags */);
|
||||
noi.offer.callback.asBinder().unlinkToDeath(noi, 0 /* flags */);
|
||||
}
|
||||
|
||||
@Nullable private NetworkOfferInfo findNetworkOfferInfoByCallback(
|
||||
|
||||
Reference in New Issue
Block a user