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

Commit 7a326da7 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Added builder for PreciseDataConnectionState am: 426e5cf6

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1435715

Change-Id: Ibc2f0b5aafdd8c5a4035df181df349cfa14e051f
parents f22e4a56 426e5cf6
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ import android.telephony.AccessNetworkConstants;
import android.telephony.BarringInfo;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentity;
import android.telephony.DataFailCause;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.NetworkScanRequest;
import android.telephony.PhoneNumberUtils;
@@ -84,7 +83,6 @@ import android.util.Pair;

import com.android.ims.ImsManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.cdma.CdmaMmiCode;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.dataconnection.DataEnabledSettings;
@@ -642,10 +640,11 @@ public class GsmCdmaPhone extends Phone {
        if (mSST == null
                || ((mSST.getCurrentDataConnectionState() != ServiceState.STATE_IN_SERVICE)
                        && !isEmergencyData)) {
            return new PreciseDataConnectionState(TelephonyManager.DATA_DISCONNECTED,
                    TelephonyManager.NETWORK_TYPE_UNKNOWN,
                    ApnSetting.getApnTypesBitmaskFromString(apnType),
                    apnType, null, DataFailCause.NONE, null);
            return new PreciseDataConnectionState.Builder()
                    .setState(TelephonyManager.DATA_DISCONNECTED)
                    .setApnTypes(ApnSetting.getApnTypesBitmaskFromString(apnType))
                    .setApn(apnType)
                    .build();
        }

        // must never be null
+8 −4
Original line number Diff line number Diff line
@@ -1190,10 +1190,14 @@ public class DcTracker extends Handler {
        int apnTypesBitmask = ApnSetting.getApnTypesBitmaskFromString(apnType);

        // TODO: should the data fail cause be populated?
        return new PreciseDataConnectionState(
                telState, networkType, apnTypesBitmask, apnType,
                getLinkProperties(apnType),
                DataFailCause.NONE, apnSetting);
        return new PreciseDataConnectionState.Builder()
                .setState(telState)
                .setNetworkType(networkType)
                .setApnTypes(apnTypesBitmask)
                .setApn(apnType)
                .setLinkProperties(getLinkProperties(apnType))
                .setApnSetting(apnSetting)
                .build();
    }

    /**
+24 −6
Original line number Diff line number Diff line
@@ -312,8 +312,14 @@ public class TelephonyRegistryTest extends TelephonyTest {
        // Initialize the PSL with a PreciseDataConnection
        mTelephonyRegistry.notifyDataConnectionForSubscriber(
                /*phoneId*/ 0, subId, ApnSetting.TYPE_DEFAULT,
                new PreciseDataConnectionState(
                    0, 0, 0, "default", new LinkProperties(), 0, null));
                new PreciseDataConnectionState.Builder()
                        .setState(0)
                        .setNetworkType(0)
                        .setApnTypes(0)
                        .setApn("default")
                        .setLinkProperties(new LinkProperties())
                        .setFailCause(0)
                        .build());
        mTelephonyRegistry.listenForSubscriber(subId, mContext.getOpPackageName(),
                mContext.getAttributionTag(), mPhoneStateListener.callback,
                PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE, true);
@@ -324,8 +330,14 @@ public class TelephonyRegistryTest extends TelephonyTest {
        // Add IMS APN and verify that the listener is invoked for the IMS APN
        mTelephonyRegistry.notifyDataConnectionForSubscriber(
                /*phoneId*/ 0, subId, ApnSetting.TYPE_IMS,
                new PreciseDataConnectionState(
                    0, 0, 0, "ims", new LinkProperties(), 0, null));
                new PreciseDataConnectionState.Builder()
                        .setState(0)
                        .setNetworkType(0)
                        .setApnTypes(0)
                        .setApn("ims")
                        .setLinkProperties(new LinkProperties())
                        .setFailCause(0)
                        .build());
        processAllMessages();

        assertEquals(mPhoneStateListener.invocationCount.get(), 2);
@@ -347,8 +359,14 @@ public class TelephonyRegistryTest extends TelephonyTest {
        // invoked.
        mTelephonyRegistry.notifyDataConnectionForSubscriber(
                /*phoneId*/ 0, subId, ApnSetting.TYPE_IMS,
                new PreciseDataConnectionState(
                    0, 0, 0, "ims", new LinkProperties(), 0, null));
                new PreciseDataConnectionState.Builder()
                        .setState(0)
                        .setNetworkType(0)
                        .setApnTypes(0)
                        .setApn("ims")
                        .setLinkProperties(new LinkProperties())
                        .setFailCause(0)
                        .build());
        processAllMessages();
        assertEquals(mPhoneStateListener.invocationCount.get(), 4);
    }