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

Commit 86cfbdb6 authored by Daniel Bright's avatar Daniel Bright
Browse files

Notify ALL active data connections

ApnContext's states are not always in sync with actual
data connection states, especially when the connection
is in lingering.

Bug: 143011233
Test: Manual
Test: Unit Tests
Change-Id: I7d85f81b9621da3f84f954d2744af79e9dcb59e8
parent 3ed07a6e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -2503,9 +2503,16 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    /** Send notification with an updated PreciseDataConnectionState to all data connections */
    public void notifyAllActiveDataConnections() {
        String types[] = getActiveApnTypes();
        for (String apnType : types) {
            mNotifier.notifyDataConnection(this, apnType, getPreciseDataConnectionState(apnType));
        if (mTransportManager != null) {
            for (int transportType : mTransportManager.getAvailableTransports()) {
                DcTracker dct = getDcTracker(transportType);
                if (dct != null) {
                    for (String apnType : dct.getConnectedApnTypes()) {
                        mNotifier.notifyDataConnection(
                                this, apnType, getPreciseDataConnectionState(apnType));
                    }
                }
            }
        }
    }

+13 −1
Original line number Diff line number Diff line
@@ -1091,6 +1091,18 @@ public class DcTracker extends Handler {
        return result.toArray(new String[0]);
    }

    /**
     * Get ApnTypes with connected data connections.  This is different than getActiveApnTypes()
     * which returns apn types that with active apn contexts.
     * @return apn types
     */
    public String[] getConnectedApnTypes() {
        return mApnContexts.values().stream()
                .filter(ac -> ac.getState() == DctConstants.State.CONNECTED)
                .map(ApnContext::getApnType)
                .toArray(String[]::new);
    }

    @VisibleForTesting
    public Collection<ApnContext> getApnContexts() {
        return mPrioritySortedApnContexts;
@@ -4383,7 +4395,7 @@ public class DcTracker extends Handler {
        mNetStatPollPeriod = POLL_NETSTAT_MILLIS;
    }

    private void startNetStatPoll() {
    protected void startNetStatPoll() {
        if (isAnyDataConnected() && !mNetStatPollEnabled) {
            if (DBG) {
                log("startNetStatPoll");