[NS B06] Simplification

This check is now unnecessary, seeing how the code adding these
changes is now guaranteed to only add at most one change for
each request.

Test: FrameworksNetTests
Change-Id: Ia0443602d9c89ee413e956df9c7b79f8f74813f7
This commit is contained in:
Chalard Jean
2019-12-10 21:25:24 +09:00
parent 7feb6ed384
commit 46a62378ec

View File

@@ -155,7 +155,6 @@ import android.security.Credentials;
import android.security.KeyStore;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.LocalLog;
import android.util.Log;
@@ -6547,37 +6546,30 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
@NonNull private final Set<NetworkBgStatePair> mRematchedNetworks = new ArraySet<>();
@NonNull private final Map<NetworkRequestInfo, RequestReassignment> mReassignments =
new ArrayMap<>();
@NonNull private final ArrayList<RequestReassignment> mReassignments = new ArrayList<>();
@NonNull Iterable<NetworkBgStatePair> getRematchedNetworks() {
return mRematchedNetworks;
}
@NonNull Iterable<RequestReassignment> getRequestReassignments() {
return mReassignments.values();
return mReassignments;
}
void addRequestReassignment(@NonNull final RequestReassignment reassignment) {
final RequestReassignment oldChange = mReassignments.get(reassignment.mRequest);
if (null == oldChange) {
mReassignments.put(reassignment.mRequest, reassignment);
return;
if (!Build.IS_USER) {
// The code is never supposed to add two reassignments of the same request. Make
// sure this stays true, but without imposing this expensive check on all
// reassignments on all user devices.
for (final RequestReassignment existing : mReassignments) {
if (existing.mRequest.equals(reassignment.mRequest)) {
throw new IllegalStateException("Trying to reassign ["
+ reassignment + "] but already have ["
+ existing + "]");
}
}
}
if (oldChange.mNewNetwork != reassignment.mOldNetwork) {
throw new IllegalArgumentException("Reassignment <" + reassignment.mRequest + "> ["
+ reassignment.mOldNetwork + " -> " + reassignment.mNewNetwork
+ "] conflicts with ["
+ oldChange.mOldNetwork + " -> " + oldChange.mNewNetwork + "]");
}
// There was already a note to reassign this request from a network A to a network B,
// and a reassignment is added from network B to some other network C. The following
// synthesizes the merged reassignment that goes A -> C. An interesting (but not
// special) case to think about is when B is null, which can happen when the rematch
// loop notices the current satisfier doesn't satisfy the request any more, but
// hasn't yet encountered another network that could.
mReassignments.put(reassignment.mRequest, new RequestReassignment(reassignment.mRequest,
oldChange.mOldNetwork, reassignment.mNewNetwork));
mReassignments.add(reassignment);
}
void addRematchedNetwork(@NonNull final NetworkBgStatePair network) {