Loading src/java/com/android/internal/telephony/data/DataConfigManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -536,6 +536,14 @@ public class DataConfigManager extends Handler { .collect(Collectors.toUnmodifiableSet()); } /** * @return {@code true} if tethering profile should not be used when the device is roaming. */ public boolean isTetheringProfileDisabledForRoaming() { return mCarrierConfig.getBoolean( CarrierConfigManager.KEY_DISABLE_DUN_APN_WHILE_ROAMING_WITH_PRESET_APN_BOOL); } /** * Check if the network capability metered. * Loading Loading @@ -1226,6 +1234,8 @@ public class DataConfigManager extends Handler { com.android.internal.R.string.config_bandwidthEstimateSource)); pw.println("isDelayTearDownImsEnabled=" + isImsDelayTearDownEnabled()); pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled()); pw.println("isTetheringProfileDisabledForRoaming=" + isTetheringProfileDisabledForRoaming()); pw.decreaseIndent(); } } src/java/com/android/internal/telephony/data/DataProfileManager.java +11 −2 Original line number Diff line number Diff line Loading @@ -688,14 +688,21 @@ public class DataProfileManager extends Handler { * Check if there is tethering data profile for certain network type. * * @param networkType The network type * @return {@code true} if tethering data profile is found. * @return {@code true} if tethering data profile is found. {@code false} if no specific profile * should used for tethering. In this case, tethering service will use internet network for * tethering. */ public boolean isTetheringDataProfileExisting(@NetworkType int networkType) { if (mDataConfigManager.isTetheringProfileDisabledForRoaming() && mPhone.getServiceState().getDataRoaming()) { // Use internet network for tethering. return false; } TelephonyNetworkRequest networkRequest = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_DUN) .build(), mPhone); return null != getDataProfileForNetworkRequest(networkRequest, networkType); return getDataProfileForNetworkRequest(networkRequest, networkType) != null; } /** Loading Loading @@ -934,6 +941,8 @@ public class DataProfileManager extends Handler { pw.println("Preferred data profile from config=" + getPreferredDataProfileFromConfig()); pw.println("Preferred data profile set id=" + mPreferredDataProfileSetId); pw.println("Initial attach data profile=" + mInitialAttachDataProfile); pw.println("isTetheringDataProfileExisting=" + isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_LTE)); pw.println("Local logs:"); pw.increaseIndent(); Loading tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ import android.net.Uri; import android.os.Looper; import android.os.SystemClock; import android.provider.Telephony; import android.telephony.AccessNetworkConstants; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; import android.telephony.data.DataProfile; Loading Loading @@ -852,4 +854,36 @@ public class DataProfileManagerTest extends TelephonyTest { assertThat(mDataProfileManagerUT.isAnyPreferredDataProfileExisting()).isFalse(); assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isFalse(); } @Test public void testTetheringApnExisting() { assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_NR)).isTrue(); assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_LTE)).isFalse(); } @Test public void testTetheringApnDisabledForRoaming() { doReturn(true).when(mDataConfigManager).isTetheringProfileDisabledForRoaming(); assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_NR)).isTrue(); ServiceState ss = new ServiceState(); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .build()); ss.setDataRoamingFromRegistration(true); doReturn(ss).when(mSST).getServiceState(); doReturn(ss).when(mPhone).getServiceState(); assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_NR)).isFalse(); } } Loading
src/java/com/android/internal/telephony/data/DataConfigManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -536,6 +536,14 @@ public class DataConfigManager extends Handler { .collect(Collectors.toUnmodifiableSet()); } /** * @return {@code true} if tethering profile should not be used when the device is roaming. */ public boolean isTetheringProfileDisabledForRoaming() { return mCarrierConfig.getBoolean( CarrierConfigManager.KEY_DISABLE_DUN_APN_WHILE_ROAMING_WITH_PRESET_APN_BOOL); } /** * Check if the network capability metered. * Loading Loading @@ -1226,6 +1234,8 @@ public class DataConfigManager extends Handler { com.android.internal.R.string.config_bandwidthEstimateSource)); pw.println("isDelayTearDownImsEnabled=" + isImsDelayTearDownEnabled()); pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled()); pw.println("isTetheringProfileDisabledForRoaming=" + isTetheringProfileDisabledForRoaming()); pw.decreaseIndent(); } }
src/java/com/android/internal/telephony/data/DataProfileManager.java +11 −2 Original line number Diff line number Diff line Loading @@ -688,14 +688,21 @@ public class DataProfileManager extends Handler { * Check if there is tethering data profile for certain network type. * * @param networkType The network type * @return {@code true} if tethering data profile is found. * @return {@code true} if tethering data profile is found. {@code false} if no specific profile * should used for tethering. In this case, tethering service will use internet network for * tethering. */ public boolean isTetheringDataProfileExisting(@NetworkType int networkType) { if (mDataConfigManager.isTetheringProfileDisabledForRoaming() && mPhone.getServiceState().getDataRoaming()) { // Use internet network for tethering. return false; } TelephonyNetworkRequest networkRequest = new TelephonyNetworkRequest( new NetworkRequest.Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_DUN) .build(), mPhone); return null != getDataProfileForNetworkRequest(networkRequest, networkType); return getDataProfileForNetworkRequest(networkRequest, networkType) != null; } /** Loading Loading @@ -934,6 +941,8 @@ public class DataProfileManager extends Handler { pw.println("Preferred data profile from config=" + getPreferredDataProfileFromConfig()); pw.println("Preferred data profile set id=" + mPreferredDataProfileSetId); pw.println("Initial attach data profile=" + mInitialAttachDataProfile); pw.println("isTetheringDataProfileExisting=" + isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_LTE)); pw.println("Local logs:"); pw.increaseIndent(); Loading
tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ import android.net.Uri; import android.os.Looper; import android.os.SystemClock; import android.provider.Telephony; import android.telephony.AccessNetworkConstants; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; import android.telephony.data.DataProfile; Loading Loading @@ -852,4 +854,36 @@ public class DataProfileManagerTest extends TelephonyTest { assertThat(mDataProfileManagerUT.isAnyPreferredDataProfileExisting()).isFalse(); assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isFalse(); } @Test public void testTetheringApnExisting() { assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_NR)).isTrue(); assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_LTE)).isFalse(); } @Test public void testTetheringApnDisabledForRoaming() { doReturn(true).when(mDataConfigManager).isTetheringProfileDisabledForRoaming(); assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_NR)).isTrue(); ServiceState ss = new ServiceState(); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .build()); ss.setDataRoamingFromRegistration(true); doReturn(ss).when(mSST).getServiceState(); doReturn(ss).when(mPhone).getServiceState(); assertThat(mDataProfileManagerUT.isTetheringDataProfileExisting( TelephonyManager.NETWORK_TYPE_NR)).isFalse(); } }