am 89a54408: Merge "Update networktype before sending state change." into gingerbread

* commit '89a544088fcfa849be0d8824a2ac0a545950847b':
  Update networktype before sending state change.
This commit is contained in:
Robert Greenwalt
2011-01-27 10:20:33 -08:00
committed by Android Git Automerger
2 changed files with 10 additions and 8 deletions

View File

@@ -150,6 +150,11 @@ public class MobileDataStateTracker extends NetworkStateTracker {
ConnectivityManager mConnectivityManager; ConnectivityManager mConnectivityManager;
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
synchronized(this) { 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. if (intent.getAction().equals(TelephonyIntents.
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
Phone.DataState state = getMobileDataState(intent); Phone.DataState state = getMobileDataState(intent);
@@ -255,9 +260,6 @@ public class MobileDataStateTracker extends NetworkStateTracker {
reason == null ? "" : "(" + reason + ")"); reason == null ? "" : "(" + reason + ")");
setDetailedState(DetailedState.FAILED, reason, apnName); setDetailedState(DetailedState.FAILED, reason, apnName);
} }
TelephonyManager tm = TelephonyManager.getDefault();
setRoamingStatus(tm.isNetworkRoaming());
setSubtype(tm.getNetworkType(), tm.getNetworkTypeName());
} }
} }
} }

View File

@@ -315,7 +315,7 @@ public abstract class NetworkStateTracker extends Handler {
public boolean isTeardownRequested() { public boolean isTeardownRequested() {
return mTeardownRequested; return mTeardownRequested;
} }
/** /**
* Send a notification that the results of a scan for network access * Send a notification that the results of a scan for network access
* points has completed, and results are available. * points has completed, and results are available.
@@ -340,10 +340,10 @@ public abstract class NetworkStateTracker extends Handler {
} }
protected void setSubtype(int subtype, String subtypeName) { protected void setSubtype(int subtype, String subtypeName) {
if (mNetworkInfo.isConnected()) { int oldSubtype = mNetworkInfo.getSubtype();
int oldSubtype = mNetworkInfo.getSubtype(); if (subtype != oldSubtype) {
if (subtype != oldSubtype) { mNetworkInfo.setSubtype(subtype, subtypeName);
mNetworkInfo.setSubtype(subtype, subtypeName); if (mNetworkInfo.isConnected()) {
Message msg = mTarget.obtainMessage( Message msg = mTarget.obtainMessage(
EVENT_NETWORK_SUBTYPE_CHANGED, oldSubtype, 0, mNetworkInfo); EVENT_NETWORK_SUBTYPE_CHANGED, oldSubtype, 0, mNetworkInfo);
msg.sendToTarget(); msg.sendToTarget();