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

Commit cc22fd1d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8704672 from 0fd91c20 to tm-release

Change-Id: I1c85fe79ee1d4d18d4598548a034a0c2eecd4ac3
parents 2cef7712 0fd91c20
Loading
Loading
Loading
Loading
+10 −51
Original line number Original line Diff line number Diff line
@@ -28,9 +28,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.ContentValues;
@@ -170,15 +167,6 @@ public class SubscriptionController extends ISub.Stub {
    // Allows test mocks to avoid SELinux failures on invalidate calls.
    // Allows test mocks to avoid SELinux failures on invalidate calls.
    private static boolean sCachingEnabled = true;
    private static boolean sCachingEnabled = true;


    /**
     * Apps targeting on Android T and beyond will get exception if there is no
     * {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER} permission
     * when calling SubscriptionManager#getSubscriptionsInGroup.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
    public static final long REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID = 213902861L;

    // Each slot can have multiple subs.
    // Each slot can have multiple subs.
    private static class WatchedSlotIndexToSubIds {
    private static class WatchedSlotIndexToSubIds {
        private Map<Integer, ArrayList<Integer>> mSlotIndexToSubIds = new ConcurrentHashMap<>();
        private Map<Integer, ArrayList<Integer>> mSlotIndexToSubIds = new ConcurrentHashMap<>();
@@ -473,11 +461,10 @@ public class SubscriptionController extends ISub.Stub {
    /**
    /**
     * Returns whether the {@code callingPackage} has access to subscriber identifiers on the
     * Returns whether the {@code callingPackage} has access to subscriber identifiers on the
     * specified {@code subId} using the provided {@code message} in any resulting
     * specified {@code subId} using the provided {@code message} in any resulting
     * SecurityException. {@code throwException} flag to indicate if throw exception.
     * SecurityException.
     */
     */
    private boolean hasSubscriberIdentifierAccess(int subId, String callingPackage,
    private boolean hasSubscriberIdentifierAccess(int subId, String callingPackage,
            String callingFeatureId, String message, boolean reportFailure,
            String callingFeatureId, String message, boolean reportFailure) {
            boolean throwException) {
        try {
        try {
            return TelephonyPermissions.checkCallingOrSelfReadSubscriberIdentifiers(mContext, subId,
            return TelephonyPermissions.checkCallingOrSelfReadSubscriberIdentifiers(mContext, subId,
                    callingPackage, callingFeatureId, message, reportFailure);
                    callingPackage, callingFeatureId, message, reportFailure);
@@ -485,9 +472,6 @@ public class SubscriptionController extends ISub.Stub {
            // A SecurityException indicates that the calling package is targeting at least the
            // A SecurityException indicates that the calling package is targeting at least the
            // minimum level that enforces identifier access restrictions and the new access
            // minimum level that enforces identifier access restrictions and the new access
            // requirements are not met.
            // requirements are not met.
            if (throwException) {
                throw e;
            }
            return false;
            return false;
        }
        }
    }
    }
@@ -3976,21 +3960,10 @@ public class SubscriptionController extends ISub.Stub {
     * Get subscriptionInfo list of subscriptions that are in the same group of given subId.
     * Get subscriptionInfo list of subscriptions that are in the same group of given subId.
     * See {@link #createSubscriptionGroup(int[], String)} for more details.
     * See {@link #createSubscriptionGroup(int[], String)} for more details.
     *
     *
     * Caller must have {@link android.Manifest.permission#READ_PHONE_STATE}
     * Caller will either have {@link android.Manifest.permission#READ_PHONE_STATE}
     * or carrier privilege permission on the subscription.
     * permission or had carrier privilege permission on the subscription.
     * {@link TelephonyManager#hasCarrierPrivileges(int)}
     * {@link TelephonyManager#hasCarrierPrivileges(int)}
     *
     *
     * <p>Starting with API level 33, the caller needs the additional permission
     * {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER}
     * to get the list of subscriptions associated with a group UUID.
     * This method can be invoked if one of the following requirements is met:
     * <ul>
     *     <li>If the app has carrier privilege permission.
     *     {@link TelephonyManager#hasCarrierPrivileges()}
     *     <li>If the app has {@link android.Manifest.permission#READ_PHONE_STATE} and
     *     {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER} permission.
     * </ul>
     *
     * @throws SecurityException if the caller doesn't meet the requirements
     * @throws SecurityException if the caller doesn't meet the requirements
     *             outlined above.
     *             outlined above.
     *
     *
@@ -4018,29 +3991,15 @@ public class SubscriptionController extends ISub.Stub {
        }
        }


        return subInfoList.stream().filter(info -> {
        return subInfoList.stream().filter(info -> {
            int subId = info.getSubscriptionId();
            boolean permission = checkPermissionForGroupUuid(subId, callingPackage,
                    callingFeatureId, Binder.getCallingUid());
            if (!groupUuid.equals(info.getGroupUuid())) return false;
            if (!groupUuid.equals(info.getGroupUuid())) return false;
            return permission || info.canManageSubscription(mContext, callingPackage);
            int subId = info.getSubscriptionId();
            return TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId,
                    callingPackage, callingFeatureId, "getSubscriptionsInGroup")
                    || info.canManageSubscription(mContext, callingPackage);
        }).map(subscriptionInfo -> conditionallyRemoveIdentifiers(subscriptionInfo,
        }).map(subscriptionInfo -> conditionallyRemoveIdentifiers(subscriptionInfo,
                callingPackage, callingFeatureId, "getSubscriptionsInGroup"))
                callingPackage, callingFeatureId, "getSubscriptionsInGroup"))
        .collect(Collectors.toList());
        .collect(Collectors.toList());
    }

    private boolean checkPermissionForGroupUuid(int subId, String callingPackage,
            String callingFeatureId, int uid) {
        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId,
                callingPackage, callingFeatureId, "getSubscriptionsInGroup")) {
            return false;
        }


        if (CompatChanges.isChangeEnabled(
                REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID, uid)) {
            return hasSubscriberIdentifierAccess(subId, callingPackage,
                    callingFeatureId, "getSubscriptionsInGroup", true, true);
        }
        return true;
    }
    }


    /**
    /**
@@ -4354,7 +4313,7 @@ public class SubscriptionController extends ISub.Stub {
            if (canReadPhoneState) {
            if (canReadPhoneState) {
                canReadIdentifiers = hasSubscriberIdentifierAccess(
                canReadIdentifiers = hasSubscriberIdentifierAccess(
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
                        callingFeatureId, "getSubscriptionInfoList", false, false);
                        callingFeatureId, "getSubscriptionInfoList", false);
                canReadPhoneNumber = hasPhoneNumberAccess(
                canReadPhoneNumber = hasPhoneNumberAccess(
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
                        callingFeatureId, "getSubscriptionInfoList");
                        callingFeatureId, "getSubscriptionInfoList");
@@ -4406,7 +4365,7 @@ public class SubscriptionController extends ISub.Stub {
        SubscriptionInfo result = subInfo;
        SubscriptionInfo result = subInfo;
        int subId = subInfo.getSubscriptionId();
        int subId = subInfo.getSubscriptionId();
        boolean hasIdentifierAccess = hasSubscriberIdentifierAccess(subId, callingPackage,
        boolean hasIdentifierAccess = hasSubscriberIdentifierAccess(subId, callingPackage,
                callingFeatureId, message, true, false);
                callingFeatureId, message, true);
        boolean hasPhoneNumberAccess = hasPhoneNumberAccess(subId, callingPackage, callingFeatureId,
        boolean hasPhoneNumberAccess = hasPhoneNumberAccess(subId, callingPackage, callingFeatureId,
                message);
                message);
        return conditionallyRemoveIdentifiers(subInfo, hasIdentifierAccess, hasPhoneNumberAccess);
        return conditionallyRemoveIdentifiers(subInfo, hasIdentifierAccess, hasPhoneNumberAccess);
+2 −8
Original line number Original line Diff line number Diff line
@@ -231,12 +231,6 @@ public class DataNetwork extends StateMachine {
    /** Event for CSS indicator changed. */
    /** Event for CSS indicator changed. */
    private static final int EVENT_CSS_INDICATOR_CHANGED = 24;
    private static final int EVENT_CSS_INDICATOR_CHANGED = 24;


    /** The default MTU for IPv4 network. */
    private static final int DEFAULT_MTU_V4 = 1280;

    /** The default MTU for IPv6 network. */
    private static final int DEFAULT_MTU_V6 = 1280;

    /** Invalid context id. */
    /** Invalid context id. */
    private static final int INVALID_CID = -1;
    private static final int INVALID_CID = -1;


@@ -2220,7 +2214,7 @@ public class DataNetwork extends StateMachine {
                mtuV4 = mDataProfile.getApnSetting().getMtuV4();
                mtuV4 = mDataProfile.getApnSetting().getMtuV4();
            }
            }
            if (mtuV4 <= 0) {
            if (mtuV4 <= 0) {
                mtuV4 = DEFAULT_MTU_V4;
                mtuV4 = mDataConfigManager.getDefaultMtu();
            }
            }
        }
        }


@@ -2232,7 +2226,7 @@ public class DataNetwork extends StateMachine {
                mtuV6 = mDataProfile.getApnSetting().getMtuV6();
                mtuV6 = mDataProfile.getApnSetting().getMtuV6();
            }
            }
            if (mtuV6 <= 0) {
            if (mtuV6 <= 0) {
                mtuV6 = DEFAULT_MTU_V6;
                mtuV6 = mDataConfigManager.getDefaultMtu();
            }
            }
        }
        }


