Loading src/java/com/android/internal/telephony/data/DataNetwork.java +22 −0 Original line number Diff line number Diff line Loading @@ -664,6 +664,11 @@ public class DataNetwork extends StateMachine { */ private @NetworkType int mLastKnownDataNetworkType; /** * The last known roaming state of this data network. */ private boolean mLastKnownRoamingState; /** The reason that why setting up this data network is allowed. */ private @NonNull DataAllowedReason mDataAllowedReason; Loading Loading @@ -929,6 +934,7 @@ public class DataNetwork extends StateMachine { } mTransport = transport; mLastKnownDataNetworkType = getDataNetworkType(); mLastKnownRoamingState = mPhone.getServiceState().getDataRoamingFromRegistration(); mDataAllowedReason = dataAllowedReason; dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime()); mAttachedNetworkRequestList.addAll(networkRequestList); Loading Loading @@ -1142,6 +1148,15 @@ public class DataNetwork extends StateMachine { if (networkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) { mLastKnownDataNetworkType = networkType; } NetworkRegistrationInfo nri = mPhone.getServiceState() .getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (nri != null && nri.isInService()) { mLastKnownRoamingState = nri.getNetworkRegistrationState() == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING; } updateSuspendState(); updateNetworkCapabilities(); break; Loading Loading @@ -3398,6 +3413,13 @@ public class DataNetwork extends StateMachine { return mLastKnownDataNetworkType; } /** * @return The last known roaming state of this data network. */ public boolean getLastKnownRoamingState() { return mLastKnownRoamingState; } /** * @return The PCO data received from the network. */ Loading src/java/com/android/internal/telephony/data/DataNetworkController.java +14 −4 Original line number Diff line number Diff line Loading @@ -1977,21 +1977,31 @@ public class DataNetworkController extends Handler { } int sourceAccessNetwork = DataUtils.networkTypeToAccessNetworkType( sourceNetworkType); NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); boolean isWwanInService = false; if (nri != null && nri.isInService()) { isWwanInService = true; } // If WWAN is inService, use the real roaming state reported by modem instead of // using the overridden roaming state, otherwise get last known roaming state stored // in data network. boolean isRoaming = isWwanInService ? mServiceState.getDataRoamingFromRegistration() : dataNetwork.getLastKnownRoamingState(); int targetAccessNetwork = DataUtils.networkTypeToAccessNetworkType( getDataNetworkType(DataUtils.getTargetTransport(dataNetwork.getTransport()))); NetworkCapabilities capabilities = dataNetwork.getNetworkCapabilities(); log("evaluateDataNetworkHandover: " + "source=" + AccessNetworkType.toString(sourceAccessNetwork) + ", target=" + AccessNetworkType.toString(targetAccessNetwork) + ", roaming=" + isRoaming + ", ServiceState=" + mServiceState + ", capabilities=" + capabilities); // Matching the rules by the configured order. Bail out if find first matching rule. for (HandoverRule rule : handoverRules) { // Check if the rule is only for roaming and we are not roaming. Use the real // roaming state reported by modem instead of using the overridden roaming state. if (rule.isOnlyForRoaming && !mServiceState.getDataRoamingFromRegistration()) { // Check if the rule is only for roaming and we are not roaming. if (rule.isOnlyForRoaming && !isRoaming) { // If the rule is for roaming only, and the device is not roaming, then bypass // this rule. continue; Loading tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java +79 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ import android.provider.Telephony; import android.telephony.AccessNetworkConstants; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.Annotation; import android.telephony.Annotation.DataFailureCause; import android.telephony.Annotation.NetCapability; import android.telephony.Annotation.NetworkType; Loading Loading @@ -3966,6 +3967,84 @@ public class DataNetworkControllerTest extends TelephonyTest { AccessNetworkConstants.TRANSPORT_TYPE_WLAN); } @Test public void testHandoverDataNetworkRoamingOos() throws Exception { testSetupImsDataNetwork(); // Configured handover is disallowed at Roaming. mCarrierConfig.putStringArray( CarrierConfigManager.KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY, new String[]{ "source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN|UNKNOWN, " + "target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, roaming=true, " + "type=disallowed, capabilities=IMS" }); carrierConfigChanged(); DataNetwork dataNetwork = getDataNetworks().get(0); //Enter ROAMING serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); updateServiceStateForDatatNetwork(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING, dataNetwork); //OOS serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); updateServiceStateForDatatNetwork(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, dataNetwork); updateTransport(NetworkCapabilities.NET_CAPABILITY_IMS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); // Verify IMS network was torn down on source first. verify(mMockedWwanDataServiceManager).deactivateDataCall(anyInt(), eq(DataService.REQUEST_REASON_NORMAL), any(Message.class)); // Verify that IWLAN is brought up again on IWLAN. verify(mMockedWlanDataServiceManager).setupDataCall(anyInt(), any(DataProfile.class), anyBoolean(), anyBoolean(), eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), any(), anyBoolean(), any(Message.class)); DataNetwork dataNetworkIwlan = getDataNetworks().get(0); assertThat(dataNetworkIwlan.getTransport()).isEqualTo( AccessNetworkConstants.TRANSPORT_TYPE_WLAN); } private void updateServiceStateForDatatNetwork(@Annotation.NetworkType int networkType, @NetworkRegistrationInfo.RegistrationState int regState, DataNetwork dataNetwork) { ServiceState ss = new ServiceState(); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .setAccessNetworkTechnology(networkType) .setRegistrationState(regState) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDataSpecificInfo(null) .build()); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN) .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .build()); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .setAccessNetworkTechnology(networkType) .setRegistrationState(regState) .setDomain(NetworkRegistrationInfo.DOMAIN_CS) .build()); ss.setDataRoamingFromRegistration(regState == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); doReturn(ss).when(mSST).getServiceState(); doReturn(ss).when(mPhone).getServiceState(); if (dataNetwork != null) { dataNetwork.obtainMessage(9/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget(); processAllMessages(); } } @Test public void testHandoverDataNetworkSourceOosNoUnknownRule() throws Exception { testSetupImsDataNetwork(); Loading Loading
src/java/com/android/internal/telephony/data/DataNetwork.java +22 −0 Original line number Diff line number Diff line Loading @@ -664,6 +664,11 @@ public class DataNetwork extends StateMachine { */ private @NetworkType int mLastKnownDataNetworkType; /** * The last known roaming state of this data network. */ private boolean mLastKnownRoamingState; /** The reason that why setting up this data network is allowed. */ private @NonNull DataAllowedReason mDataAllowedReason; Loading Loading @@ -929,6 +934,7 @@ public class DataNetwork extends StateMachine { } mTransport = transport; mLastKnownDataNetworkType = getDataNetworkType(); mLastKnownRoamingState = mPhone.getServiceState().getDataRoamingFromRegistration(); mDataAllowedReason = dataAllowedReason; dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime()); mAttachedNetworkRequestList.addAll(networkRequestList); Loading Loading @@ -1142,6 +1148,15 @@ public class DataNetwork extends StateMachine { if (networkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) { mLastKnownDataNetworkType = networkType; } NetworkRegistrationInfo nri = mPhone.getServiceState() .getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (nri != null && nri.isInService()) { mLastKnownRoamingState = nri.getNetworkRegistrationState() == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING; } updateSuspendState(); updateNetworkCapabilities(); break; Loading Loading @@ -3398,6 +3413,13 @@ public class DataNetwork extends StateMachine { return mLastKnownDataNetworkType; } /** * @return The last known roaming state of this data network. */ public boolean getLastKnownRoamingState() { return mLastKnownRoamingState; } /** * @return The PCO data received from the network. */ Loading
src/java/com/android/internal/telephony/data/DataNetworkController.java +14 −4 Original line number Diff line number Diff line Loading @@ -1977,21 +1977,31 @@ public class DataNetworkController extends Handler { } int sourceAccessNetwork = DataUtils.networkTypeToAccessNetworkType( sourceNetworkType); NetworkRegistrationInfo nri = mServiceState.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); boolean isWwanInService = false; if (nri != null && nri.isInService()) { isWwanInService = true; } // If WWAN is inService, use the real roaming state reported by modem instead of // using the overridden roaming state, otherwise get last known roaming state stored // in data network. boolean isRoaming = isWwanInService ? mServiceState.getDataRoamingFromRegistration() : dataNetwork.getLastKnownRoamingState(); int targetAccessNetwork = DataUtils.networkTypeToAccessNetworkType( getDataNetworkType(DataUtils.getTargetTransport(dataNetwork.getTransport()))); NetworkCapabilities capabilities = dataNetwork.getNetworkCapabilities(); log("evaluateDataNetworkHandover: " + "source=" + AccessNetworkType.toString(sourceAccessNetwork) + ", target=" + AccessNetworkType.toString(targetAccessNetwork) + ", roaming=" + isRoaming + ", ServiceState=" + mServiceState + ", capabilities=" + capabilities); // Matching the rules by the configured order. Bail out if find first matching rule. for (HandoverRule rule : handoverRules) { // Check if the rule is only for roaming and we are not roaming. Use the real // roaming state reported by modem instead of using the overridden roaming state. if (rule.isOnlyForRoaming && !mServiceState.getDataRoamingFromRegistration()) { // Check if the rule is only for roaming and we are not roaming. if (rule.isOnlyForRoaming && !isRoaming) { // If the rule is for roaming only, and the device is not roaming, then bypass // this rule. continue; Loading
tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java +79 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ import android.provider.Telephony; import android.telephony.AccessNetworkConstants; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.Annotation; import android.telephony.Annotation.DataFailureCause; import android.telephony.Annotation.NetCapability; import android.telephony.Annotation.NetworkType; Loading Loading @@ -3966,6 +3967,84 @@ public class DataNetworkControllerTest extends TelephonyTest { AccessNetworkConstants.TRANSPORT_TYPE_WLAN); } @Test public void testHandoverDataNetworkRoamingOos() throws Exception { testSetupImsDataNetwork(); // Configured handover is disallowed at Roaming. mCarrierConfig.putStringArray( CarrierConfigManager.KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY, new String[]{ "source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN|UNKNOWN, " + "target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, roaming=true, " + "type=disallowed, capabilities=IMS" }); carrierConfigChanged(); DataNetwork dataNetwork = getDataNetworks().get(0); //Enter ROAMING serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); updateServiceStateForDatatNetwork(TelephonyManager.NETWORK_TYPE_LTE, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING, dataNetwork); //OOS serviceStateChanged(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING); updateServiceStateForDatatNetwork(TelephonyManager.NETWORK_TYPE_UNKNOWN, NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, dataNetwork); updateTransport(NetworkCapabilities.NET_CAPABILITY_IMS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); // Verify IMS network was torn down on source first. verify(mMockedWwanDataServiceManager).deactivateDataCall(anyInt(), eq(DataService.REQUEST_REASON_NORMAL), any(Message.class)); // Verify that IWLAN is brought up again on IWLAN. verify(mMockedWlanDataServiceManager).setupDataCall(anyInt(), any(DataProfile.class), anyBoolean(), anyBoolean(), eq(DataService.REQUEST_REASON_NORMAL), any(), anyInt(), any(), any(), anyBoolean(), any(Message.class)); DataNetwork dataNetworkIwlan = getDataNetworks().get(0); assertThat(dataNetworkIwlan.getTransport()).isEqualTo( AccessNetworkConstants.TRANSPORT_TYPE_WLAN); } private void updateServiceStateForDatatNetwork(@Annotation.NetworkType int networkType, @NetworkRegistrationInfo.RegistrationState int regState, DataNetwork dataNetwork) { ServiceState ss = new ServiceState(); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .setAccessNetworkTechnology(networkType) .setRegistrationState(regState) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .setDataSpecificInfo(null) .build()); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN) .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .setDomain(NetworkRegistrationInfo.DOMAIN_PS) .build()); ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .setAccessNetworkTechnology(networkType) .setRegistrationState(regState) .setDomain(NetworkRegistrationInfo.DOMAIN_CS) .build()); ss.setDataRoamingFromRegistration(regState == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); doReturn(ss).when(mSST).getServiceState(); doReturn(ss).when(mPhone).getServiceState(); if (dataNetwork != null) { dataNetwork.obtainMessage(9/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget(); processAllMessages(); } } @Test public void testHandoverDataNetworkSourceOosNoUnknownRule() throws Exception { testSetupImsDataNetwork(); Loading