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

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

Snap for 9325773 from 930daf3b to tm-qpr2-release

Change-Id: I256b0136e5d1c991a47adffa2a5d1d28b421b794
parents c3af0646 930daf3b
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1261,11 +1261,15 @@ public class NetworkTypeController extends StateMachine {
            return false;
        }

        int bandwidths = mPhone.getServiceStateTracker().getPhysicalChannelConfigList()
                .stream()
                .filter(config -> config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR)
                .map(PhysicalChannelConfig::getCellBandwidthDownlinkKhz)
                .mapToInt(Integer::intValue)
                .sum();
        // Check if meeting minimum bandwidth requirement. For most carriers, there is no minimum
        // bandwidth requirement and mNrAdvancedThresholdBandwidth is 0.
        if (mNrAdvancedThresholdBandwidth > 0
                && IntStream.of(mPhone.getServiceState().getCellBandwidths()).sum()
                < mNrAdvancedThresholdBandwidth) {
        if (mNrAdvancedThresholdBandwidth > 0 && bandwidths < mNrAdvancedThresholdBandwidth) {
            return false;
        }

+1 −1
Original line number Diff line number Diff line
@@ -3152,7 +3152,7 @@ public class DataNetwork extends StateMachine {
                && !mAttachedNetworkRequestList.isEmpty()) {
            TelephonyNetworkRequest networkRequest = mAttachedNetworkRequestList.get(0);
            DataProfile dataProfile = mDataNetworkController.getDataProfileManager()
                    .getDataProfileForNetworkRequest(networkRequest, targetNetworkType, true);
                    .getDataProfileForNetworkRequest(networkRequest, targetNetworkType, false);
            // Some carriers have different profiles between cellular and IWLAN. We need to
            // dynamically switch profile, but only when those profiles have same APN name.
            if (dataProfile != null && dataProfile.getApnSetting() != null
+18 −6
Original line number Diff line number Diff line
@@ -684,15 +684,28 @@ public class DataProfileManager extends Handler {
            return null;
        }

        // If the preferred data profile can be used, always use it if it can satisfy the network
        // request with current network type (even though it's been marked as permanent failed.)
        if (mPreferredDataProfile != null
                && networkRequest.canBeSatisfiedBy(mPreferredDataProfile)
                && mPreferredDataProfile.getApnSetting() != null
                && mPreferredDataProfile.getApnSetting().canSupportNetworkType(networkType)) {
            if (ignorePermanentFailure || !mPreferredDataProfile.getApnSetting()
                    .getPermanentFailed()) {
                return mPreferredDataProfile.getApnSetting();
            }
            log("The preferred data profile is permanently failed. Only condition based retry "
                    + "can happen.");
            return null;
        }

        // Filter out the data profile that can't satisfy the request.
        // Preferred data profile should be returned in the top of the list.
        List<DataProfile> dataProfiles = mAllDataProfiles.stream()
                .filter(networkRequest::canBeSatisfiedBy)
                // Put the preferred data profile at the top of the list, then the longest time
                // hasn't used data profile will be in the front so all the data profiles can be
                // tried.
                .sorted(Comparator.comparing((DataProfile dp) -> !dp.equals(mPreferredDataProfile))
                        .thenComparingLong(DataProfile::getLastSetupTimestamp))
                // The longest time hasn't used data profile will be in the front so all the data
                // profiles can be tried.
                .sorted(Comparator.comparing(DataProfile::getLastSetupTimestamp))
                .collect(Collectors.toList());
        for (DataProfile dataProfile : dataProfiles) {
            logv("Satisfied profile: " + dataProfile + ", last setup="
@@ -720,7 +733,6 @@ public class DataProfileManager extends Handler {
                        && (dp.getApnSetting().getApnSetId()
                        == Telephony.Carriers.MATCH_ALL_APN_SET_ID
                        || dp.getApnSetting().getApnSetId() == mPreferredDataProfileSetId))
                .filter(dp -> ignorePermanentFailure || !dp.getApnSetting().getPermanentFailed())
                .collect(Collectors.toList());
        if (dataProfiles.size() == 0) {
            log("Can't find any data profile has APN set id matched. mPreferredDataProfileSetId="
+6 −1
Original line number Diff line number Diff line
@@ -1323,7 +1323,12 @@ public class NetworkTypeControllerTest extends TelephonyTest {
        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getDataNetworkType();
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(mServiceState).getNrFrequencyRange();
        doReturn(new int[] {20001}).when(mServiceState).getCellBandwidths();
        List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>();
        lastPhysicalChannelConfigList.add(new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setCellBandwidthDownlinkKhz(20001)
                .build());
        doReturn(lastPhysicalChannelConfigList).when(mSST).getPhysicalChannelConfigList();
        mBundle.putInt(CarrierConfigManager.KEY_NR_ADVANCED_THRESHOLD_BANDWIDTH_KHZ_INT, 20000);
        broadcastCarrierConfigs();

+55 −0
Original line number Diff line number Diff line
@@ -404,6 +404,18 @@ public class DataProfileManagerTest extends TelephonyTest {
        public void restoreApnSettings() {
            mDeletedApns.clear();
        }

        public void setPreferredApn(String apnName) {
            for (Object apnSetting : mAllApnSettings) {
                if (apnName == ((Object[]) apnSetting)[3]) {
                    mPreferredApnId = (int) ((Object[]) apnSetting)[0];
                    mPreferredApnSet = (int) ((Object[]) apnSetting)[28];
                    logd("mPreferredApnId=" + mPreferredApnId + " ,mPreferredApnSet="
                            + mPreferredApnSet);
                    break;
                }
            }
        }
    }

    /**
@@ -1069,4 +1081,47 @@ public class DataProfileManagerTest extends TelephonyTest {

        assertThat(mDataProfileManagerUT.isDataProfileCompatible(dataProfile1)).isTrue();
    }

    @Test
    public void testPermanentFailureWithNoPreferredDataProfile() {
        // No preferred APN is set

        NetworkRequest request = new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                .build();
        TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
        DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
                TelephonyManager.NETWORK_TYPE_LTE, false);

        // Mark the APN as permanent failed.
        dp.getApnSetting().setPermanentFailed(true);

        // Data profile manager should return a different data profile for setup as the previous
        // data profile has been marked as permanent failed.
        assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
                TelephonyManager.NETWORK_TYPE_LTE, false)).isNotEqualTo(dp);
    }

    @Test
    public void testPermanentFailureWithPreferredDataProfile() {
        // Set the preferred APN
        mApnSettingContentProvider.setPreferredApn(GENERAL_PURPOSE_APN);
        mDataProfileManagerUT.obtainMessage(2 /* EVENT_APN_DATABASE_CHANGED */).sendToTarget();
        processAllMessages();

        NetworkRequest request = new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                .build();
        TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
        DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
                TelephonyManager.NETWORK_TYPE_LTE, false);

        // Mark the APN as permanent failed.
        dp.getApnSetting().setPermanentFailed(true);

        // Since preferred APN is already set, and that data profile was marked as permanent failed,
        // so this should result in getting nothing.
        assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
                TelephonyManager.NETWORK_TYPE_LTE, false)).isNull();
    }
}