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

Commit 578bd9c3 authored by Sarah Chin's avatar Sarah Chin Committed by Android (Google) Code Review
Browse files

Merge "Notify all data disconnected on DCT initialized" into sc-dev

parents 3fec4886 b6973b93
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import android.telephony.CellLocation;
import android.telephony.DataFailCause;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PcoData;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SubscriptionManager;
@@ -1080,11 +1081,21 @@ public class DcTracker extends Handler {
        for (ApnConfigType apnConfigType : types) {
            ApnContext apnContext = new ApnContext(mPhone, apnConfigType.getType(), mLogTag, this,
                    apnConfigType.getPriority());
            int bitmask = ApnSetting.getApnTypesBitmaskFromString(apnContext.getApnType());
            mPrioritySortedApnContexts.add(apnContext);
            mApnContexts.put(apnContext.getApnType(), apnContext);
            mApnContextsByType.put(ApnSetting.getApnTypesBitmaskFromString(apnContext.getApnType()),
                    apnContext);

            mApnContextsByType.put(bitmask, apnContext);
            // Notify listeners that all data is disconnected when DCT is initialized.
            // Once connections are established, DC will then notify that data is connected.
            // This is to prevent the case where the phone process crashed but we don't notify
            // listeners that data was disconnected, so they may be stuck in a connected state.
            mPhone.notifyDataConnection(new PreciseDataConnectionState.Builder()
                    .setTransportType(mTransportType)
                    .setState(TelephonyManager.DATA_DISCONNECTED)
                    .setApnSetting(new ApnSetting.Builder()
                            .setApnTypeBitmask(bitmask).buildWithoutCheck())
                    .setNetworkType(getDataRat())
                    .build());
            log("initApnContexts: apnContext=" + ApnSetting.getApnTypeString(
                    apnConfigType.getType()));
        }
+12 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CarrierConfigManager;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -2851,4 +2852,15 @@ public class DcTrackerTest extends TelephonyTest {
                anyInt(), any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(),
                anyInt(), any(), any(), anyBoolean(), any(Message.class));
    }

    @Test
    public void testNotifyDataDisconnected() {
        // Verify notify data disconnected on DCT constructor, initialized in setUp()
        ArgumentCaptor<PreciseDataConnectionState> captor =
                ArgumentCaptor.forClass(PreciseDataConnectionState.class);
        verify(mPhone, times(13)).notifyDataConnection(captor.capture());
        for (PreciseDataConnectionState state : captor.getAllValues()) {
            assertEquals(TelephonyManager.DATA_DISCONNECTED, state.getState());
        }
    }
}