am 89c8f755: Merge "Fix handling of multiple possible default networks" into honeycomb
* commit '89c8f7554bbec5d62ebeddddc2ef2460265a80c5': Fix handling of multiple possible default networks
This commit is contained in:
@@ -1132,11 +1132,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns null if no failover available
|
// returns null if no failover available, otherwise returns the highest
|
||||||
|
// priority network we're trying
|
||||||
private NetworkStateTracker tryFailover(int prevNetType) {
|
private NetworkStateTracker tryFailover(int prevNetType) {
|
||||||
/*
|
/*
|
||||||
* If this is a default network, check if other defaults are available
|
* If this is a default network, check if other defaults are available.
|
||||||
* or active
|
* Try to reconnect on all available and let them hash it out when
|
||||||
|
* more than one connects.
|
||||||
*/
|
*/
|
||||||
NetworkStateTracker newNet = null;
|
NetworkStateTracker newNet = null;
|
||||||
if (mNetAttributes[prevNetType].isDefault()) {
|
if (mNetAttributes[prevNetType].isDefault()) {
|
||||||
@@ -1149,54 +1151,30 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
|
||||||
if (checkType == prevNetType) continue;
|
if (checkType == prevNetType) continue;
|
||||||
if (mNetAttributes[checkType] == null) continue;
|
if (mNetAttributes[checkType] == null) continue;
|
||||||
if (mNetAttributes[checkType].isDefault()) {
|
if (!mNetAttributes[checkType].isDefault()) continue;
|
||||||
/* TODO - if we have multiple nets we could use
|
if (!mNetTrackers[checkType].isAvailable()) continue;
|
||||||
* we may want to put more thought into which we choose
|
|
||||||
*/
|
|
||||||
if (checkType == mNetworkPreference) {
|
|
||||||
newType = checkType;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mNetAttributes[checkType].mPriority > newPriority) {
|
|
||||||
newType = checkType;
|
|
||||||
newPriority = mNetAttributes[newType].mPriority;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newType != -1) {
|
NetworkStateTracker tracker = mNetTrackers[checkType];
|
||||||
newNet = mNetTrackers[newType];
|
NetworkInfo info = tracker.getNetworkInfo();
|
||||||
/**
|
if (!info.isConnectedOrConnecting() ||
|
||||||
* See if the other network is available to fail over to.
|
tracker.isTeardownRequested()) {
|
||||||
* If is not available, we enable it anyway, so that it
|
info.setFailover(true);
|
||||||
* will be able to connect when it does become available,
|
tracker.reconnect();
|
||||||
* but we report a total loss of connectivity rather than
|
}
|
||||||
* report that we are attempting to fail over.
|
if (DBG) log("Attempting to switch to " + info.getTypeName());
|
||||||
*/
|
|
||||||
if (newNet.isAvailable()) {
|
// figure out if this is the highest priority network
|
||||||
NetworkInfo switchTo = newNet.getNetworkInfo();
|
// so we send an appropriate return value
|
||||||
switchTo.setFailover(true);
|
if (checkType == mNetworkPreference) {
|
||||||
if (!switchTo.isConnectedOrConnecting() ||
|
newType = checkType;
|
||||||
newNet.isTeardownRequested()) {
|
}
|
||||||
newNet.reconnect();
|
if (mNetAttributes[checkType].mPriority > newPriority &&
|
||||||
}
|
newType != mNetworkPreference) {
|
||||||
if (DBG) {
|
newType = checkType;
|
||||||
if (switchTo.isConnected()) {
|
newPriority = mNetAttributes[newType].mPriority;
|
||||||
log("Switching to already connected " + switchTo.getTypeName());
|
|
||||||
} else {
|
|
||||||
log("Attempting to switch to " + switchTo.getTypeName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newNet.reconnect();
|
|
||||||
newNet = null; // not officially avail.. try anyway, but
|
|
||||||
// report no failover
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
loge("Network failover failing.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newNet;
|
return newNet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user