summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-02-11 17:32:58 -0800
committerRobert Greenwalt <rgreenwalt@google.com>2011-02-11 17:32:58 -0800
commit7e62fd1436c0db6398528e654563896364d6000a (patch)
tree6a974ebd103270bb37efadab82b1185c4dab8971 /services
parent322891c689c845b5aa63dbca606967eb9f8f900b (diff)
downloadframeworks_base-7e62fd1436c0db6398528e654563896364d6000a.zip
frameworks_base-7e62fd1436c0db6398528e654563896364d6000a.tar.gz
frameworks_base-7e62fd1436c0db6398528e654563896364d6000a.tar.bz2
DO NOT MERGE - backport of l92a02b31 from master
Fix handling of multiple possible default networks. bug:3328196 Change-Id: I994f1621ff82de454192945a9cae961e1710d537
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/ConnectivityService.java61
1 files changed, 17 insertions, 44 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index bc102e4..4e5aa33 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1037,59 +1037,32 @@ public class ConnectivityService extends IConnectivityManager.Stub {
for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
if (checkType == prevNetType) continue;
if (mNetAttributes[checkType] == null) continue;
+ if (mNetAttributes[checkType].isDefault() == false) continue;
if (mNetAttributes[checkType].mRadio == ConnectivityManager.TYPE_MOBILE &&
noMobileData) {
Slog.e(TAG, "not failing over to mobile type " + checkType +
" because Mobile Data Disabled");
continue;
}
- if (mNetAttributes[checkType].isDefault()) {
- /* TODO - if we have multiple nets we could use
- * we may want to put more thought into which we choose
- */
- if (checkType == mNetworkPreference) {
- newType = checkType;
- break;
- }
- if (mNetAttributes[checkType].mPriority > newPriority) {
- newType = checkType;
- newPriority = mNetAttributes[newType].mPriority;
- }
+ 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());
- if (newType != -1) {
- newNet = mNetTrackers[newType];
- /**
- * See if the other network is available to fail over to.
- * If is not available, we enable it anyway, so that it
- * will be able to connect when it does become available,
- * but we report a total loss of connectivity rather than
- * report that we are attempting to fail over.
- */
- 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
+ // 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;
}
- } else {
- Slog.e(TAG, "Network failover failing.");
}
}