Merge changes Ide2567b2,I0ee0ce92,Iac3f55af
* changes: Fix a bug where callbacks would see blips Fix a bug where a request would not be refcounted Fix a bug where UID ranges would not be removed
This commit is contained in:
@@ -3831,7 +3831,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
removeListenRequestFromNetworks(req);
|
||||
}
|
||||
}
|
||||
mDefaultNetworkRequests.remove(nri);
|
||||
if (mDefaultNetworkRequests.remove(nri)) {
|
||||
// If this request was one of the defaults, then the UID rules need to be updated
|
||||
// WARNING : if the app(s) for which this network request is the default are doing
|
||||
// traffic, this will kill their connected sockets, even if an equivalent request
|
||||
// is going to be reinstated right away ; unconnected traffic will go on the default
|
||||
// until the new default is set, which will happen very soon.
|
||||
// TODO : The only way out of this is to diff old defaults and new defaults, and only
|
||||
// remove ranges for those requests that won't have a replacement
|
||||
final NetworkAgentInfo satisfier = nri.getSatisfier();
|
||||
if (null != satisfier) {
|
||||
try {
|
||||
mNetd.networkRemoveUidRanges(satisfier.network.getNetId(),
|
||||
toUidRangeStableParcels(nri.getUids()));
|
||||
} catch (RemoteException e) {
|
||||
loge("Exception setting network preference default network", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
mNetworkRequestCounter.decrementCount(nri.mUid);
|
||||
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
||||
|
||||
@@ -5237,11 +5254,20 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
ensureAllNetworkRequestsHaveType(r);
|
||||
mRequests = initializeRequests(r);
|
||||
mNetworkRequestForCallback = nri.getNetworkRequestForCallback();
|
||||
// Note here that the satisfier may have corresponded to an old request, that
|
||||
// this code doesn't try to take over. While it is a small discrepancy in the
|
||||
// structure of these requests, it will be fixed by the next rematch and it's
|
||||
// not as bad as having an NRI not storing its real satisfier.
|
||||
// Fixing this discrepancy would require figuring out in the copying code what
|
||||
// is the new request satisfied by this, which is a bit complex and not very
|
||||
// useful as no code is using it until rematch fixes it.
|
||||
mSatisfier = nri.mSatisfier;
|
||||
mMessenger = nri.mMessenger;
|
||||
mBinder = nri.mBinder;
|
||||
mPid = nri.mPid;
|
||||
mUid = nri.mUid;
|
||||
mPendingIntent = nri.mPendingIntent;
|
||||
mNetworkRequestCounter.incrementCountOrThrow(mUid);
|
||||
mCallingAttributionTag = nri.mCallingAttributionTag;
|
||||
}
|
||||
|
||||
@@ -7201,13 +7227,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
private static class NetworkReassignment {
|
||||
static class RequestReassignment {
|
||||
@NonNull public final NetworkRequestInfo mNetworkRequestInfo;
|
||||
@NonNull public final NetworkRequest mOldNetworkRequest;
|
||||
@NonNull public final NetworkRequest mNewNetworkRequest;
|
||||
@Nullable public final NetworkRequest mOldNetworkRequest;
|
||||
@Nullable public final NetworkRequest mNewNetworkRequest;
|
||||
@Nullable public final NetworkAgentInfo mOldNetwork;
|
||||
@Nullable public final NetworkAgentInfo mNewNetwork;
|
||||
RequestReassignment(@NonNull final NetworkRequestInfo networkRequestInfo,
|
||||
@NonNull final NetworkRequest oldNetworkRequest,
|
||||
@NonNull final NetworkRequest newNetworkRequest,
|
||||
@Nullable final NetworkRequest oldNetworkRequest,
|
||||
@Nullable final NetworkRequest newNetworkRequest,
|
||||
@Nullable final NetworkAgentInfo oldNetwork,
|
||||
@Nullable final NetworkAgentInfo newNetwork) {
|
||||
mNetworkRequestInfo = networkRequestInfo;
|
||||
@@ -7280,14 +7306,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
private void updateSatisfiersForRematchRequest(@NonNull final NetworkRequestInfo nri,
|
||||
@NonNull final NetworkRequest previousRequest,
|
||||
@NonNull final NetworkRequest newRequest,
|
||||
@Nullable final NetworkRequest previousRequest,
|
||||
@Nullable final NetworkRequest newRequest,
|
||||
@Nullable final NetworkAgentInfo previousSatisfier,
|
||||
@Nullable final NetworkAgentInfo newSatisfier,
|
||||
final long now) {
|
||||
if (null != newSatisfier && mNoServiceNetwork != newSatisfier) {
|
||||
if (VDBG) log("rematch for " + newSatisfier.toShortString());
|
||||
if (null != previousSatisfier && mNoServiceNetwork != previousSatisfier) {
|
||||
if (null != previousRequest && null != previousSatisfier) {
|
||||
if (VDBG || DDBG) {
|
||||
log(" accepting network in place of " + previousSatisfier.toShortString());
|
||||
}
|
||||
@@ -7310,7 +7336,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
Log.wtf(TAG, "BUG: " + newSatisfier.toShortString() + " already has "
|
||||
+ newRequest);
|
||||
}
|
||||
} else if (null != previousSatisfier) {
|
||||
} else if (null != previousRequest && null != previousSatisfier) {
|
||||
if (DBG) {
|
||||
log("Network " + previousSatisfier.toShortString() + " stopped satisfying"
|
||||
+ " request " + previousRequest.requestId);
|
||||
|
||||
Reference in New Issue
Block a user