diff options
Diffstat (limited to 'core/java/android/net/MobileDataStateTracker.java')
-rw-r--r-- | core/java/android/net/MobileDataStateTracker.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index d790fc1..004cdb7 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -54,6 +54,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 @@ -72,6 +76,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) { @@ -139,6 +147,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. @@ -191,7 +200,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 @@ -213,6 +241,7 @@ public class MobileDataStateTracker extends NetworkStateTracker { if (mInterfaceName == null) { Log.d(TAG, "CONNECTED event did not supply interface name."); } + mDefaultGatewayAddr = intent.getIntExtra(Phone.DATA_GATEWAY_KEY, 0); setDetailedState(DetailedState.CONNECTED, reason, apnName); break; } |