Merge changes I493b969c,I7b759425,I60fe318a,Ie4ae6a97,I2379e47b, ...
am: e2427502f1 Change-Id: Ic5b59cb5e23feaf7aac0075f16afa3da94d3628c
This commit is contained in:
@@ -146,6 +146,7 @@ import android.security.Credentials;
|
|||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.ArrayMap;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.LocalLog;
|
import android.util.LocalLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -3050,7 +3051,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleAsyncChannelHalfConnect(Message msg) {
|
private void handleAsyncChannelHalfConnect(Message msg) {
|
||||||
AsyncChannel ac = (AsyncChannel) msg.obj;
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
final AsyncChannel ac = (AsyncChannel) msg.obj;
|
||||||
if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
|
if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
|
||||||
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
|
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
|
||||||
if (VDBG) log("NetworkFactory connected");
|
if (VDBG) log("NetworkFactory connected");
|
||||||
@@ -3060,7 +3062,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// A network factory has connected. Send it all current NetworkRequests.
|
// A network factory has connected. Send it all current NetworkRequests.
|
||||||
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
||||||
if (nri.request.isListen()) continue;
|
if (nri.request.isListen()) continue;
|
||||||
NetworkAgentInfo nai = getNetworkForRequest(nri.request.requestId);
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
NetworkAgentInfo nai = nri.mSatisfier;
|
||||||
final int score;
|
final int score;
|
||||||
final int serial;
|
final int serial;
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
@@ -3116,6 +3119,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// ConnectivityService, free its interfaces and clean up.
|
// ConnectivityService, free its interfaces and clean up.
|
||||||
// Must be called on the Handler thread.
|
// Must be called on the Handler thread.
|
||||||
private void disconnectAndDestroyNetwork(NetworkAgentInfo nai) {
|
private void disconnectAndDestroyNetwork(NetworkAgentInfo nai) {
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log(nai.name() + " got DISCONNECTED, was satisfying " + nai.numNetworkRequests());
|
log(nai.name() + " got DISCONNECTED, was satisfying " + nai.numNetworkRequests());
|
||||||
}
|
}
|
||||||
@@ -3162,14 +3166,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// Remove all previously satisfied requests.
|
// Remove all previously satisfied requests.
|
||||||
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
||||||
NetworkRequest request = nai.requestAt(i);
|
NetworkRequest request = nai.requestAt(i);
|
||||||
NetworkAgentInfo currentNetwork = getNetworkForRequest(request.requestId);
|
final NetworkRequestInfo nri = mNetworkRequests.get(request);
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
final NetworkAgentInfo currentNetwork = nri.mSatisfier;
|
||||||
if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) {
|
if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) {
|
||||||
clearNetworkForRequest(request.requestId);
|
nri.mSatisfier = null;
|
||||||
sendUpdatedScoreToFactories(request, null);
|
sendUpdatedScoreToFactories(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nai.clearLingerState();
|
nai.clearLingerState();
|
||||||
if (nai.isSatisfyingRequest(mDefaultRequest.requestId)) {
|
if (nai.isSatisfyingRequest(mDefaultRequest.requestId)) {
|
||||||
|
mDefaultNetworkNai = null;
|
||||||
updateDataActivityTracking(null /* newNetwork */, nai);
|
updateDataActivityTracking(null /* newNetwork */, nai);
|
||||||
notifyLockdownVpn(nai);
|
notifyLockdownVpn(nai);
|
||||||
ensureNetworkTransitionWakelock(nai.name());
|
ensureNetworkTransitionWakelock(nai.name());
|
||||||
@@ -3253,6 +3260,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleRegisterNetworkRequest(NetworkRequestInfo nri) {
|
private void handleRegisterNetworkRequest(NetworkRequestInfo nri) {
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
mNetworkRequests.put(nri.request, nri);
|
mNetworkRequests.put(nri.request, nri);
|
||||||
mNetworkRequestInfoLogs.log("REGISTER " + nri);
|
mNetworkRequestInfoLogs.log("REGISTER " + nri);
|
||||||
if (nri.request.isListen()) {
|
if (nri.request.isListen()) {
|
||||||
@@ -3264,7 +3272,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rematchAllNetworksAndRequests(null, 0);
|
rematchAllNetworksAndRequests(null, 0);
|
||||||
if (nri.request.isRequest() && getNetworkForRequest(nri.request.requestId) == null) {
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
if (nri.request.isRequest() && nri.mSatisfier == null) {
|
||||||
sendUpdatedScoreToFactories(nri.request, null);
|
sendUpdatedScoreToFactories(nri.request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3286,6 +3295,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// - UnneededFor.LINGER: foreground NetworkRequests. If a network is unneeded for this reason,
|
// - UnneededFor.LINGER: foreground NetworkRequests. If a network is unneeded for this reason,
|
||||||
// then it should be lingered.
|
// then it should be lingered.
|
||||||
private boolean unneeded(NetworkAgentInfo nai, UnneededFor reason) {
|
private boolean unneeded(NetworkAgentInfo nai, UnneededFor reason) {
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
final int numRequests;
|
final int numRequests;
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case TEARDOWN:
|
case TEARDOWN:
|
||||||
@@ -3310,6 +3320,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
// If this Network is already the highest scoring Network for a request, or if
|
// If this Network is already the highest scoring Network for a request, or if
|
||||||
// there is hope for it to become one if it validated, then it is needed.
|
// there is hope for it to become one if it validated, then it is needed.
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
if (nri.request.isRequest() && nai.satisfies(nri.request) &&
|
if (nri.request.isRequest() && nai.satisfies(nri.request) &&
|
||||||
(nai.isSatisfyingRequest(nri.request.requestId) ||
|
(nai.isSatisfyingRequest(nri.request.requestId) ||
|
||||||
// Note that this catches two important cases:
|
// Note that this catches two important cases:
|
||||||
@@ -3319,8 +3330,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// 2. Unvalidated WiFi will not be reaped when validated cellular
|
// 2. Unvalidated WiFi will not be reaped when validated cellular
|
||||||
// is currently satisfying the request. This is desirable when
|
// is currently satisfying the request. This is desirable when
|
||||||
// WiFi ends up validating and out scoring cellular.
|
// WiFi ends up validating and out scoring cellular.
|
||||||
getNetworkForRequest(nri.request.requestId).getCurrentScore() <
|
nri.mSatisfier.getCurrentScore()
|
||||||
nai.getCurrentScoreAsValidated())) {
|
< nai.getCurrentScoreAsValidated())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3344,10 +3355,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleTimedOutNetworkRequest(final NetworkRequestInfo nri) {
|
private void handleTimedOutNetworkRequest(final NetworkRequestInfo nri) {
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
if (mNetworkRequests.get(nri.request) == null) {
|
if (mNetworkRequests.get(nri.request) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getNetworkForRequest(nri.request.requestId) != null) {
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
if (nri.mSatisfier != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (VDBG || (DBG && nri.request.isRequest())) {
|
if (VDBG || (DBG && nri.request.isRequest())) {
|
||||||
@@ -3374,6 +3387,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleRemoveNetworkRequest(final NetworkRequestInfo nri) {
|
private void handleRemoveNetworkRequest(final NetworkRequestInfo nri) {
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
|
||||||
nri.unlinkDeathRecipient();
|
nri.unlinkDeathRecipient();
|
||||||
mNetworkRequests.remove(nri.request);
|
mNetworkRequests.remove(nri.request);
|
||||||
|
|
||||||
@@ -3393,7 +3408,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
||||||
if (nri.request.isRequest()) {
|
if (nri.request.isRequest()) {
|
||||||
boolean wasKept = false;
|
boolean wasKept = false;
|
||||||
NetworkAgentInfo nai = getNetworkForRequest(nri.request.requestId);
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
final NetworkAgentInfo nai = nri.mSatisfier;
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
boolean wasBackgroundNetwork = nai.isBackgroundNetwork();
|
boolean wasBackgroundNetwork = nai.isBackgroundNetwork();
|
||||||
nai.removeRequest(nri.request.requestId);
|
nai.removeRequest(nri.request.requestId);
|
||||||
@@ -3410,7 +3426,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
} else {
|
} else {
|
||||||
wasKept = true;
|
wasKept = true;
|
||||||
}
|
}
|
||||||
clearNetworkForRequest(nri.request.requestId);
|
nri.mSatisfier = null;
|
||||||
if (!wasBackgroundNetwork && nai.isBackgroundNetwork()) {
|
if (!wasBackgroundNetwork && nai.isBackgroundNetwork()) {
|
||||||
// Went from foreground to background.
|
// Went from foreground to background.
|
||||||
updateCapabilities(nai.getCurrentScore(), nai, nai.networkCapabilities);
|
updateCapabilities(nai.getCurrentScore(), nai, nai.networkCapabilities);
|
||||||
@@ -5093,6 +5109,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
*/
|
*/
|
||||||
private class NetworkRequestInfo implements IBinder.DeathRecipient {
|
private class NetworkRequestInfo implements IBinder.DeathRecipient {
|
||||||
final NetworkRequest request;
|
final NetworkRequest request;
|
||||||
|
// The network currently satisfying this request, or null if none. Must only be touched
|
||||||
|
// on the handler thread. This only makes sense for network requests and not for listens,
|
||||||
|
// as defined by NetworkRequest#isRequest(). For listens, this is always null.
|
||||||
|
@Nullable
|
||||||
|
NetworkAgentInfo mSatisfier;
|
||||||
final PendingIntent mPendingIntent;
|
final PendingIntent mPendingIntent;
|
||||||
boolean mPendingIntentSent;
|
boolean mPendingIntentSent;
|
||||||
private final IBinder mBinder;
|
private final IBinder mBinder;
|
||||||
@@ -5479,16 +5500,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (DBG) log("unregisterNetworkFactory for " + nfi.name);
|
if (DBG) log("unregisterNetworkFactory for " + nfi.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* NetworkAgentInfo supporting a request by requestId.
|
|
||||||
* These have already been vetted (their Capabilities satisfy the request)
|
|
||||||
* and the are the highest scored network available.
|
|
||||||
* the are keyed off the Requests requestId.
|
|
||||||
*/
|
|
||||||
// NOTE: Accessed on multiple threads, must be synchronized on itself.
|
|
||||||
@GuardedBy("mNetworkForRequestId")
|
|
||||||
private final SparseArray<NetworkAgentInfo> mNetworkForRequestId = new SparseArray<>();
|
|
||||||
|
|
||||||
// NOTE: Accessed on multiple threads, must be synchronized on itself.
|
// NOTE: Accessed on multiple threads, must be synchronized on itself.
|
||||||
@GuardedBy("mNetworkForNetId")
|
@GuardedBy("mNetworkForNetId")
|
||||||
private final SparseArray<NetworkAgentInfo> mNetworkForNetId = new SparseArray<>();
|
private final SparseArray<NetworkAgentInfo> mNetworkForNetId = new SparseArray<>();
|
||||||
@@ -5506,7 +5517,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private final HashSet<Integer> mBlockedAppUids = new HashSet<>();
|
private final HashSet<Integer> mBlockedAppUids = new HashSet<>();
|
||||||
|
|
||||||
// Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated.
|
// Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated.
|
||||||
|
@NonNull
|
||||||
private final NetworkRequest mDefaultRequest;
|
private final NetworkRequest mDefaultRequest;
|
||||||
|
// The NetworkAgentInfo currently satisfying the default request, if any.
|
||||||
|
@Nullable
|
||||||
|
private volatile NetworkAgentInfo mDefaultNetworkNai = null;
|
||||||
|
|
||||||
// Request used to optionally keep mobile data active even when higher
|
// Request used to optionally keep mobile data active even when higher
|
||||||
// priority networks like Wi-Fi are active.
|
// priority networks like Wi-Fi are active.
|
||||||
@@ -5516,26 +5531,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// priority networks like ethernet are active.
|
// priority networks like ethernet are active.
|
||||||
private final NetworkRequest mDefaultWifiRequest;
|
private final NetworkRequest mDefaultWifiRequest;
|
||||||
|
|
||||||
private NetworkAgentInfo getNetworkForRequest(int requestId) {
|
|
||||||
synchronized (mNetworkForRequestId) {
|
|
||||||
return mNetworkForRequestId.get(requestId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearNetworkForRequest(int requestId) {
|
|
||||||
synchronized (mNetworkForRequestId) {
|
|
||||||
mNetworkForRequestId.remove(requestId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setNetworkForRequest(int requestId, NetworkAgentInfo nai) {
|
|
||||||
synchronized (mNetworkForRequestId) {
|
|
||||||
mNetworkForRequestId.put(requestId, nai);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private NetworkAgentInfo getDefaultNetwork() {
|
private NetworkAgentInfo getDefaultNetwork() {
|
||||||
return getNetworkForRequest(mDefaultRequest.requestId);
|
return mDefaultNetworkNai;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -6253,7 +6250,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeDefault(NetworkAgentInfo newNetwork) {
|
private void makeDefault(@NonNull final NetworkAgentInfo newNetwork) {
|
||||||
if (DBG) log("Switching to new default network: " + newNetwork);
|
if (DBG) log("Switching to new default network: " + newNetwork);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -6262,6 +6259,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
loge("Exception setting default network :" + e);
|
loge("Exception setting default network :" + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaultNetworkNai = newNetwork;
|
||||||
notifyLockdownVpn(newNetwork);
|
notifyLockdownVpn(newNetwork);
|
||||||
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
|
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
|
||||||
updateTcpBufferSizes(newNetwork.linkProperties.getTcpBufferSizes());
|
updateTcpBufferSizes(newNetwork.linkProperties.getTcpBufferSizes());
|
||||||
@@ -6325,6 +6323,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// validated) of becoming the highest scoring network.
|
// validated) of becoming the highest scoring network.
|
||||||
private void rematchNetworkAndRequests(NetworkAgentInfo newNetwork,
|
private void rematchNetworkAndRequests(NetworkAgentInfo newNetwork,
|
||||||
ReapUnvalidatedNetworks reapUnvalidatedNetworks, long now) {
|
ReapUnvalidatedNetworks reapUnvalidatedNetworks, long now) {
|
||||||
|
ensureRunningOnConnectivityServiceThread();
|
||||||
if (!newNetwork.everConnected) return;
|
if (!newNetwork.everConnected) return;
|
||||||
boolean keep = newNetwork.isVPN();
|
boolean keep = newNetwork.isVPN();
|
||||||
boolean isNewDefault = false;
|
boolean isNewDefault = false;
|
||||||
@@ -6335,10 +6334,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
if (VDBG || DDBG) log("rematching " + newNetwork.name());
|
if (VDBG || DDBG) log("rematching " + newNetwork.name());
|
||||||
|
|
||||||
|
final ArrayMap<NetworkRequestInfo, NetworkAgentInfo> reassignedRequests = new ArrayMap<>();
|
||||||
|
|
||||||
// Find and migrate to this Network any NetworkRequests for
|
// Find and migrate to this Network any NetworkRequests for
|
||||||
// which this network is now the best.
|
// which this network is now the best.
|
||||||
ArrayList<NetworkAgentInfo> affectedNetworks = new ArrayList<>();
|
final ArrayList<NetworkAgentInfo> removedRequests = new ArrayList<>();
|
||||||
ArrayList<NetworkRequestInfo> addedRequests = new ArrayList<>();
|
final ArrayList<NetworkRequestInfo> addedRequests = new ArrayList<>();
|
||||||
NetworkCapabilities nc = newNetwork.networkCapabilities;
|
NetworkCapabilities nc = newNetwork.networkCapabilities;
|
||||||
if (VDBG) log(" network has: " + nc);
|
if (VDBG) log(" network has: " + nc);
|
||||||
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
||||||
@@ -6348,16 +6349,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// requests or not, and doesn't affect the network's score.
|
// requests or not, and doesn't affect the network's score.
|
||||||
if (nri.request.isListen()) continue;
|
if (nri.request.isListen()) continue;
|
||||||
|
|
||||||
final NetworkAgentInfo currentNetwork = getNetworkForRequest(nri.request.requestId);
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
final NetworkAgentInfo currentNetwork = nri.mSatisfier;
|
||||||
final boolean satisfies = newNetwork.satisfies(nri.request);
|
final boolean satisfies = newNetwork.satisfies(nri.request);
|
||||||
if (newNetwork == currentNetwork && satisfies) {
|
if (newNetwork == currentNetwork && satisfies) continue;
|
||||||
if (VDBG) {
|
|
||||||
log("Network " + newNetwork.name() + " was already satisfying" +
|
|
||||||
" request " + nri.request.requestId + ". No change.");
|
|
||||||
}
|
|
||||||
keep = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if it satisfies the NetworkCapabilities
|
// check if it satisfies the NetworkCapabilities
|
||||||
if (VDBG) log(" checking if request is satisfied: " + nri.request);
|
if (VDBG) log(" checking if request is satisfied: " + nri.request);
|
||||||
@@ -6370,6 +6365,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
", newScore = " + score);
|
", newScore = " + score);
|
||||||
}
|
}
|
||||||
if (currentNetwork == null || currentNetwork.getCurrentScore() < score) {
|
if (currentNetwork == null || currentNetwork.getCurrentScore() < score) {
|
||||||
|
reassignedRequests.put(nri, newNetwork);
|
||||||
if (VDBG) log("rematch for " + newNetwork.name());
|
if (VDBG) log("rematch for " + newNetwork.name());
|
||||||
if (currentNetwork != null) {
|
if (currentNetwork != null) {
|
||||||
if (VDBG || DDBG){
|
if (VDBG || DDBG){
|
||||||
@@ -6377,12 +6373,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
currentNetwork.removeRequest(nri.request.requestId);
|
currentNetwork.removeRequest(nri.request.requestId);
|
||||||
currentNetwork.lingerRequest(nri.request, now, mLingerDelayMs);
|
currentNetwork.lingerRequest(nri.request, now, mLingerDelayMs);
|
||||||
affectedNetworks.add(currentNetwork);
|
removedRequests.add(currentNetwork);
|
||||||
} else {
|
} else {
|
||||||
if (VDBG || DDBG) log(" accepting network in place of null");
|
if (VDBG || DDBG) log(" accepting network in place of null");
|
||||||
}
|
}
|
||||||
newNetwork.unlingerRequest(nri.request);
|
newNetwork.unlingerRequest(nri.request);
|
||||||
setNetworkForRequest(nri.request.requestId, newNetwork);
|
nri.mSatisfier = newNetwork;
|
||||||
if (!newNetwork.addRequest(nri.request)) {
|
if (!newNetwork.addRequest(nri.request)) {
|
||||||
Slog.wtf(TAG, "BUG: " + newNetwork.name() + " already has " + nri.request);
|
Slog.wtf(TAG, "BUG: " + newNetwork.name() + " already has " + nri.request);
|
||||||
}
|
}
|
||||||
@@ -6403,6 +6399,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (newNetwork.isSatisfyingRequest(nri.request.requestId)) {
|
} else if (newNetwork.isSatisfyingRequest(nri.request.requestId)) {
|
||||||
|
reassignedRequests.put(nri, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final Map.Entry<NetworkRequestInfo, NetworkAgentInfo> entry :
|
||||||
|
reassignedRequests.entrySet()) {
|
||||||
|
final NetworkRequestInfo nri = entry.getKey();
|
||||||
|
final NetworkAgentInfo previousSatisfier = nri.mSatisfier;
|
||||||
|
final NetworkAgentInfo newSatisfier = entry.getValue();
|
||||||
|
if (newSatisfier == null) {
|
||||||
// If "newNetwork" is listed as satisfying "nri" but no longer satisfies "nri",
|
// If "newNetwork" is listed as satisfying "nri" but no longer satisfies "nri",
|
||||||
// mark it as no longer satisfying "nri". Because networks are processed by
|
// mark it as no longer satisfying "nri". Because networks are processed by
|
||||||
// rematchAllNetworksAndRequests() in descending score order, "currentNetwork" will
|
// rematchAllNetworksAndRequests() in descending score order, "currentNetwork" will
|
||||||
@@ -6415,13 +6421,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
" request " + nri.request.requestId);
|
" request " + nri.request.requestId);
|
||||||
}
|
}
|
||||||
newNetwork.removeRequest(nri.request.requestId);
|
newNetwork.removeRequest(nri.request.requestId);
|
||||||
if (currentNetwork == newNetwork) {
|
if (previousSatisfier == newNetwork) {
|
||||||
clearNetworkForRequest(nri.request.requestId);
|
nri.mSatisfier = null;
|
||||||
|
if (isDefaultRequest(nri)) mDefaultNetworkNai = null;
|
||||||
sendUpdatedScoreToFactories(nri.request, null);
|
sendUpdatedScoreToFactories(nri.request, null);
|
||||||
} else {
|
} else {
|
||||||
Slog.wtf(TAG, "BUG: Removing request " + nri.request.requestId + " from " +
|
Slog.wtf(TAG, "BUG: Removing request " + nri.request.requestId + " from " +
|
||||||
newNetwork.name() +
|
newNetwork.name() +
|
||||||
" without updating mNetworkForRequestId or factories!");
|
" without updating mSatisfier or factories!");
|
||||||
}
|
}
|
||||||
// TODO: Technically, sending CALLBACK_LOST here is
|
// TODO: Technically, sending CALLBACK_LOST here is
|
||||||
// incorrect if there is a replacement network currently
|
// incorrect if there is a replacement network currently
|
||||||
@@ -6433,6 +6440,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
callCallbackForRequest(nri, newNetwork, ConnectivityManager.CALLBACK_LOST, 0);
|
callCallbackForRequest(nri, newNetwork, ConnectivityManager.CALLBACK_LOST, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNewDefault) {
|
if (isNewDefault) {
|
||||||
updateDataActivityTracking(newNetwork, oldDefaultNetwork);
|
updateDataActivityTracking(newNetwork, oldDefaultNetwork);
|
||||||
// Notify system services that this network is up.
|
// Notify system services that this network is up.
|
||||||
@@ -6472,7 +6480,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
// Linger any networks that are no longer needed. This should be done after sending the
|
// Linger any networks that are no longer needed. This should be done after sending the
|
||||||
// available callback for newNetwork.
|
// available callback for newNetwork.
|
||||||
for (NetworkAgentInfo nai : affectedNetworks) {
|
for (NetworkAgentInfo nai : removedRequests) {
|
||||||
updateLingerState(nai, now);
|
updateLingerState(nai, now);
|
||||||
}
|
}
|
||||||
// Possibly unlinger newNetwork. Unlingering a network does not send any callbacks so it
|
// Possibly unlinger newNetwork. Unlingering a network does not send any callbacks so it
|
||||||
|
|||||||
Reference in New Issue
Block a user