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

Commit d378fad0 authored by Hui Wang's avatar Hui Wang Committed by Automerger Merge Worker
Browse files

Merge "Match phoneId in the record if the subId is invalid" into sc-v2-dev am:...

Merge "Match phoneId in the record if the subId is invalid" into sc-v2-dev am: 289e29fd am: 13849556

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

Change-Id: I546e4a71e69ad2d1fb9304ddc7ae69584ff34eeb
parents dd0f6ad7 13849556
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
@@ -804,4 +804,67 @@ public class TelephonyRegistryTest extends TelephonyTest {
        processAllMessages();
        assertEquals(lceList, mLinkCapacityEstimateList);
    }

    @Test
    public void testPreciseDataConnectionStateChangedForInvalidSubId() {
        //set dual sim
        doReturn(2).when(mTelephonyManager).getActiveModemCount();
        mContext.sendBroadcast(new Intent(ACTION_MULTI_SIM_CONFIG_CHANGED));
        // set default slot
        mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED)
                .putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 2)
                .putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0));
        processAllMessages();

        final int subId = 1;
        int[] events = {TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED};
        doReturn(mMockSubInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
        doReturn(1).when(mMockSubInfo).getSimSlotIndex();

        mTelephonyRegistry.listenWithEventList(subId, mContext.getOpPackageName(),
                mContext.getAttributionTag(), mTelephonyCallback.callback, events, true);
        processAllMessages();

        // notify data connection with invalid sub id and default phone id
        mTelephonyRegistry.notifyDataConnectionForSubscriber(
                /*default phoneId*/ 0, /*invalid subId*/ -1,
                new PreciseDataConnectionState.Builder()
                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                        .setId(1)
                        .setState(TelephonyManager.DATA_CONNECTED)
                        .setNetworkType(TelephonyManager.NETWORK_TYPE_LTE)
                        .setApnSetting(new ApnSetting.Builder()
                                .setApnTypeBitmask(ApnSetting.TYPE_IMS)
                                .setApnName("ims")
                                .setEntryName("ims")
                                .build())
                        .setLinkProperties(new LinkProperties())
                        .setFailCause(0)
                        .build());

        processAllMessages();

        assertEquals(0, mTelephonyCallback.invocationCount.get());

        // notify data connection with invalid sub id and default phone id
        mTelephonyRegistry.notifyDataConnectionForSubscriber(
                /*target phoneId*/ 1, /*invalid subId*/ -1,
                new PreciseDataConnectionState.Builder()
                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                        .setId(2)
                        .setState(TelephonyManager.DATA_SUSPENDED)
                        .setNetworkType(TelephonyManager.NETWORK_TYPE_LTE)
                        .setApnSetting(new ApnSetting.Builder()
                                .setApnTypeBitmask(ApnSetting.TYPE_IMS)
                                .setApnName("ims")
                                .setEntryName("ims")
                                .build())
                        .setLinkProperties(new LinkProperties())
                        .setFailCause(0)
                        .build());

        processAllMessages();

        assertEquals(1, mTelephonyCallback.invocationCount.get());
    }
}