diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2011-01-26 10:45:10 -0800 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2011-01-26 13:39:46 -0800 |
commit | 67881c414a7ed4ed48619482bef7fe65cd7826a0 (patch) | |
tree | 4ec6e8699803287975f62dd2d286e31c03c01905 /core/java/android | |
parent | c33acae9060162c5d2c28613b71c3bb1e0ef4c1c (diff) | |
download | frameworks_base-67881c414a7ed4ed48619482bef7fe65cd7826a0.zip frameworks_base-67881c414a7ed4ed48619482bef7fe65cd7826a0.tar.gz frameworks_base-67881c414a7ed4ed48619482bef7fe65cd7826a0.tar.bz2 |
Update networktype before sending state change.
Fixes potential race condition in network-type info. May fix this issue.
bug:3376930
Change-Id: I3d5fd7c76e54923b62c56defa947be3c9c1cd585
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/net/MobileDataStateTracker.java | 8 | ||||
-rw-r--r-- | core/java/android/net/NetworkStateTracker.java | 10 |
2 files changed, 10 insertions, 8 deletions
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index ffbd69d..b559601 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -149,6 +149,11 @@ public class MobileDataStateTracker extends NetworkStateTracker { ConnectivityManager mConnectivityManager; public void onReceive(Context context, Intent intent) { synchronized(this) { + // update state and roaming before we set the state - only state changes are + // noticed + TelephonyManager tm = TelephonyManager.getDefault(); + setRoamingStatus(tm.isNetworkRoaming()); + setSubtype(tm.getNetworkType(), tm.getNetworkTypeName()); if (intent.getAction().equals(TelephonyIntents. ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { Phone.DataState state = getMobileDataState(intent); @@ -254,9 +259,6 @@ public class MobileDataStateTracker extends NetworkStateTracker { reason == null ? "" : "(" + reason + ")"); setDetailedState(DetailedState.FAILED, reason, apnName); } - TelephonyManager tm = TelephonyManager.getDefault(); - setRoamingStatus(tm.isNetworkRoaming()); - setSubtype(tm.getNetworkType(), tm.getNetworkTypeName()); } } } diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java index d340a99..039dfff 100644 --- a/core/java/android/net/NetworkStateTracker.java +++ b/core/java/android/net/NetworkStateTracker.java @@ -302,7 +302,7 @@ public abstract class NetworkStateTracker extends Handler { public boolean isTeardownRequested() { return mTeardownRequested; } - + /** * Send a notification that the results of a scan for network access * points has completed, and results are available. @@ -327,10 +327,10 @@ public abstract class NetworkStateTracker extends Handler { } protected void setSubtype(int subtype, String subtypeName) { - if (mNetworkInfo.isConnected()) { - int oldSubtype = mNetworkInfo.getSubtype(); - if (subtype != oldSubtype) { - mNetworkInfo.setSubtype(subtype, subtypeName); + int oldSubtype = mNetworkInfo.getSubtype(); + if (subtype != oldSubtype) { + mNetworkInfo.setSubtype(subtype, subtypeName); + if (mNetworkInfo.isConnected()) { Message msg = mTarget.obtainMessage( EVENT_NETWORK_SUBTYPE_CHANGED, oldSubtype, 0, mNetworkInfo); msg.sendToTarget(); |