Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e7e0a9f authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

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
parent 2cf17ed7
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -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,7 +401,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    }
                }
            } else {
                mConnectedApns.remove(apnType);
                if (mConnectedApns.remove(apnType)) {
                    if (mConnectedApns.isEmpty()) {
                        mDataConnectionState = state;
                        modified = true;
@@ -410,15 +410,18 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
                        // send out the new status for the APN in question.
                    }
                }
            }
            mDataConnectionPossible = isDataConnectivityPossible;
            mDataConnectionReason = reason;
            mDataConnectionLinkProperties = linkProperties;
            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 {
+4 −0
Original line number Diff line number Diff line
@@ -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. */
+3 −0
Original line number Diff line number Diff line
@@ -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));
    }

+0 −4
Original line number Diff line number Diff line
@@ -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);
+6 −1
Original line number Diff line number Diff line
@@ -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) {
Loading