Fix data state change callbacks
Initial state should be unknown or we miss the first connected change. Don't send a disconnected msg when changing network types. Filter out redundent disconnects. Add some logging. bug:3060742 Change-Id: Idc797c1276b7417337a91ed60b12b1bf392d57c0
This commit is contained in:
@@ -85,7 +85,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
private int mDataActivity = TelephonyManager.DATA_ACTIVITY_NONE;
|
||||
|
||||
private int mDataConnectionState = TelephonyManager.DATA_CONNECTED;
|
||||
private int mDataConnectionState = TelephonyManager.DATA_UNKNOWN;
|
||||
|
||||
private boolean mDataConnectionPossible = false;
|
||||
|
||||
@@ -401,13 +401,14 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mConnectedApns.remove(apnType);
|
||||
if (mConnectedApns.isEmpty()) {
|
||||
mDataConnectionState = state;
|
||||
modified = true;
|
||||
} else {
|
||||
// leave mDataConnectionState as is and
|
||||
// send out the new status for the APN in question.
|
||||
if (mConnectedApns.remove(apnType)) {
|
||||
if (mConnectedApns.isEmpty()) {
|
||||
mDataConnectionState = state;
|
||||
modified = true;
|
||||
} else {
|
||||
// leave mDataConnectionState as is and
|
||||
// send out the new status for the APN in question.
|
||||
}
|
||||
}
|
||||
}
|
||||
mDataConnectionPossible = isDataConnectivityPossible;
|
||||
@@ -416,9 +417,11 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mDataConnectionLinkCapabilities = linkCapabilities;
|
||||
if (mDataConnectionNetworkType != networkType) {
|
||||
mDataConnectionNetworkType = networkType;
|
||||
// need to tell registered listeners about the new network type
|
||||
modified = true;
|
||||
}
|
||||
if (modified) {
|
||||
Slog.d(TAG, "onDataConnectionStateChanged(" + state + ", " + networkType + ")");
|
||||
for (Record r : mRecords) {
|
||||
if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
|
||||
try {
|
||||
|
||||
@@ -802,6 +802,10 @@ public class TelephonyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** Data connection state: Unknown. Used before we know the state.
|
||||
* @hide
|
||||
*/
|
||||
public static final int DATA_UNKNOWN = -1;
|
||||
/** Data connection state: Disconnected. IP traffic not available. */
|
||||
public static final int DATA_DISCONNECTED = 0;
|
||||
/** Data connection state: Currently setting up a data connection. */
|
||||
|
||||
@@ -659,6 +659,9 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected abstract boolean isDataAllowed();
|
||||
|
||||
public boolean isApnTypeEnabled(String apnType) {
|
||||
if (apnType == null) {
|
||||
apnType = getActiveApnString();
|
||||
}
|
||||
return isApnIdEnabled(apnTypeToId(apnType));
|
||||
}
|
||||
|
||||
|
||||
@@ -94,10 +94,6 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyDataConnection(Phone sender, String reason, String apnType) {
|
||||
doNotifyDataConnection(sender, reason, apnType, sender.getDataConnectionState(apnType));
|
||||
}
|
||||
|
||||
public void notifyDataConnection(Phone sender, String reason, String apnType,
|
||||
Phone.DataState state) {
|
||||
doNotifyDataConnection(sender, reason, apnType, state);
|
||||
|
||||
@@ -742,7 +742,12 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
}
|
||||
|
||||
public void notifyDataConnection(String reason, String apnType) {
|
||||
mNotifier.notifyDataConnection(this, reason, apnType);
|
||||
mNotifier.notifyDataConnection(this, reason, apnType, getDataConnectionState(apnType));
|
||||
}
|
||||
|
||||
public void notifyDataConnection() {
|
||||
String apn = getActiveApn();
|
||||
mNotifier.notifyDataConnection(this, null, apn, getDataConnectionState(apn));
|
||||
}
|
||||
|
||||
public void notifyOtaspChanged(int otaspMode) {
|
||||
|
||||
@@ -33,8 +33,7 @@ public interface PhoneNotifier {
|
||||
|
||||
public void notifyCallForwardingChanged(Phone sender);
|
||||
|
||||
public void notifyDataConnection(Phone sender, String reason, String apnType);
|
||||
|
||||
/** TODO - reason should never be null */
|
||||
public void notifyDataConnection(Phone sender, String reason, String apnType,
|
||||
Phone.DataState state);
|
||||
|
||||
|
||||
@@ -1159,7 +1159,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
||||
}
|
||||
|
||||
if (hasCdmaDataConnectionChanged || hasNetworkTypeChanged) {
|
||||
phone.notifyDataConnection(null, null);
|
||||
phone.notifyDataConnection();
|
||||
}
|
||||
|
||||
if (hasRoamingOn) {
|
||||
|
||||
@@ -1033,8 +1033,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
|
||||
}
|
||||
|
||||
if (hasNetworkTypeChanged) {
|
||||
// TODO - do we really want this?
|
||||
phone.notifyDataConnection(null, null);
|
||||
phone.notifyDataConnection();
|
||||
}
|
||||
|
||||
if (hasRoamingOn) {
|
||||
|
||||
Reference in New Issue
Block a user