summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
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());
}
}