am 1ea7e5df: am a78e9f05: Merge "Fix any_connection reporting." into honeycomb

* commit '1ea7e5df91f023d03fa7c87c534e6024795abaaa':
  Fix any_connection reporting.
This commit is contained in:
Robert Greenwalt
2011-01-12 07:21:32 -08:00
committed by Android Git Automerger

View File

@@ -1100,18 +1100,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
@@ -1127,56 +1119,46 @@ 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, otherwise returns the highest private void tryFailover(int prevNetType) {
// priority network we're trying
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.
* Try to reconnect on all available and let them hash it out when * Try to reconnect on all available and let them hash it out when
* more than one connects. * more than one connects.
*/ */
NetworkStateTracker newNet = null;
if (mNetAttributes[prevNetType].isDefault()) { if (mNetAttributes[prevNetType].isDefault()) {
if (mActiveDefaultNetwork == prevNetType) { if (mActiveDefaultNetwork == prevNetType) {
mActiveDefaultNetwork = -1; mActiveDefaultNetwork = -1;
} }
int newType = -1; // don't signal a reconnect for anything lower or equal priority than our
int newPriority = -1; // current connected default
// TODO - don't filter by priority now - nice optimization but risky
// int currentPriority = -1;
// if (mActiveDefaultNetwork != -1) {
// currentPriority = mNetAttributes[mActiveDefaultNetwork].mPriority;
// }
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()) continue; if (!mNetAttributes[checkType].isDefault()) continue;
if (!mNetTrackers[checkType].isAvailable()) continue; if (!mNetTrackers[checkType].isAvailable()) continue;
// if (currentPriority >= mNetAttributes[checkType].mPriority) 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) log("Attempting to switch to " + info.getTypeName()); if (DBG) log("Attempting to switch to " + checkInfo.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[newType].mPriority;
} }
} }
} }
return newNet;
}
private void sendConnectedBroadcast(NetworkInfo info) { private void sendConnectedBroadcast(NetworkInfo info) {
sendGeneralBroadcast(info, ConnectivityManager.CONNECTIVITY_ACTION); sendGeneralBroadcast(info, ConnectivityManager.CONNECTIVITY_ACTION);
@@ -1238,17 +1220,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;
@@ -1262,8 +1237,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());
} }
} }