summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-03-11 11:52:31 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-03-11 11:52:31 -0800
commit2e7415564ad1d77537f9f3d5151ed480fcfc6ef9 (patch)
tree3a84ca0bcb486f9319573660f1fa3fa4d0063b93 /services
parent38d0d5628d36bb1c2a8353a2b3e1a041e9e84652 (diff)
parentb5c51d5fa88c56ebbfb56af89beb077aa4f1f2f8 (diff)
downloadframeworks_base-2e7415564ad1d77537f9f3d5151ed480fcfc6ef9.zip
frameworks_base-2e7415564ad1d77537f9f3d5151ed480fcfc6ef9.tar.gz
frameworks_base-2e7415564ad1d77537f9f3d5151ed480fcfc6ef9.tar.bz2
am b5c51d5f: Merge "DO NOT MERGE Backport of I1f55df8a from master." into gingerbread
* commit 'b5c51d5fa88c56ebbfb56af89beb077aa4f1f2f8': DO NOT MERGE Backport of I1f55df8a from master.
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/ConnectivityService.java67
1 files changed, 17 insertions, 50 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index a3694fe..97fd804 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1120,18 +1120,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
info.getExtraInfo());
}
- NetworkStateTracker newNet = null;
if (mNetAttributes[prevNetType].isDefault()) {
- newNet = tryFailover(prevNetType);
- if (newNet != null) {
- NetworkInfo switchTo = newNet.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);
- }
+ tryFailover(prevNetType);
+ if (mActiveDefaultNetwork != -1) {
+ NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
} else {
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
* out a followup broadcast indicating successful failover
*/
- if (newNet != null && newNet.getNetworkInfo().isConnected()) {
- sendConnectedBroadcast(newNet.getNetworkInfo());
+ if (mActiveDefaultNetwork != -1) {
+ sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
}
}
- // returns null if no failover available
- private NetworkStateTracker tryFailover(int prevNetType) {
+ private void tryFailover(int prevNetType) {
/*
* If this is a default network, check if other defaults are available
* or active
*/
- NetworkStateTracker newNet = null;
if (mNetAttributes[prevNetType].isDefault()) {
if (mActiveDefaultNetwork == prevNetType) {
mActiveDefaultNetwork = -1;
}
- int newType = -1;
- int newPriority = -1;
boolean noMobileData = !getMobileDataEnabled();
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
if (checkType == prevNetType) continue;
@@ -1177,29 +1165,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
" because Mobile Data Disabled");
continue;
}
- NetworkStateTracker tracker = mNetTrackers[checkType];
- NetworkInfo info = tracker.getNetworkInfo();
- if (!info.isConnectedOrConnecting() ||
- tracker.isTeardownRequested()) {
- info.setFailover(true);
- 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;
+ NetworkStateTracker checkTracker = mNetTrackers[checkType];
+ NetworkInfo checkInfo = checkTracker.getNetworkInfo();
+ if (!checkInfo.isConnectedOrConnecting() || checkTracker.isTeardownRequested()) {
+ checkInfo.setFailover(true);
+ checkTracker.reconnect();
}
+ if (DBG) Slog.d(TAG, "Attempting to switch to " + checkInfo.getTypeName());
}
}
-
- return newNet;
}
private void sendConnectedBroadcast(NetworkInfo info) {
@@ -1262,17 +1236,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
info.setFailover(false);
}
- NetworkStateTracker newNet = null;
if (mNetAttributes[info.getType()].isDefault()) {
- newNet = tryFailover(info.getType());
- if (newNet != null) {
- NetworkInfo switchTo = newNet.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;
- }
+ tryFailover(info.getType());
+ if (mActiveDefaultNetwork != -1) {
+ NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
} else {
mDefaultInetConditionPublished = 0;
@@ -1286,8 +1253,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* If the failover network is already connected, then immediately send
* out a followup broadcast indicating successful failover
*/
- if (newNet != null && newNet.getNetworkInfo().isConnected()) {
- sendConnectedBroadcast(newNet.getNetworkInfo());
+ if (mActiveDefaultNetwork != -1) {
+ sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
}
}