summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRobert Greenwalt <robdroid@android.com>2010-08-13 17:49:49 -0700
committerRobert Greenwalt <robdroid@android.com>2010-08-18 15:03:46 -0700
commita22ae073cc727eb4cf2c6734d6ba7336d6d9e2b4 (patch)
treed3aa0a219b0ed07cf6730cfce8ffe8d5ec75323e /core
parent6a73368be44f45a80cc4b65dc57b9ff529cb2d89 (diff)
downloadframeworks_base-a22ae073cc727eb4cf2c6734d6ba7336d6d9e2b4.zip
frameworks_base-a22ae073cc727eb4cf2c6734d6ba7336d6d9e2b4.tar.gz
frameworks_base-a22ae073cc727eb4cf2c6734d6ba7336d6d9e2b4.tar.bz2
DO NOT MERGE Do not kill sockets going default->hipri
A usecase is to use hipri to keep alive 3g connections when wifi is about to be brought up. They are the same network, so don't reset unless both are down. Change-Id: I8dabc42f315943b28ea34721793b0ee330c07bf6
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/MobileDataStateTracker.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java
index 214510d..c34cb2f 100644
--- a/core/java/android/net/MobileDataStateTracker.java
+++ b/core/java/android/net/MobileDataStateTracker.java
@@ -53,6 +53,10 @@ public class MobileDataStateTracker extends NetworkStateTracker {
private boolean mEnabled;
private BroadcastReceiver mStateReceiver;
+ // DEFAULT and HIPRI are the same connection. If we're one of these we need to check if
+ // the other is also disconnected before we reset sockets
+ private boolean mIsDefaultOrHipri = false;
+
/**
* Create a new MobileDataStateTracker
* @param context the application context of the caller
@@ -71,6 +75,10 @@ public class MobileDataStateTracker extends NetworkStateTracker {
} else {
mApnTypeToWatchFor = mApnType;
}
+ if (netType == ConnectivityManager.TYPE_MOBILE ||
+ netType == ConnectivityManager.TYPE_MOBILE_HIPRI) {
+ mIsDefaultOrHipri = true;
+ }
mPhoneService = null;
if(netType == ConnectivityManager.TYPE_MOBILE) {
@@ -138,6 +146,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
}
private class MobileDataStateReceiver extends BroadcastReceiver {
+ ConnectivityManager mConnectivityManager;
public void onReceive(Context context, Intent intent) {
synchronized(this) {
if (intent.getAction().equals(TelephonyIntents.
@@ -190,7 +199,26 @@ public class MobileDataStateTracker extends NetworkStateTracker {
}
setDetailedState(DetailedState.DISCONNECTED, reason, apnName);
- if (mInterfaceName != null) {
+ boolean doReset = true;
+ if (mIsDefaultOrHipri == true) {
+ // both default and hipri must go down before we reset
+ int typeToCheck = (Phone.APN_TYPE_DEFAULT.equals(mApnType) ?
+ ConnectivityManager.TYPE_MOBILE_HIPRI :
+ ConnectivityManager.TYPE_MOBILE);
+ if (mConnectivityManager == null) {
+ mConnectivityManager =
+ (ConnectivityManager)context.getSystemService(
+ Context.CONNECTIVITY_SERVICE);
+ }
+ if (mConnectivityManager != null) {
+ NetworkInfo info = mConnectivityManager.getNetworkInfo(
+ typeToCheck);
+ if (info != null && info.isConnected() == true) {
+ doReset = false;
+ }
+ }
+ }
+ if (doReset && mInterfaceName != null) {
NetworkUtils.resetConnections(mInterfaceName);
}
// can't do this here - ConnectivityService needs it to clear stuff