+14 −80
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.internal.telephony;


import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION;
import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION;


import static com.android.internal.telephony.SubscriptionController.REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID;
import static com.android.internal.telephony.uicc.IccCardStatus.CardState.CARDSTATE_PRESENT;
import static com.android.internal.telephony.uicc.IccCardStatus.CardState.CARDSTATE_PRESENT;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
@@ -34,9 +33,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.times;
@@ -44,7 +41,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import android.Manifest;
import android.Manifest;
import android.compat.testing.PlatformCompatChangeRule;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.ContentValues;
import android.content.Intent;
import android.content.Intent;
@@ -72,14 +68,9 @@ import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UiccSlot;
import com.android.internal.telephony.uicc.UiccSlot;


import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;

import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentCaptor;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -117,9 +108,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
    private static final String DISPLAY_NUMBER = "123456";
    private static final String DISPLAY_NUMBER = "123456";
    private static final String DISPLAY_NAME = "testing_display_name";
    private static final String DISPLAY_NAME = "testing_display_name";


    @Rule
    public TestRule mCompatChangeRule = new PlatformCompatChangeRule();

    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
        super.setUp(getClass().getSimpleName());
@@ -1111,7 +1099,6 @@ public class SubscriptionControllerTest extends TelephonyTest {


    @Test
    @Test
    @SmallTest
    @SmallTest
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testAddSubscriptionIntoGroupWithCarrierPrivilegePermission() throws Exception {
    public void testAddSubscriptionIntoGroupWithCarrierPrivilegePermission() throws Exception {
        testInsertSim();
        testInsertSim();
        // Adding a second profile and mark as embedded.
        // Adding a second profile and mark as embedded.
@@ -1163,7 +1150,6 @@ public class SubscriptionControllerTest extends TelephonyTest {


    @Test
    @Test
    @SmallTest
    @SmallTest
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testUpdateSubscriptionGroupWithCarrierPrivilegePermission() throws Exception {
    public void testUpdateSubscriptionGroupWithCarrierPrivilegePermission() throws Exception {
        testInsertSim();
        testInsertSim();
        // Adding a second profile and mark as embedded.
        // Adding a second profile and mark as embedded.
@@ -1285,7 +1271,6 @@ public class SubscriptionControllerTest extends TelephonyTest {


    @Test
    @Test
    @SmallTest
    @SmallTest
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testSetSubscriptionGroup() throws Exception {
    public void testSetSubscriptionGroup() throws Exception {
        testInsertSim();
        testInsertSim();
        // Adding a second profile and mark as embedded.
        // Adding a second profile and mark as embedded.
@@ -1720,81 +1705,42 @@ public class SubscriptionControllerTest extends TelephonyTest {
    }
    }


    @Test
    @Test
    @DisableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testGetSubscriptionsInGroupWithNoPermission() throws Exception {
    public void testGetSubscriptionsInGroupWithReadPhoneState() throws Exception {
        // If the calling package does not have the READ_PHONE_STATE permission or carrier
        // For backward compatibility test
        // privileges then getSubscriptionsInGroup should throw a SecurityException when the
        ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
        // READ_PHONE_STATE permission check is performed.
        setupReadPhoneNumbersTest();
        setIdentifierAccess(false);

        List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getSubscriptionsInGroup(
                groupUuid, mCallingPackage, mCallingFeature);

        assertTrue(subInfoList.size() > 0);
        for (SubscriptionInfo info : subInfoList) {
            assertEquals(UNAVAILABLE_ICCID, info.getIccId());
            assertEquals(UNAVAILABLE_ICCID, info.getCardString());
            assertEquals(UNAVAILABLE_NUMBER, info.getNumber());
        }
    }

    @Test
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testGetSubscriptionsInGroupWithoutAppropriatePermission() throws Exception {
        ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
        ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
        mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL);


        // no permission
        setNoPermission();
        try {
        try {
            mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
            mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
                    mCallingFeature);
                    mCallingFeature);
            fail("getSubscriptionsInGroup should fail when invoked with no permissions");
            fail("getSubscriptionsInGroup should fail when invoked with no permissions");
        } catch (SecurityException expected) {
        } catch (SecurityException expected) {
        }
        }

        // only has the USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission
        setIdentifierAccess(true);
        try {
            mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
                    mCallingFeature);
            fail("getSubscriptionsInGroup should fail when invoked with no"
                    + "READ_PHONE_STATE permissions");
        } catch (SecurityException expected) {
        }

        // only has the READ_PHONE_STATE permission
        setIdentifierAccess(false);
        setReadPhoneState();
        try {
            mSubscriptionControllerUT.getSubscriptionsInGroup(groupUuid, mCallingPackage,
                    mCallingFeature);
            fail("getSubscriptionsInGroup should fail when invoked with no "
                    + "USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permissions");
        } catch (SecurityException expected) {
        }
    }
    }


    @Test
    @Test
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testGetSubscriptionsInGroupWithReadPhoneState() throws Exception {
    public void testGetSubscriptionsInGroupWithReadDeviceIdentifier() throws Exception {
        // If the calling package only has the READ_PHONE_STATE permission then
        // getSubscriptionsInGroup should still return the list of SubscriptionInfo objects
        // but the ICC ID should not be available via getIccId or getCardString.
        ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
        ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest();
        setNoPermission();
        setupReadPhoneNumbersTest();
        setCarrierPrivileges(false);
        setIdentifierAccess(false);
        setIdentifierAccess(true);
        setReadPhoneState();


        List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getSubscriptionsInGroup(
        List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getSubscriptionsInGroup(
                groupUuid, mCallingPackage, mCallingFeature);
                groupUuid, mCallingPackage, mCallingFeature);


        assertTrue(subInfoList.size() > 0);
        assertTrue(subInfoList.size() > 0);
        for (SubscriptionInfo info : subInfoList) {
        for (SubscriptionInfo info : subInfoList) {
            assertTrue(info.getIccId().length() > 0);
            assertEquals(UNAVAILABLE_ICCID, info.getIccId());
            assertTrue(info.getCardString().length() > 0);
            assertEquals(UNAVAILABLE_ICCID, info.getCardString());
            assertEquals(UNAVAILABLE_NUMBER, info.getNumber());
        }
        }
    }
    }


    @Test
    @Test
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testGetSubscriptionInGroupWithPhoneNumberAccess() throws Exception {
    public void testGetSubscriptionInGroupWithPhoneNumberAccess() throws Exception {
        // If the calling package meets any of the requirements for the
        // If the calling package meets any of the requirements for the
        // LegacyPermissionManager#checkPhoneNumberAccess test then the number should be available
        // LegacyPermissionManager#checkPhoneNumberAccess test then the number should be available
@@ -1812,7 +1758,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
    }
    }


    @Test
    @Test
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testGetSubscriptionsInGroupWithCarrierPrivileges() throws Exception {
    public void testGetSubscriptionsInGroupWithCarrierPrivileges() throws Exception {
        // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier
        // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier
        // privileges the ICC ID should be available in the SubscriptionInfo objects in the List.
        // privileges the ICC ID should be available in the SubscriptionInfo objects in the List.
@@ -1830,7 +1775,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
    }
    }


    @Test
    @Test
    @EnableCompatChanges({REQUIRE_ICC_AUTH_DEVICE_IDENTIFIERS_FOR_GROUP_UUID})
    public void testGetSubscriptionsInGroupWithPrivilegedPermission() throws Exception {
    public void testGetSubscriptionsInGroupWithPrivilegedPermission() throws Exception {
        // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier
        // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier
        // privileges the ICC ID should be available in the SubscriptionInfo objects in the List.
        // privileges the ICC ID should be available in the SubscriptionInfo objects in the List.
@@ -2110,14 +2054,4 @@ public class SubscriptionControllerTest extends TelephonyTest {
        assertTrue(mSubscriptionControllerUT.checkPhoneIdAndIccIdMatch(0, "test2"));
        assertTrue(mSubscriptionControllerUT.checkPhoneIdAndIccIdMatch(0, "test2"));
        assertFalse(mSubscriptionControllerUT.checkPhoneIdAndIccIdMatch(0, "test3"));
        assertFalse(mSubscriptionControllerUT.checkPhoneIdAndIccIdMatch(0, "test3"));
    }
    }

    private void setNoPermission() {
        doThrow(new SecurityException()).when(mContext)
                .enforcePermission(anyString(), anyInt(), anyInt(), anyString());
    }

    private void setReadPhoneState() {
        doNothing().when(mContext).enforcePermission(
                eq(android.Manifest.permission.READ_PHONE_STATE), anyInt(), anyInt(), anyString());
    }
}
}
+6 −3
Original line number Original line Diff line number Diff line
@@ -102,6 +102,8 @@ public class DataNetworkTest extends TelephonyTest {
    private static final int ADMIN_UID1 = 1234;
    private static final int ADMIN_UID1 = 1234;
    private static final int ADMIN_UID2 = 5678;
    private static final int ADMIN_UID2 = 5678;


    private static final int DEFAULT_MTU = 1501;

    private static final String FAKE_IMSI = "123456789";
    private static final String FAKE_IMSI = "123456789";


    private DataNetwork mDataNetworkUT;
    private DataNetwork mDataNetworkUT;
@@ -218,7 +220,6 @@ public class DataNetworkTest extends TelephonyTest {
                            InetAddresses.parseNumericAddress("fd00:976a:c202:1d::7"),
                            InetAddresses.parseNumericAddress("fd00:976a:c202:1d::7"),
                            InetAddresses.parseNumericAddress("fd00:976a:c305:1d::5")))
                            InetAddresses.parseNumericAddress("fd00:976a:c305:1d::5")))
                    .setMtuV4(1234)
                    .setMtuV4(1234)
                    .setMtuV6(5678)
                    .setPduSessionId(1)
                    .setPduSessionId(1)
                    .setQosBearerSessions(new ArrayList<>())
                    .setQosBearerSessions(new ArrayList<>())
                    .setTrafficDescriptors(tds)
                    .setTrafficDescriptors(tds)
@@ -318,6 +319,7 @@ public class DataNetworkTest extends TelephonyTest {
                .when(mDataConfigManager).getBandwidthEstimateSource();
                .when(mDataConfigManager).getBandwidthEstimateSource();
        doReturn(true).when(mDataConfigManager).isTempNotMeteredSupportedByCarrier();
        doReturn(true).when(mDataConfigManager).isTempNotMeteredSupportedByCarrier();
        doReturn(true).when(mDataConfigManager).isImsDelayTearDownEnabled();
        doReturn(true).when(mDataConfigManager).isImsDelayTearDownEnabled();
        doReturn(DEFAULT_MTU).when(mDataConfigManager).getDefaultMtu();
        doReturn(FAKE_IMSI).when(mPhone).getSubscriberId();
        doReturn(FAKE_IMSI).when(mPhone).getSubscriberId();
        doReturn(true).when(mDataNetworkController)
        doReturn(true).when(mDataNetworkController)
                .isNetworkRequestExisting(any(TelephonyNetworkRequest.class));
                .isNetworkRequestExisting(any(TelephonyNetworkRequest.class));
@@ -402,9 +404,10 @@ public class DataNetworkTest extends TelephonyTest {
        assertThat(lp.getRoutes().get(0).getMtu()).isEqualTo(1234);
        assertThat(lp.getRoutes().get(0).getMtu()).isEqualTo(1234);
        assertThat(lp.getRoutes().get(1).getGateway()).isEqualTo(
        assertThat(lp.getRoutes().get(1).getGateway()).isEqualTo(
                InetAddresses.parseNumericAddress("fe80::2"));
                InetAddresses.parseNumericAddress("fe80::2"));
        assertThat(lp.getRoutes().get(1).getMtu()).isEqualTo(5678);
        // The default from carrier configs should be used if MTU is not set.
        assertThat(lp.getRoutes().get(1).getMtu()).isEqualTo(DEFAULT_MTU);
        // The higher value of v4 and v6 should be used.
        // The higher value of v4 and v6 should be used.
        assertThat(lp.getMtu()).isEqualTo(5678);
        assertThat(lp.getMtu()).isEqualTo(DEFAULT_MTU);


        ArgumentCaptor<PreciseDataConnectionState> pdcsCaptor =
        ArgumentCaptor<PreciseDataConnectionState> pdcsCaptor =
                ArgumentCaptor.forClass(PreciseDataConnectionState.class);
                ArgumentCaptor.forClass(PreciseDataConnectionState.class);