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

Commit 617d5cba authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Fixed that telephony notified the incorrect data connection state"

parents 5a1c0728 2cb46f56
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2210,10 +2210,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mNotifier.notifyMessageWaitingChanged(this);
    }

    public void notifyDataConnection(String apnType, PhoneConstants.DataState state) {
        mNotifier.notifyDataConnection(this, apnType, state);
    }

    public void notifyDataConnection(String apnType) {
        mNotifier.notifyDataConnection(this, apnType, getDataConnectionState(apnType));
    }
@@ -2248,6 +2244,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mNotifier.notifySignalStrength(this);
    }

    public PhoneConstants.DataState getDataConnectionState(String apnType) {
        return PhoneConstants.DataState.DISCONNECTED;
    }

    public void notifyCellInfo(List<CellInfo> cellInfo) {
        AsyncResult ar = new AsyncResult(null, cellInfo, null);
        mCellInfoRegistrants.notifyRegistrants(ar);
+8 −51
Original line number Diff line number Diff line
@@ -1167,7 +1167,7 @@ public class DcTracker extends Handler {
        if (DBG) log ("onDataConnectionDetached: stop polling and notify detached");
        stopNetStatPoll();
        stopDataStallAlarm();
        notifyDataConnection();
        mPhone.notifyDataConnection();
        mAttached.set(false);
    }

@@ -1178,10 +1178,7 @@ public class DcTracker extends Handler {
            if (DBG) log("onDataConnectionAttached: start polling notify attached");
            startNetStatPoll();
            startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
            notifyDataConnection();
        } else {
            // update APN availability so that APN can be enabled.
            notifyOffApnsOfAvailability();
            mPhone.notifyDataConnection();
        }
        if (mAutoAttachOnCreationConfig) {
            mAutoAttachEnabled.set(true);
@@ -1443,7 +1440,6 @@ public class DcTracker extends Handler {
                        buildWaitingApns(apnContext.getApnType(), radioTech);
                if (waitingApns.isEmpty()) {
                    notifyNoData(DataFailCause.MISSING_UNKNOWN_APN, apnContext);
                    notifyOffApnsOfAvailability();
                    String str = "trySetupData: X No APN found retValue=false";
                    if (DBG) log(str);
                    apnContext.requestLog(str);
@@ -1458,7 +1454,6 @@ public class DcTracker extends Handler {
            }

            boolean retValue = setupData(apnContext, radioTech, requestType);
            notifyOffApnsOfAvailability();

            if (DBG) log("trySetupData: X retValue=" + retValue);
            return retValue;
@@ -1467,7 +1462,6 @@ public class DcTracker extends Handler {
                    && apnContext.isConnectable()) {
                mPhone.notifyDataConnectionFailed(apnContext.getApnType());
            }
            notifyOffApnsOfAvailability();

            StringBuilder str = new StringBuilder();

@@ -1493,22 +1487,6 @@ public class DcTracker extends Handler {
        }
    }

    // Disabled apn's still need avail/unavail notifications - send them out
    private void notifyOffApnsOfAvailability() {
        for (ApnContext apnContext : mApnContexts.values()) {
            if (!mAttached.get() || !apnContext.isReady()) {
                if (DBG) log("notifyOffApnOfAvailability type:" + apnContext.getApnType());
                mPhone.notifyDataConnection(apnContext.getApnType(),
                                            PhoneConstants.DataState.DISCONNECTED);
            } else {
                if (VDBG) {
                    log("notifyOffApnsOfAvailability skipped apn due to attached && isReady " +
                            apnContext.toString());
                }
            }
        }
    }

    /**
     * Clean up all data connections. Note this is just detach the APN context from the data
     * connection. After all APN contexts are detached from the data connection, the data
@@ -2190,10 +2168,7 @@ public class DcTracker extends Handler {
        createAllApnList();
        setDataProfilesAsNeeded();
        setInitialAttachApn();
        if (mPhone.mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON) {
            if (DBG) log("onRecordsLoadedOrSubIdChanged: notifying data availability");
            notifyOffApnsOfAvailability();
        }
        mPhone.notifyDataConnection();
        setupDataOnConnectableApns(Phone.REASON_SIM_LOADED, RetryFailures.ALWAYS);
    }

@@ -2587,10 +2562,9 @@ public class DcTracker extends Handler {
            // If the user did not enable data roaming, now when we transit from roaming to
            // non-roaming, we should try to reestablish the data connection.

            notifyOffApnsOfAvailability();
            setupDataOnConnectableApns(Phone.REASON_ROAMING_OFF, RetryFailures.ALWAYS);
        } else {
            notifyDataConnection();
            mPhone.notifyDataConnection();
        }
    }

@@ -2621,14 +2595,13 @@ public class DcTracker extends Handler {
            if (DBG) log("onDataRoamingOnOrSettingsChanged: setup data on roaming");

            setupDataOnConnectableApns(Phone.REASON_ROAMING_ON, RetryFailures.ALWAYS);
            notifyDataConnection();
            mPhone.notifyDataConnection();
        } else {
            // If the user does not turn on data roaming, when we transit from non-roaming to
            // roaming, we need to tear down the data connection otherwise the user might be
            // charged for data roaming usage.
            if (DBG) log("onDataRoamingOnOrSettingsChanged: Tear down data connection on roaming.");
            cleanUpAllConnectionsInternal(true, Phone.REASON_ROAMING_ON);
            notifyOffApnsOfAvailability();
        }
    }

@@ -2654,16 +2627,11 @@ public class DcTracker extends Handler {
            // Assume data is connected on the simulator
            // FIXME  this can be improved
            // setState(DctConstants.State.CONNECTED);
            notifyDataConnection();
            mPhone.notifyDataConnection();

            log("onRadioAvailable: We're on the simulator; assuming data is connected");
        }

        IccRecords r = mIccRecords.get();
        if (r != null && r.getRecordsLoaded()) {
            notifyOffApnsOfAvailability();
        }

        if (getOverallState() != DctConstants.State.IDLE) {
            cleanUpConnectionInternal(true, RELEASE_TYPE_DETACH, null);
        }
@@ -2686,7 +2654,6 @@ public class DcTracker extends Handler {
            if (DBG) log("onRadioOffOrNotAvailable: is off and clean up all connections");
            cleanUpAllConnectionsInternal(false, Phone.REASON_RADIO_TURNED_OFF);
        }
        notifyOffApnsOfAvailability();
    }

    private void completeConnection(ApnContext apnContext) {
@@ -3051,7 +3018,7 @@ public class DcTracker extends Handler {
            if (DBG) log("onVoiceCallStarted stop polling");
            stopNetStatPoll();
            stopDataStallAlarm();
            notifyDataConnection();
            mPhone.notifyDataConnection();
        }
    }

@@ -3062,7 +3029,7 @@ public class DcTracker extends Handler {
            if (!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
                startNetStatPoll();
                startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);
                notifyDataConnection();
                mPhone.notifyDataConnection();
            } else {
                // clean slate after call end.
                resetPollStats();
@@ -3094,16 +3061,6 @@ public class DcTracker extends Handler {
        return true;
    }

    private void notifyDataConnection() {
        for (ApnContext apnContext : mApnContexts.values()) {
            if (mAttached.get() && apnContext.isReady()) {
                if (DBG) log("notifyDataConnection: type:" + apnContext.getApnType());
                mPhone.notifyDataConnection(apnContext.getApnType());
            }
        }
        notifyOffApnsOfAvailability();
    }

    private void setDataProfilesAsNeeded() {
        if (DBG) log("setDataProfilesAsNeeded");

+0 −5
Original line number Diff line number Diff line
@@ -183,11 +183,6 @@ abstract class ImsPhoneBase extends Phone {
        return PhoneConstants.DataState.DISCONNECTED;
    }

    @Override
    public PhoneConstants.DataState getDataConnectionState(String apnType) {
        return PhoneConstants.DataState.DISCONNECTED;
    }

    @Override
    public DataActivityState getDataActivityState() {
        return DataActivityState.NONE;
+0 −5
Original line number Diff line number Diff line
@@ -134,11 +134,6 @@ abstract class SipPhoneBase extends Phone {
        return PhoneConstants.DataState.DISCONNECTED;
    }

    @Override
    public PhoneConstants.DataState getDataConnectionState(String apnType) {
        return PhoneConstants.DataState.DISCONNECTED;
    }

    @Override
    public DataActivityState getDataActivityState() {
        return DataActivityState.NONE;
+0 −5
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.telephony.SignalStrength;
import android.telephony.VoLteServiceState;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.PhoneConstants.DataState;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccFileHandler;
@@ -1077,10 +1076,6 @@ public class PhoneMock extends Phone {
        throw new RuntimeException("not implemented");
    }

    public DataState getDataConnectionState(String apnType) {
        throw new RuntimeException("not implemented");
    }

    public DataActivityState getDataActivityState() {
        throw new RuntimeException("not implemented");
    }