am 3259d885: Merge "DO NOT MERGE - backport of l92a02b31 from master" into gingerbread

* commit '3259d8853760a72b811757e1711119d041962a1c':
  DO NOT MERGE - backport of l92a02b31 from master
This commit is contained in:
Robert Greenwalt
2011-02-16 10:51:04 -08:00
committed by Android Git Automerger

View File

@@ -1068,59 +1068,32 @@ 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() == false) continue;
if (mNetAttributes[checkType].mRadio == ConnectivityManager.TYPE_MOBILE && if (mNetAttributes[checkType].mRadio == ConnectivityManager.TYPE_MOBILE &&
noMobileData) { noMobileData) {
Slog.e(TAG, "not failing over to mobile type " + checkType + Slog.e(TAG, "not failing over to mobile type " + checkType +
" because Mobile Data Disabled"); " because Mobile Data Disabled");
continue; continue;
} }
if (mNetAttributes[checkType].isDefault()) { NetworkStateTracker tracker = mNetTrackers[checkType];
/* TODO - if we have multiple nets we could use NetworkInfo info = tracker.getNetworkInfo();
* we may want to put more thought into which we choose if (!info.isConnectedOrConnecting() ||
*/ tracker.isTeardownRequested()) {
if (checkType == mNetworkPreference) { info.setFailover(true);
newType = checkType; tracker.reconnect();
break;
}
if (mNetAttributes[checkType].mPriority > newPriority) {
newType = checkType;
newPriority = mNetAttributes[newType].mPriority;
}
} }
} if (DBG) Slog.d(TAG, "Attempting to switch to " + info.getTypeName());
if (newType != -1) { // figure out if this is the highest priority network
newNet = mNetTrackers[newType]; // so we send an appropriate return value
/** if (checkType == mNetworkPreference) {
* See if the other network is available to fail over to. newType = checkType;
* If is not available, we enable it anyway, so that it }
* will be able to connect when it does become available, if (mNetAttributes[checkType].mPriority > newPriority &&
* but we report a total loss of connectivity rather than newType != mNetworkPreference) {
* report that we are attempting to fail over. newType = checkType;
*/ newPriority = mNetAttributes[checkType].mPriority;
if (newNet.isAvailable()) {
NetworkInfo switchTo = newNet.getNetworkInfo();
switchTo.setFailover(true);
if (!switchTo.isConnectedOrConnecting() ||
newNet.isTeardownRequested()) {
newNet.reconnect();
}
if (DBG) {
if (switchTo.isConnected()) {
Slog.v(TAG, "Switching to already connected " +
switchTo.getTypeName());
} else {
Slog.v(TAG, "Attempting to switch to " +
switchTo.getTypeName());
}
}
} else {
newNet.reconnect();
newNet = null; // not officially avail.. try anyway, but
// report no failover
} }
} else {
Slog.e(TAG, "Network failover failing.");
} }
} }