am b5c51d5f: Merge "DO NOT MERGE Backport of I1f55df8a from master." into gingerbread

* commit 'b5c51d5fa88c56ebbfb56af89beb077aa4f1f2f8':
  DO NOT MERGE Backport of I1f55df8a from master.
This commit is contained in:
Robert Greenwalt
2011-03-11 11:52:31 -08:00
committed by Android Git Automerger

View File

@@ -1120,18 +1120,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
info.getExtraInfo()); info.getExtraInfo());
} }
NetworkStateTracker newNet = null;
if (mNetAttributes[prevNetType].isDefault()) { if (mNetAttributes[prevNetType].isDefault()) {
newNet = tryFailover(prevNetType); tryFailover(prevNetType);
if (newNet != null) { if (mActiveDefaultNetwork != -1) {
NetworkInfo switchTo = newNet.getNetworkInfo(); NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
if (!switchTo.isConnected()) {
// if the other net is connected they've already reset this and perhaps even gotten
// a positive report we don't want to overwrite, but if not we need to clear this now
// to turn our cellular sig strength white
mDefaultInetConditionPublished = 0;
intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true);
}
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo); intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
} else { } else {
mDefaultInetConditionPublished = 0; // we're not connected anymore mDefaultInetConditionPublished = 0; // we're not connected anymore
@@ -1147,25 +1139,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* If the failover network is already connected, then immediately send * If the failover network is already connected, then immediately send
* out a followup broadcast indicating successful failover * out a followup broadcast indicating successful failover
*/ */
if (newNet != null && newNet.getNetworkInfo().isConnected()) { if (mActiveDefaultNetwork != -1) {
sendConnectedBroadcast(newNet.getNetworkInfo()); sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
} }
} }
// returns null if no failover available private void 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 * or active
*/ */
NetworkStateTracker newNet = null;
if (mNetAttributes[prevNetType].isDefault()) { if (mNetAttributes[prevNetType].isDefault()) {
if (mActiveDefaultNetwork == prevNetType) { if (mActiveDefaultNetwork == prevNetType) {
mActiveDefaultNetwork = -1; mActiveDefaultNetwork = -1;
} }
int newType = -1;
int newPriority = -1;
boolean noMobileData = !getMobileDataEnabled(); boolean noMobileData = !getMobileDataEnabled();
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;
@@ -1177,29 +1165,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
" because Mobile Data Disabled"); " because Mobile Data Disabled");
continue; continue;
} }
NetworkStateTracker tracker = mNetTrackers[checkType]; NetworkStateTracker checkTracker = mNetTrackers[checkType];
NetworkInfo info = tracker.getNetworkInfo(); NetworkInfo checkInfo = checkTracker.getNetworkInfo();
if (!info.isConnectedOrConnecting() || if (!checkInfo.isConnectedOrConnecting() || checkTracker.isTeardownRequested()) {
tracker.isTeardownRequested()) { checkInfo.setFailover(true);
info.setFailover(true); checkTracker.reconnect();
tracker.reconnect();
}
if (DBG) Slog.d(TAG, "Attempting to switch to " + info.getTypeName());
// figure out if this is the highest priority network
// so we send an appropriate return value
if (checkType == mNetworkPreference) {
newType = checkType;
}
if (mNetAttributes[checkType].mPriority > newPriority &&
newType != mNetworkPreference) {
newType = checkType;
newPriority = mNetAttributes[checkType].mPriority;
} }
if (DBG) Slog.d(TAG, "Attempting to switch to " + checkInfo.getTypeName());
} }
} }
return newNet;
} }
private void sendConnectedBroadcast(NetworkInfo info) { private void sendConnectedBroadcast(NetworkInfo info) {
@@ -1262,17 +1236,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
info.setFailover(false); info.setFailover(false);
} }
NetworkStateTracker newNet = null;
if (mNetAttributes[info.getType()].isDefault()) { if (mNetAttributes[info.getType()].isDefault()) {
newNet = tryFailover(info.getType()); tryFailover(info.getType());
if (newNet != null) { if (mActiveDefaultNetwork != -1) {
NetworkInfo switchTo = newNet.getNetworkInfo(); NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
if (!switchTo.isConnected()) {
// if the other net is connected they've already reset this and perhaps
// even gotten a positive report we don't want to overwrite, but if not
// we need to clear this now to turn our cellular sig strength white
mDefaultInetConditionPublished = 0;
}
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo); intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
} else { } else {
mDefaultInetConditionPublished = 0; mDefaultInetConditionPublished = 0;
@@ -1286,8 +1253,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* If the failover network is already connected, then immediately send * If the failover network is already connected, then immediately send
* out a followup broadcast indicating successful failover * out a followup broadcast indicating successful failover
*/ */
if (newNet != null && newNet.getNetworkInfo().isConnected()) { if (mActiveDefaultNetwork != -1) {
sendConnectedBroadcast(newNet.getNetworkInfo()); sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
} }
} }