Loading src/java/com/android/internal/telephony/data/DataNetworkController.java +40 −20 Original line number Original line Diff line number Diff line Loading @@ -1640,8 +1640,14 @@ public class DataNetworkController extends Handler { evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_CONFIG_NOT_READY); evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_CONFIG_NOT_READY); } } if (mFeatureFlags.dataServiceCheck() && !isDataServiceSupported(transport)) { if (mFeatureFlags.dataServiceCheck()) { evaluation.addDataDisallowedReason(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, transport); if (nri != null && !nri.getAvailableServices().contains( NetworkRegistrationInfo.SERVICE_TYPE_DATA)) { evaluation.addDataDisallowedReason( DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } } } // Check CS call state and see if concurrent voice/data is allowed. // Check CS call state and see if concurrent voice/data is allowed. Loading Loading @@ -1977,9 +1983,14 @@ public class DataNetworkController extends Handler { evaluation.addDataDisallowedReason(DataDisallowedReason.CDMA_EMERGENCY_CALLBACK_MODE); evaluation.addDataDisallowedReason(DataDisallowedReason.CDMA_EMERGENCY_CALLBACK_MODE); } } if (mFeatureFlags.dataServiceCheck() if (mFeatureFlags.dataServiceCheck()) { && !isDataServiceSupported(dataNetwork.getTransport())) { NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( evaluation.addDataDisallowedReason(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); NetworkRegistrationInfo.DOMAIN_PS, dataNetwork.getTransport()); if (nri != null && nri.isInService() && !nri.getAvailableServices().contains( NetworkRegistrationInfo.SERVICE_TYPE_DATA)) { evaluation.addDataDisallowedReason( DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } } } // If the network is satellite, then the network must be restricted. // If the network is satellite, then the network must be restricted. Loading Loading @@ -2176,21 +2187,6 @@ public class DataNetworkController extends Handler { return evaluation; return evaluation; } } /** * Check if the available services support data service. * {@link NetworkRegistrationInfo#SERVICE_TYPE_DATA} service or not. * * @param transport The preferred transport type for the request. The transport here is * WWAN/WLAN. * @return {@code true} if data services is supported, otherwise {@code false}. */ private boolean isDataServiceSupported(@TransportType int transport) { NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, transport); return nri != null && nri.getAvailableServices().contains( NetworkRegistrationInfo.SERVICE_TYPE_DATA); } /** /** * Check if the transport from connectivity service can satisfy the network request. Note the * Check if the transport from connectivity service can satisfy the network request. Note the * transport here is connectivity service's transport (Wifi, cellular, satellite, etc..), not * transport here is connectivity service's transport (Wifi, cellular, satellite, etc..), not Loading Loading @@ -3802,6 +3798,22 @@ public class DataNetworkController extends Handler { } } } } /** * Check if network available services list is changed * * @param oldNri Previous network registration info. * @param newNri Current network registration info. * @return {@code true} if available services list is changed else return false */ private boolean areNetworkAvailableServicesChanged(@NonNull NetworkRegistrationInfo oldNri, @NonNull NetworkRegistrationInfo newNri) { List<Integer> oldAvailableServicesList = oldNri.getAvailableServices(); List<Integer> newAvailableServicesList = newNri.getAvailableServices(); return !(oldAvailableServicesList.size() == newAvailableServicesList.size() && oldAvailableServicesList.stream().allMatch(newAvailableServicesList::contains)); } /** /** * Check if needed to re-evaluate the existing data networks. * Check if needed to re-evaluate the existing data networks. * * Loading @@ -3818,6 +3830,10 @@ public class DataNetworkController extends Handler { return false; return false; } } if (areNetworkAvailableServicesChanged(oldNri, newNri)) { return true; } if (oldNri.getAccessNetworkTechnology() != newNri.getAccessNetworkTechnology() if (oldNri.getAccessNetworkTechnology() != newNri.getAccessNetworkTechnology() // Some CarrierConfig disallows vops in nonVops area for specified home/roaming. // Some CarrierConfig disallows vops in nonVops area for specified home/roaming. || (oldNri.isRoaming() != newNri.isRoaming())) { || (oldNri.isRoaming() != newNri.isRoaming())) { Loading Loading @@ -3863,6 +3879,10 @@ public class DataNetworkController extends Handler { return false; return false; } } if (areNetworkAvailableServicesChanged(oldPsNri, newPsNri)) { return true; } if (oldPsNri == null if (oldPsNri == null || oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology() || oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology() || (!oldPsNri.isInService() && newPsNri.isInService()) || (!oldPsNri.isInService() && newPsNri.isInService()) Loading tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java +150 −22 Original line number Original line Diff line number Diff line Loading @@ -186,7 +186,7 @@ public class DataNetworkControllerTest extends TelephonyTest { private LinkBandwidthEstimatorCallback mLinkBandwidthEstimatorCallback; private LinkBandwidthEstimatorCallback mLinkBandwidthEstimatorCallback; private boolean mIsNonTerrestrialNetwork = false; private boolean mIsNonTerrestrialNetwork = false; private ArrayList<Integer> mCarrierSupportedSatelliteServices = new ArrayList<>(); private ArrayList<Integer> mCarrierSupportedServices = new ArrayList<>(); private final DataProfile mGeneralPurposeDataProfile = new DataProfile.Builder() private final DataProfile mGeneralPurposeDataProfile = new DataProfile.Builder() .setApnSetting(new ApnSetting.Builder() .setApnSetting(new ApnSetting.Builder() Loading Loading @@ -692,7 +692,7 @@ public class DataNetworkControllerTest extends TelephonyTest { .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDataSpecificInfo(dsri) .setDataSpecificInfo(dsri) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setAvailableServices(mCarrierSupportedSatelliteServices) .setAvailableServices(mCarrierSupportedServices) .setEmergencyOnly(isEmergencyOnly) .setEmergencyOnly(isEmergencyOnly) .build()); .build()); Loading @@ -702,7 +702,7 @@ public class DataNetworkControllerTest extends TelephonyTest { .setRegistrationState(iwlanRegState) .setRegistrationState(iwlanRegState) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setAvailableServices(mCarrierSupportedSatelliteServices) .setAvailableServices(mCarrierSupportedServices) .setEmergencyOnly(isEmergencyOnly) .setEmergencyOnly(isEmergencyOnly) .build()); .build()); Loading Loading @@ -1124,7 +1124,7 @@ public class DataNetworkControllerTest extends TelephonyTest { doReturn(CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED) doReturn(CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED) .when(mSatelliteController) .when(mSatelliteController) .getSatelliteDataServicePolicyForPlmn(anyInt(), any()); .getSatelliteDataServicePolicyForPlmn(anyInt(), any()); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); logd("DataNetworkControllerTest -Setup!"); logd("DataNetworkControllerTest -Setup!"); Loading Loading @@ -1538,15 +1538,144 @@ public class DataNetworkControllerTest extends TelephonyTest { public void testMovingFromInServiceToNoService() throws Exception { public void testMovingFromInServiceToNoService() throws Exception { testSetupDataNetwork(); testSetupDataNetwork(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, // clear available services at no service mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); // Verify we don't tear down the data network. // Verify we don't tear down the data network. verifyInternetConnected(); verifyInternetConnected(); } @Test public void testInServiceAvailableServicesChanged() throws Exception { testSetupDataNetwork(); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); // Add available services sms to existing available services with data mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_SMS); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); // Verify we don't tear down the data network. // Verify we don't tear down the data network. verifyInternetConnected(); verifyInternetConnected(); mCarrierSupportedServices.clear(); // Add available services data and mms mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_MMS); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Verify we don't tear down the data network. verifyInternetConnected(); // clear all available services mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Verify internet is not connected verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } @Test public void testHomeToRoamingAvailableServicesChangedWithDataRoamingDisabled() throws Exception { testSetupDataNetwork(); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); // Disable data roaming setting mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(false); // Home to roaming with same available services serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); // Verify internet is not connected due to roaming disabled verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.ROAMING_DISABLED); } @Test public void testHomeToRoamingAvailableServicesChangedWithDataRoamingEnabled() throws Exception { testSetupDataNetwork(); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); // Enable data roaming setting mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(true); // Home to roaming with same available services serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); // Verify we don't tear down the data network since available services as still data // with data roaming enabled verifyInternetConnected(); // clear all available services mCarrierSupportedServices.clear(); // At roaming serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); // Verify internet is not connected verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } @Test public void testOnAvailableServiceChanged_WithReevaluateNetworkRequest() throws Exception { // clear available services at no service mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Set network request transport with Internet capability mDataNetworkControllerUT.addNetworkRequest( createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET)); processAllMessages(); // Verify internet is not connected due to roaming disabled verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); // add available services with data, re-evaluate network request mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Verify now internet was connected verifyInternetConnected(); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); } } @Test @Test Loading @@ -1572,7 +1701,6 @@ public class DataNetworkControllerTest extends TelephonyTest { verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS); verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS); verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET); verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET); // PS unrestricted, new setup is allowed // PS unrestricted, new setup is allowed mDataNetworkControllerUT.obtainMessage(7/*EVENT_PS_RESTRICT_DISABLED*/).sendToTarget(); mDataNetworkControllerUT.obtainMessage(7/*EVENT_PS_RESTRICT_DISABLED*/).sendToTarget(); processAllMessages(); processAllMessages(); Loading Loading @@ -2129,7 +2257,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -5846,8 +5974,8 @@ public class DataNetworkControllerTest extends TelephonyTest { @Test @Test public void testNotRestrictedDataConnectionRequest_WithoutDataServiceSupport() public void testNotRestrictedDataConnectionRequest_WithoutDataServiceSupport() throws Exception { throws Exception { mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); Loading @@ -5863,7 +5991,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration // reset satellite network and roaming registration mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading @@ -5872,8 +6000,8 @@ public class DataNetworkControllerTest extends TelephonyTest { public void testConnection_WithDataServiceCheckFlagDisabled_WithoutDataServiceSupport() public void testConnection_WithDataServiceCheckFlagDisabled_WithoutDataServiceSupport() throws Exception { throws Exception { doReturn(false).when(mFeatureFlags).dataServiceCheck(); doReturn(false).when(mFeatureFlags).dataServiceCheck(); mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); Loading @@ -5889,7 +6017,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration // reset satellite network and roaming registration mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading @@ -5897,8 +6025,8 @@ public class DataNetworkControllerTest extends TelephonyTest { @Test @Test public void testRestrictedDataConnectionRequest_WithoutDataServiceSupport() public void testRestrictedDataConnectionRequest_WithoutDataServiceSupport() throws Exception { throws Exception { mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); Loading @@ -5918,7 +6046,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration // reset satellite network and roaming registration mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -5947,7 +6075,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -5982,7 +6110,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -6017,7 +6145,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -6053,7 +6181,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading
src/java/com/android/internal/telephony/data/DataNetworkController.java +40 −20 Original line number Original line Diff line number Diff line Loading @@ -1640,8 +1640,14 @@ public class DataNetworkController extends Handler { evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_CONFIG_NOT_READY); evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_CONFIG_NOT_READY); } } if (mFeatureFlags.dataServiceCheck() && !isDataServiceSupported(transport)) { if (mFeatureFlags.dataServiceCheck()) { evaluation.addDataDisallowedReason(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, transport); if (nri != null && !nri.getAvailableServices().contains( NetworkRegistrationInfo.SERVICE_TYPE_DATA)) { evaluation.addDataDisallowedReason( DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } } } // Check CS call state and see if concurrent voice/data is allowed. // Check CS call state and see if concurrent voice/data is allowed. Loading Loading @@ -1977,9 +1983,14 @@ public class DataNetworkController extends Handler { evaluation.addDataDisallowedReason(DataDisallowedReason.CDMA_EMERGENCY_CALLBACK_MODE); evaluation.addDataDisallowedReason(DataDisallowedReason.CDMA_EMERGENCY_CALLBACK_MODE); } } if (mFeatureFlags.dataServiceCheck() if (mFeatureFlags.dataServiceCheck()) { && !isDataServiceSupported(dataNetwork.getTransport())) { NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( evaluation.addDataDisallowedReason(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); NetworkRegistrationInfo.DOMAIN_PS, dataNetwork.getTransport()); if (nri != null && nri.isInService() && !nri.getAvailableServices().contains( NetworkRegistrationInfo.SERVICE_TYPE_DATA)) { evaluation.addDataDisallowedReason( DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } } } // If the network is satellite, then the network must be restricted. // If the network is satellite, then the network must be restricted. Loading Loading @@ -2176,21 +2187,6 @@ public class DataNetworkController extends Handler { return evaluation; return evaluation; } } /** * Check if the available services support data service. * {@link NetworkRegistrationInfo#SERVICE_TYPE_DATA} service or not. * * @param transport The preferred transport type for the request. The transport here is * WWAN/WLAN. * @return {@code true} if data services is supported, otherwise {@code false}. */ private boolean isDataServiceSupported(@TransportType int transport) { NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, transport); return nri != null && nri.getAvailableServices().contains( NetworkRegistrationInfo.SERVICE_TYPE_DATA); } /** /** * Check if the transport from connectivity service can satisfy the network request. Note the * Check if the transport from connectivity service can satisfy the network request. Note the * transport here is connectivity service's transport (Wifi, cellular, satellite, etc..), not * transport here is connectivity service's transport (Wifi, cellular, satellite, etc..), not Loading Loading @@ -3802,6 +3798,22 @@ public class DataNetworkController extends Handler { } } } } /** * Check if network available services list is changed * * @param oldNri Previous network registration info. * @param newNri Current network registration info. * @return {@code true} if available services list is changed else return false */ private boolean areNetworkAvailableServicesChanged(@NonNull NetworkRegistrationInfo oldNri, @NonNull NetworkRegistrationInfo newNri) { List<Integer> oldAvailableServicesList = oldNri.getAvailableServices(); List<Integer> newAvailableServicesList = newNri.getAvailableServices(); return !(oldAvailableServicesList.size() == newAvailableServicesList.size() && oldAvailableServicesList.stream().allMatch(newAvailableServicesList::contains)); } /** /** * Check if needed to re-evaluate the existing data networks. * Check if needed to re-evaluate the existing data networks. * * Loading @@ -3818,6 +3830,10 @@ public class DataNetworkController extends Handler { return false; return false; } } if (areNetworkAvailableServicesChanged(oldNri, newNri)) { return true; } if (oldNri.getAccessNetworkTechnology() != newNri.getAccessNetworkTechnology() if (oldNri.getAccessNetworkTechnology() != newNri.getAccessNetworkTechnology() // Some CarrierConfig disallows vops in nonVops area for specified home/roaming. // Some CarrierConfig disallows vops in nonVops area for specified home/roaming. || (oldNri.isRoaming() != newNri.isRoaming())) { || (oldNri.isRoaming() != newNri.isRoaming())) { Loading Loading @@ -3863,6 +3879,10 @@ public class DataNetworkController extends Handler { return false; return false; } } if (areNetworkAvailableServicesChanged(oldPsNri, newPsNri)) { return true; } if (oldPsNri == null if (oldPsNri == null || oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology() || oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology() || (!oldPsNri.isInService() && newPsNri.isInService()) || (!oldPsNri.isInService() && newPsNri.isInService()) Loading
tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java +150 −22 Original line number Original line Diff line number Diff line Loading @@ -186,7 +186,7 @@ public class DataNetworkControllerTest extends TelephonyTest { private LinkBandwidthEstimatorCallback mLinkBandwidthEstimatorCallback; private LinkBandwidthEstimatorCallback mLinkBandwidthEstimatorCallback; private boolean mIsNonTerrestrialNetwork = false; private boolean mIsNonTerrestrialNetwork = false; private ArrayList<Integer> mCarrierSupportedSatelliteServices = new ArrayList<>(); private ArrayList<Integer> mCarrierSupportedServices = new ArrayList<>(); private final DataProfile mGeneralPurposeDataProfile = new DataProfile.Builder() private final DataProfile mGeneralPurposeDataProfile = new DataProfile.Builder() .setApnSetting(new ApnSetting.Builder() .setApnSetting(new ApnSetting.Builder() Loading Loading @@ -692,7 +692,7 @@ public class DataNetworkControllerTest extends TelephonyTest { .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDataSpecificInfo(dsri) .setDataSpecificInfo(dsri) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setAvailableServices(mCarrierSupportedSatelliteServices) .setAvailableServices(mCarrierSupportedServices) .setEmergencyOnly(isEmergencyOnly) .setEmergencyOnly(isEmergencyOnly) .build()); .build()); Loading @@ -702,7 +702,7 @@ public class DataNetworkControllerTest extends TelephonyTest { .setRegistrationState(iwlanRegState) .setRegistrationState(iwlanRegState) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork) .setAvailableServices(mCarrierSupportedSatelliteServices) .setAvailableServices(mCarrierSupportedServices) .setEmergencyOnly(isEmergencyOnly) .setEmergencyOnly(isEmergencyOnly) .build()); .build()); Loading Loading @@ -1124,7 +1124,7 @@ public class DataNetworkControllerTest extends TelephonyTest { doReturn(CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED) doReturn(CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED) .when(mSatelliteController) .when(mSatelliteController) .getSatelliteDataServicePolicyForPlmn(anyInt(), any()); .getSatelliteDataServicePolicyForPlmn(anyInt(), any()); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); logd("DataNetworkControllerTest -Setup!"); logd("DataNetworkControllerTest -Setup!"); Loading Loading @@ -1538,15 +1538,144 @@ public class DataNetworkControllerTest extends TelephonyTest { public void testMovingFromInServiceToNoService() throws Exception { public void testMovingFromInServiceToNoService() throws Exception { testSetupDataNetwork(); testSetupDataNetwork(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, // clear available services at no service mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); // Verify we don't tear down the data network. // Verify we don't tear down the data network. verifyInternetConnected(); verifyInternetConnected(); } @Test public void testInServiceAvailableServicesChanged() throws Exception { testSetupDataNetwork(); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); // Add available services sms to existing available services with data mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_SMS); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); // Verify we don't tear down the data network. // Verify we don't tear down the data network. verifyInternetConnected(); verifyInternetConnected(); mCarrierSupportedServices.clear(); // Add available services data and mms mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_MMS); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Verify we don't tear down the data network. verifyInternetConnected(); // clear all available services mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Verify internet is not connected verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } @Test public void testHomeToRoamingAvailableServicesChangedWithDataRoamingDisabled() throws Exception { testSetupDataNetwork(); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); // Disable data roaming setting mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(false); // Home to roaming with same available services serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); // Verify internet is not connected due to roaming disabled verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.ROAMING_DISABLED); } @Test public void testHomeToRoamingAvailableServicesChangedWithDataRoamingEnabled() throws Exception { testSetupDataNetwork(); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); // Enable data roaming setting mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(true); // Home to roaming with same available services serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); // Verify we don't tear down the data network since available services as still data // with data roaming enabled verifyInternetConnected(); // clear all available services mCarrierSupportedServices.clear(); // At roaming serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); // Verify internet is not connected verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); } @Test public void testOnAvailableServiceChanged_WithReevaluateNetworkRequest() throws Exception { // clear available services at no service mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Set network request transport with Internet capability mDataNetworkControllerUT.addNetworkRequest( createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET)); processAllMessages(); // Verify internet is not connected due to roaming disabled verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); List<DataDisallowedReason> reasons = mDataNetworkControllerUT .getInternetDataDisallowedReasons(); assertThat(reasons).contains(DataDisallowedReason.SERVICE_OPTION_NOT_SUPPORTED); // add available services with data, re-evaluate network request mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_DATA); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); // Verify now internet was connected verifyInternetConnected(); reasons = mDataNetworkControllerUT.getInternetDataDisallowedReasons(); assertThat(reasons).isEmpty(); } } @Test @Test Loading @@ -1572,7 +1701,6 @@ public class DataNetworkControllerTest extends TelephonyTest { verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS); verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS); verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET); verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET); // PS unrestricted, new setup is allowed // PS unrestricted, new setup is allowed mDataNetworkControllerUT.obtainMessage(7/*EVENT_PS_RESTRICT_DISABLED*/).sendToTarget(); mDataNetworkControllerUT.obtainMessage(7/*EVENT_PS_RESTRICT_DISABLED*/).sendToTarget(); processAllMessages(); processAllMessages(); Loading Loading @@ -2129,7 +2257,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -5846,8 +5974,8 @@ public class DataNetworkControllerTest extends TelephonyTest { @Test @Test public void testNotRestrictedDataConnectionRequest_WithoutDataServiceSupport() public void testNotRestrictedDataConnectionRequest_WithoutDataServiceSupport() throws Exception { throws Exception { mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); Loading @@ -5863,7 +5991,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration // reset satellite network and roaming registration mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading @@ -5872,8 +6000,8 @@ public class DataNetworkControllerTest extends TelephonyTest { public void testConnection_WithDataServiceCheckFlagDisabled_WithoutDataServiceSupport() public void testConnection_WithDataServiceCheckFlagDisabled_WithoutDataServiceSupport() throws Exception { throws Exception { doReturn(false).when(mFeatureFlags).dataServiceCheck(); doReturn(false).when(mFeatureFlags).dataServiceCheck(); mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); Loading @@ -5889,7 +6017,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration // reset satellite network and roaming registration mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading @@ -5897,8 +6025,8 @@ public class DataNetworkControllerTest extends TelephonyTest { @Test @Test public void testRestrictedDataConnectionRequest_WithoutDataServiceSupport() public void testRestrictedDataConnectionRequest_WithoutDataServiceSupport() throws Exception { throws Exception { mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); mCarrierSupportedSatelliteServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); mCarrierSupportedServices.add(NetworkRegistrationInfo.SERVICE_TYPE_VOICE); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); Loading @@ -5918,7 +6046,7 @@ public class DataNetworkControllerTest extends TelephonyTest { Mockito.clearInvocations(mMockedDataNetworkControllerCallback); Mockito.clearInvocations(mMockedDataNetworkControllerCallback); // reset satellite network and roaming registration // reset satellite network and roaming registration mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -5947,7 +6075,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -5982,7 +6110,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -6017,7 +6145,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading Loading @@ -6053,7 +6181,7 @@ public class DataNetworkControllerTest extends TelephonyTest { // reset satellite network and roaming registration // reset satellite network and roaming registration mIsNonTerrestrialNetwork = false; mIsNonTerrestrialNetwork = false; mCarrierSupportedSatelliteServices.clear(); mCarrierSupportedServices.clear(); serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_HOME); NetworkRegistrationInfo.REGISTRATION_STATE_HOME); } } Loading