Use apn types instead of host when sending notifications.
Previously we were passing the apn host not the type and this caused us to sometimes not send out network change notifications. Also rename of getActivceApn to getActiveApnHost to make the method clearer on what is being returned and add some debug. A future change will rename ApnSetting.apn to ApnSetting.host and getActiveApnString. bug: 2995554 Change-Id: I0c405b0f823f62c9596968c8516b820d9f8a94f2
This commit is contained in:
@@ -46,6 +46,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
|
||||
private static final String TAG = "MobileDataStateTracker";
|
||||
private static final boolean DBG = true;
|
||||
private static final boolean VDBG = false;
|
||||
|
||||
private Phone.DataState mMobileDataState;
|
||||
private ITelephony mPhoneService;
|
||||
@@ -156,10 +157,15 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
private class MobileDataStateReceiver extends BroadcastReceiver {
|
||||
IConnectivityManager mConnectivityManager;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(TelephonyIntents.
|
||||
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
|
||||
String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
|
||||
if (VDBG) Log.d(TAG,
|
||||
String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED"
|
||||
+ "mApnType=%s %s received apnType=%s",
|
||||
mApnType, TextUtils.equals(apnType, mApnType) ? "==" : "!=", apnType));
|
||||
if (!TextUtils.equals(apnType, mApnType)) {
|
||||
return;
|
||||
}
|
||||
@@ -171,8 +177,8 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
mNetworkInfo.setIsAvailable(!intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
|
||||
false));
|
||||
|
||||
if (DBG) Log.d(TAG, mApnType + " Received state= " + state + ", old= " +
|
||||
mMobileDataState + ", reason= " +
|
||||
if (DBG) Log.d(TAG, mApnType + " Received state=" + state + ", old=" +
|
||||
mMobileDataState + ", reason=" +
|
||||
(reason == null ? "(unspecified)" : reason));
|
||||
|
||||
if (mMobileDataState != state) {
|
||||
@@ -249,6 +255,8 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
equals(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED)) {
|
||||
String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
|
||||
if (!TextUtils.equals(apnType, mApnType)) {
|
||||
if (DBG) Log.d(TAG, String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_FAILED ignore, mApnType=%s != received apnType=%s",
|
||||
mApnType, apnType));
|
||||
return;
|
||||
}
|
||||
String reason = intent.getStringExtra(Phone.FAILURE_REASON_KEY);
|
||||
@@ -256,6 +264,8 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
if (DBG) Log.d(TAG, mApnType + "Received " + intent.getAction() +
|
||||
" broadcast" + reason == null ? "" : "(" + reason + ")");
|
||||
setDetailedState(DetailedState.FAILED, reason, apnName);
|
||||
} else {
|
||||
if (DBG) Log.d(TAG, "Broadcast received: ignore " + intent.getAction());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,8 +388,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
return;
|
||||
}
|
||||
Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible="
|
||||
+ isDataConnectivityPossible + " reason=" + reason
|
||||
+ " apn=" + apn + " networkType=" + networkType);
|
||||
+ isDataConnectivityPossible + " reason='" + reason
|
||||
+ "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType);
|
||||
synchronized (mRecords) {
|
||||
boolean modified = false;
|
||||
if (state == TelephonyManager.DATA_CONNECTED) {
|
||||
|
||||
@@ -687,7 +687,7 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
public boolean isApnTypeEnabled(String apnType) {
|
||||
if (apnType == null) {
|
||||
apnType = getActiveApnString();
|
||||
apnType = getActiveApnType();
|
||||
}
|
||||
return isApnIdEnabled(apnTypeToId(apnType));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
|
||||
mRegistry.notifyDataConnection(
|
||||
convertDataState(state),
|
||||
sender.isDataConnectivityPossible(), reason,
|
||||
sender.getActiveApn(),
|
||||
sender.getActiveApnHost(),
|
||||
apnType,
|
||||
linkProperties,
|
||||
linkCapabilities,
|
||||
|
||||
@@ -309,16 +309,17 @@ public interface Phone {
|
||||
|
||||
/**
|
||||
* Returns an array of string identifiers for the APN types serviced by the
|
||||
* currently active or last connected APN.
|
||||
* @return The string array.
|
||||
* currently active.
|
||||
* @return The string array will always return at least one entry, Phone.APN_TYPE_DEFAULT.
|
||||
* TODO: Revisit if we always should return at least one entry.
|
||||
*/
|
||||
String[] getActiveApnTypes();
|
||||
|
||||
/**
|
||||
* Returns a string identifier for currently active or last connected APN.
|
||||
* @return The string name.
|
||||
* Returns string for the active APN host.
|
||||
* @return type as a string or null if none.
|
||||
*/
|
||||
String getActiveApn();
|
||||
String getActiveApnHost();
|
||||
|
||||
/**
|
||||
* Return the LinkProperties for the named apn or null if not available
|
||||
|
||||
@@ -746,8 +746,10 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
}
|
||||
|
||||
public void notifyDataConnection() {
|
||||
String apn = getActiveApn();
|
||||
mNotifier.notifyDataConnection(this, null, apn, getDataConnectionState(apn));
|
||||
String types[] = getActiveApnTypes();
|
||||
for (String apnType : types) {
|
||||
mNotifier.notifyDataConnection(this, null, apnType, getDataConnectionState(apnType));
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyOtaspChanged(int otaspMode) {
|
||||
@@ -947,6 +949,10 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
return mDataConnection.getActiveApnTypes();
|
||||
}
|
||||
|
||||
public String getActiveApnHost() {
|
||||
return mDataConnection.getActiveApnString();
|
||||
}
|
||||
|
||||
public LinkProperties getLinkProperties(String apnType) {
|
||||
return mDataConnection.getLinkProperties(apnType);
|
||||
}
|
||||
@@ -955,10 +961,6 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
return mDataConnection.getLinkCapabilities(apnType);
|
||||
}
|
||||
|
||||
public String getActiveApn() {
|
||||
return mDataConnection.getActiveApnString();
|
||||
}
|
||||
|
||||
public int enableApnType(String type) {
|
||||
return mDataConnection.enableApnType(type);
|
||||
}
|
||||
|
||||
@@ -209,6 +209,10 @@ public class PhoneProxy extends Handler implements Phone {
|
||||
return mActivePhone.getActiveApnTypes();
|
||||
}
|
||||
|
||||
public String getActiveApnHost() {
|
||||
return mActivePhone.getActiveApnHost();
|
||||
}
|
||||
|
||||
public LinkProperties getLinkProperties(String apnType) {
|
||||
return mActivePhone.getLinkProperties(apnType);
|
||||
}
|
||||
@@ -217,10 +221,6 @@ public class PhoneProxy extends Handler implements Phone {
|
||||
return mActivePhone.getLinkCapabilities(apnType);
|
||||
}
|
||||
|
||||
public String getActiveApn() {
|
||||
return mActivePhone.getActiveApn();
|
||||
}
|
||||
|
||||
public SignalStrength getSignalStrength() {
|
||||
return mActivePhone.getSignalStrength();
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
Phone.APN_TYPE_MMS,
|
||||
Phone.APN_TYPE_HIPRI };
|
||||
|
||||
private static final int mDefaultApnId = DataConnectionTracker.APN_DEFAULT_ID;
|
||||
|
||||
/* Constructor */
|
||||
|
||||
CdmaDataConnectionTracker(CDMAPhone p) {
|
||||
@@ -324,13 +326,17 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
/** TODO: We probably want the connection being setup to a parameter passed around */
|
||||
mPendingDataConnection = conn;
|
||||
String[] types;
|
||||
int apnId;
|
||||
if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) {
|
||||
types = new String[1];
|
||||
types[0] = Phone.APN_TYPE_DUN;
|
||||
apnId = DataConnectionTracker.APN_DUN_ID;
|
||||
} else {
|
||||
types = mDefaultApnTypes;
|
||||
apnId = mDefaultApnId;
|
||||
}
|
||||
mActiveApn = new ApnSetting(0, "", "", "", "", "", "", "", "", "", "", 0, types);
|
||||
mActiveApn = new ApnSetting(apnId, "", "", "", "", "", "", "", "", "", "", 0, types);
|
||||
if (DBG) log("setupData: mActiveApn=" + mActiveApn);
|
||||
|
||||
Message msg = obtainMessage();
|
||||
msg.what = EVENT_DATA_SETUP_COMPLETE;
|
||||
|
||||
Reference in New Issue
Block a user