Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +90 −53 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ import android.os.UserHandle; import android.os.WorkSource; import android.preference.PreferenceManager; import android.provider.Settings; import android.telephony.AccessNetworkConstants; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.CarrierConfigManager; Loading Loading @@ -203,9 +202,10 @@ public class ServiceStateTracker extends Handler { protected static final int EVENT_RADIO_STATE_CHANGED = 1; protected static final int EVENT_NETWORK_STATE_CHANGED = 2; protected static final int EVENT_GET_SIGNAL_STRENGTH = 3; protected static final int EVENT_POLL_STATE_REGISTRATION = 4; protected static final int EVENT_POLL_STATE_GPRS = 5; protected static final int EVENT_POLL_STATE_OPERATOR = 6; protected static final int EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION = 4; protected static final int EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION = 5; protected static final int EVENT_POLL_STATE_PS_IWLAN_REGISTRATION = 6; protected static final int EVENT_POLL_STATE_OPERATOR = 7; protected static final int EVENT_POLL_SIGNAL_STRENGTH = 10; protected static final int EVENT_NITZ_TIME = 11; protected static final int EVENT_SIGNAL_STRENGTH_UPDATE = 12; Loading Loading @@ -1125,8 +1125,9 @@ public class ServiceStateTracker extends Handler { disableSingleLocationUpdate(); break; case EVENT_POLL_STATE_REGISTRATION: case EVENT_POLL_STATE_GPRS: case EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION: case EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION: case EVENT_POLL_STATE_PS_IWLAN_REGISTRATION: case EVENT_POLL_STATE_OPERATOR: ar = (AsyncResult) msg.obj; handlePollStateResult(msg.what, ar); Loading Loading @@ -1189,7 +1190,7 @@ public class ServiceStateTracker extends Handler { ar = (AsyncResult) msg.obj; if (ar.exception == null) { mRegStateManagers.get(AccessNetworkConstants.TransportType.WWAN) mRegStateManagers.get(TransportType.WWAN) .getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_CS, obtainMessage(EVENT_GET_LOC_DONE, null)); } Loading Loading @@ -1449,8 +1450,8 @@ public class ServiceStateTracker extends Handler { updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS); hasChanged |= updateNrStatusFromPhysicalChannelConfigs( list, mSS.getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN)); mSS.getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN)); // Notify NR frequency, NR connection status or bandwidths changed. if (hasChanged Loading Loading @@ -1704,6 +1705,7 @@ public class ServiceStateTracker extends Handler { if (mPollingContext[0] == 0) { mNewSS.setEmergencyOnly(mEmergencyOnly); combinePsRegistrationStates(mNewSS); if (mPhone.isPhoneTypeGsm()) { updateRoamingState(); } else { Loading Loading @@ -1898,10 +1900,44 @@ public class ServiceStateTracker extends Handler { return config.getRat() == TelephonyManager.NETWORK_TYPE_NR; } /** * This combine PS registration states from cellular and IWLAN and generates the final data * reg state and rat for backward compatibility purpose. In reality there should be two separate * registration states for cellular and IWLAN, but in legacy mode, if the device camps on IWLAN, * the IWLAN registration states overwrites the service states. This method is to simulate that * behavior. * * @param serviceState The service state having combined registration states. */ private void combinePsRegistrationStates(ServiceState serviceState) { NetworkRegistrationState wlanPsRegState = serviceState.getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, TransportType.WLAN); NetworkRegistrationState wwanPsRegState = serviceState.getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN); if (wlanPsRegState != null && wlanPsRegState.getAccessNetworkTechnology() == TelephonyManager.NETWORK_TYPE_IWLAN && wlanPsRegState.getRegState() == NetworkRegistrationState.REG_STATE_HOME) { serviceState.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN); serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE); } else if (wwanPsRegState != null) { // If the device is not camped on IWLAN, then we use cellular PS registration state // to compute reg state and rat. int regState = wwanPsRegState.getRegState(); int dataRat = ServiceState.networkTypeToRilRadioTechnology( wwanPsRegState.getAccessNetworkTechnology()); serviceState.setDataRegState(regCodeToServiceState(regState)); serviceState.setRilDataRadioTechnology(dataRat); } if (DBG) { log("combinePsRegistrationStates: " + serviceState); } } void handlePollStateResultMessage(int what, AsyncResult ar) { int ints[]; switch (what) { case EVENT_POLL_STATE_REGISTRATION: { case EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION: { NetworkRegistrationState networkRegState = (NetworkRegistrationState) ar.result; VoiceSpecificRegistrationStates voiceSpecificStates = networkRegState.getVoiceSpecificStates(); Loading Loading @@ -1980,16 +2016,29 @@ public class ServiceStateTracker extends Handler { break; } case EVENT_POLL_STATE_GPRS: { case EVENT_POLL_STATE_PS_IWLAN_REGISTRATION: { NetworkRegistrationState networkRegState = (NetworkRegistrationState) ar.result; mNewSS.addNetworkRegistrationState(networkRegState); if (DBG) { log("handlPollStateResultMessage: PS IWLAN. " + networkRegState); } break; } case EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION: { NetworkRegistrationState networkRegState = (NetworkRegistrationState) ar.result; mNewSS.addNetworkRegistrationState(networkRegState); DataSpecificRegistrationStates dataSpecificStates = networkRegState.getDataSpecificStates(); int registrationState = networkRegState.getRegState(); int serviceState = regCodeToServiceState(registrationState); int newDataRat = ServiceState.networkTypeToRilRadioTechnology( networkRegState.getAccessNetworkTechnology()); mNewSS.setDataRegState(serviceState); mNewSS.setRilDataRadioTechnology(newDataRat); if (DBG) { log("handlPollStateResultMessage: PS cellular. " + networkRegState); } // When we receive OOS reset the PhyChanConfig list so that non-return-to-idle // implementers of PhyChanConfig unsol will not carry forward a CA report Loading @@ -2000,7 +2049,6 @@ public class ServiceStateTracker extends Handler { } updateNrStatusFromPhysicalChannelConfigs( mLastPhysicalChannelConfigList, networkRegState); mNewSS.addNetworkRegistrationState(networkRegState); setPhyCellInfoFromCellIdentity(mNewSS, networkRegState.getCellIdentity()); if (mPhone.isPhoneTypeGsm()) { Loading @@ -2008,22 +2056,10 @@ public class ServiceStateTracker extends Handler { mNewReasonDataDenied = networkRegState.getRejectCause(); mNewMaxDataCalls = dataSpecificStates.maxDataCalls; mDataRoaming = regCodeIsRoaming(registrationState); if (DBG) { log("handlPollStateResultMessage: GsmSST dataServiceState=" + serviceState + " regState=" + registrationState + " dataRadioTechnology=" + newDataRat); } } else if (mPhone.isPhoneTypeCdma()) { boolean isDataRoaming = regCodeIsRoaming(registrationState); mNewSS.setDataRoaming(isDataRoaming); if (DBG) { log("handlPollStateResultMessage: cdma dataServiceState=" + serviceState + " regState=" + registrationState + " dataRadioTechnology=" + newDataRat); } } else { // If the unsolicited signal strength comes just before data RAT family changes Loading @@ -2044,11 +2080,6 @@ public class ServiceStateTracker extends Handler { // voice roaming state in done while handling EVENT_POLL_STATE_REGISTRATION_CDMA boolean isDataRoaming = regCodeIsRoaming(registrationState); mNewSS.setDataRoaming(isDataRoaming); if (DBG) { log("handlPollStateResultMessage: CdmaLteSST dataServiceState=" + serviceState + " registrationState=" + registrationState + " dataRadioTechnology=" + newDataRat); } } updateServiceStateLteEarfcnBoost(mNewSS, Loading Loading @@ -2869,19 +2900,25 @@ public class ServiceStateTracker extends Handler { default: // Issue all poll-related commands at once then count down the responses, which // are allowed to arrive out-of-order // TODO: Add WLAN support. mPollingContext[0]++; mCi.getOperator(obtainMessage(EVENT_POLL_STATE_OPERATOR, mPollingContext)); mPollingContext[0]++; mRegStateManagers.get(AccessNetworkConstants.TransportType.WWAN) .getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, obtainMessage(EVENT_POLL_STATE_GPRS, mPollingContext)); mRegStateManagers.get(TransportType.WWAN).getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, obtainMessage(EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, mPollingContext)); mPollingContext[0]++; mRegStateManagers.get(AccessNetworkConstants.TransportType.WWAN) mRegStateManagers.get(TransportType.WWAN) .getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_CS, obtainMessage(EVENT_POLL_STATE_REGISTRATION, mPollingContext)); obtainMessage(EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, mPollingContext)); if (mRegStateManagers.get(TransportType.WLAN) != null) { mPollingContext[0]++; mRegStateManagers.get(TransportType.WLAN).getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, obtainMessage(EVENT_POLL_STATE_PS_IWLAN_REGISTRATION, mPollingContext)); } if (mPhone.isPhoneTypeGsm()) { mPollingContext[0]++; Loading tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +53 −30 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import android.os.Process; import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.CarrierConfigManager; import android.telephony.CellIdentity; import android.telephony.CellIdentityCdma; Loading Loading @@ -641,7 +642,9 @@ public class ServiceStateTrackerTest extends TelephonyTest { CellIdentityGsm cellIdentityGsm = new CellIdentityGsm( 2, 3, 900, 5, "001", "01", "test", "tst"); NetworkRegistrationState result = new NetworkRegistrationState( 0, 0, 0, 0, 0, false, null, cellIdentityGsm); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, 0, 0, false, null, cellIdentityGsm); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_GET_LOC_DONE, new AsyncResult(null, result, null))); Loading @@ -660,7 +663,8 @@ public class ServiceStateTrackerTest extends TelephonyTest { public void testCdmaCellLocation() { CellIdentityCdma cellIdentityCdma = new CellIdentityCdma(1, 2, 3, 4, 5, "test", "tst"); NetworkRegistrationState result = new NetworkRegistrationState( 0, 0, 0, 0, 0, false, null, cellIdentityCdma); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, 0, 0, false, null, cellIdentityCdma); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_GET_LOC_DONE, new AsyncResult(null, result, null))); Loading Loading @@ -1569,16 +1573,19 @@ public class ServiceStateTrackerTest extends TelephonyTest { new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE, LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE); NetworkRegistrationState dataResult = new NetworkRegistrationState( 0, 0, state, dataRat, 0, false, null, cid, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, state, dataRat, 0, false, null, cid, 1, false, false, false, lteVopsSupportInfo); sst.mPollingContext[0] = 2; // update data reg state to be in service sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 0, 0, state, voiceRat, 0, false, null, cid, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, state, voiceRat, 0, false, null, cid, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); } Loading Loading @@ -1664,17 +1671,21 @@ public class ServiceStateTrackerTest extends TelephonyTest { new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE, LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE); NetworkRegistrationState dataResult = new NetworkRegistrationState( 2, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 1, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); sst.mPollingContext[0] = 2; // update data reg state to be in service sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); } Loading Loading @@ -1731,16 +1742,21 @@ public class ServiceStateTrackerTest extends TelephonyTest { new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE, LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE); NetworkRegistrationState dataResult = new NetworkRegistrationState( 2, 1, 0, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_NOT_REG_NOT_SEARCHING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 1, 1, 0, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, false, 0, 0, 0); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_NOT_REG_NOT_SEARCHING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, false, 0, 0, 0); sst.mPollingContext[0] = 2; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); assertTrue(Arrays.equals(new int[0], sst.mSS.getCellBandwidths())); Loading Loading @@ -1806,32 +1822,40 @@ public class ServiceStateTrackerTest extends TelephonyTest { LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED); NetworkRegistrationState dataResult = new NetworkRegistrationState( 2, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); sst.mPollingContext[0] = 2; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 1, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState()); NetworkRegistrationState sSnetworkRegistrationState = sst.mSS.getNetworkRegistrationState(2, 1); sst.mSS.getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN); assertEquals(lteVopsSupportInfo, sSnetworkRegistrationState.getDataSpecificStates().lteVopsSupportInfo); lteVopsSupportInfo = new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_SUPPORTED, LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED); dataResult = new NetworkRegistrationState( 2, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); dataResult = new NetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); sst.mPollingContext[0] = 1; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); Loading @@ -1839,6 +1863,5 @@ public class ServiceStateTrackerTest extends TelephonyTest { sst.mSS.getNetworkRegistrationState(2, 1); assertEquals(lteVopsSupportInfo, sSnetworkRegistrationState.getDataSpecificStates().lteVopsSupportInfo); } } Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +90 −53 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ import android.os.UserHandle; import android.os.WorkSource; import android.preference.PreferenceManager; import android.provider.Settings; import android.telephony.AccessNetworkConstants; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.CarrierConfigManager; Loading Loading @@ -203,9 +202,10 @@ public class ServiceStateTracker extends Handler { protected static final int EVENT_RADIO_STATE_CHANGED = 1; protected static final int EVENT_NETWORK_STATE_CHANGED = 2; protected static final int EVENT_GET_SIGNAL_STRENGTH = 3; protected static final int EVENT_POLL_STATE_REGISTRATION = 4; protected static final int EVENT_POLL_STATE_GPRS = 5; protected static final int EVENT_POLL_STATE_OPERATOR = 6; protected static final int EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION = 4; protected static final int EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION = 5; protected static final int EVENT_POLL_STATE_PS_IWLAN_REGISTRATION = 6; protected static final int EVENT_POLL_STATE_OPERATOR = 7; protected static final int EVENT_POLL_SIGNAL_STRENGTH = 10; protected static final int EVENT_NITZ_TIME = 11; protected static final int EVENT_SIGNAL_STRENGTH_UPDATE = 12; Loading Loading @@ -1125,8 +1125,9 @@ public class ServiceStateTracker extends Handler { disableSingleLocationUpdate(); break; case EVENT_POLL_STATE_REGISTRATION: case EVENT_POLL_STATE_GPRS: case EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION: case EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION: case EVENT_POLL_STATE_PS_IWLAN_REGISTRATION: case EVENT_POLL_STATE_OPERATOR: ar = (AsyncResult) msg.obj; handlePollStateResult(msg.what, ar); Loading Loading @@ -1189,7 +1190,7 @@ public class ServiceStateTracker extends Handler { ar = (AsyncResult) msg.obj; if (ar.exception == null) { mRegStateManagers.get(AccessNetworkConstants.TransportType.WWAN) mRegStateManagers.get(TransportType.WWAN) .getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_CS, obtainMessage(EVENT_GET_LOC_DONE, null)); } Loading Loading @@ -1449,8 +1450,8 @@ public class ServiceStateTracker extends Handler { updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS); hasChanged |= updateNrStatusFromPhysicalChannelConfigs( list, mSS.getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN)); mSS.getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, AccessNetworkType.EUTRAN)); // Notify NR frequency, NR connection status or bandwidths changed. if (hasChanged Loading Loading @@ -1704,6 +1705,7 @@ public class ServiceStateTracker extends Handler { if (mPollingContext[0] == 0) { mNewSS.setEmergencyOnly(mEmergencyOnly); combinePsRegistrationStates(mNewSS); if (mPhone.isPhoneTypeGsm()) { updateRoamingState(); } else { Loading Loading @@ -1898,10 +1900,44 @@ public class ServiceStateTracker extends Handler { return config.getRat() == TelephonyManager.NETWORK_TYPE_NR; } /** * This combine PS registration states from cellular and IWLAN and generates the final data * reg state and rat for backward compatibility purpose. In reality there should be two separate * registration states for cellular and IWLAN, but in legacy mode, if the device camps on IWLAN, * the IWLAN registration states overwrites the service states. This method is to simulate that * behavior. * * @param serviceState The service state having combined registration states. */ private void combinePsRegistrationStates(ServiceState serviceState) { NetworkRegistrationState wlanPsRegState = serviceState.getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, TransportType.WLAN); NetworkRegistrationState wwanPsRegState = serviceState.getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN); if (wlanPsRegState != null && wlanPsRegState.getAccessNetworkTechnology() == TelephonyManager.NETWORK_TYPE_IWLAN && wlanPsRegState.getRegState() == NetworkRegistrationState.REG_STATE_HOME) { serviceState.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN); serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE); } else if (wwanPsRegState != null) { // If the device is not camped on IWLAN, then we use cellular PS registration state // to compute reg state and rat. int regState = wwanPsRegState.getRegState(); int dataRat = ServiceState.networkTypeToRilRadioTechnology( wwanPsRegState.getAccessNetworkTechnology()); serviceState.setDataRegState(regCodeToServiceState(regState)); serviceState.setRilDataRadioTechnology(dataRat); } if (DBG) { log("combinePsRegistrationStates: " + serviceState); } } void handlePollStateResultMessage(int what, AsyncResult ar) { int ints[]; switch (what) { case EVENT_POLL_STATE_REGISTRATION: { case EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION: { NetworkRegistrationState networkRegState = (NetworkRegistrationState) ar.result; VoiceSpecificRegistrationStates voiceSpecificStates = networkRegState.getVoiceSpecificStates(); Loading Loading @@ -1980,16 +2016,29 @@ public class ServiceStateTracker extends Handler { break; } case EVENT_POLL_STATE_GPRS: { case EVENT_POLL_STATE_PS_IWLAN_REGISTRATION: { NetworkRegistrationState networkRegState = (NetworkRegistrationState) ar.result; mNewSS.addNetworkRegistrationState(networkRegState); if (DBG) { log("handlPollStateResultMessage: PS IWLAN. " + networkRegState); } break; } case EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION: { NetworkRegistrationState networkRegState = (NetworkRegistrationState) ar.result; mNewSS.addNetworkRegistrationState(networkRegState); DataSpecificRegistrationStates dataSpecificStates = networkRegState.getDataSpecificStates(); int registrationState = networkRegState.getRegState(); int serviceState = regCodeToServiceState(registrationState); int newDataRat = ServiceState.networkTypeToRilRadioTechnology( networkRegState.getAccessNetworkTechnology()); mNewSS.setDataRegState(serviceState); mNewSS.setRilDataRadioTechnology(newDataRat); if (DBG) { log("handlPollStateResultMessage: PS cellular. " + networkRegState); } // When we receive OOS reset the PhyChanConfig list so that non-return-to-idle // implementers of PhyChanConfig unsol will not carry forward a CA report Loading @@ -2000,7 +2049,6 @@ public class ServiceStateTracker extends Handler { } updateNrStatusFromPhysicalChannelConfigs( mLastPhysicalChannelConfigList, networkRegState); mNewSS.addNetworkRegistrationState(networkRegState); setPhyCellInfoFromCellIdentity(mNewSS, networkRegState.getCellIdentity()); if (mPhone.isPhoneTypeGsm()) { Loading @@ -2008,22 +2056,10 @@ public class ServiceStateTracker extends Handler { mNewReasonDataDenied = networkRegState.getRejectCause(); mNewMaxDataCalls = dataSpecificStates.maxDataCalls; mDataRoaming = regCodeIsRoaming(registrationState); if (DBG) { log("handlPollStateResultMessage: GsmSST dataServiceState=" + serviceState + " regState=" + registrationState + " dataRadioTechnology=" + newDataRat); } } else if (mPhone.isPhoneTypeCdma()) { boolean isDataRoaming = regCodeIsRoaming(registrationState); mNewSS.setDataRoaming(isDataRoaming); if (DBG) { log("handlPollStateResultMessage: cdma dataServiceState=" + serviceState + " regState=" + registrationState + " dataRadioTechnology=" + newDataRat); } } else { // If the unsolicited signal strength comes just before data RAT family changes Loading @@ -2044,11 +2080,6 @@ public class ServiceStateTracker extends Handler { // voice roaming state in done while handling EVENT_POLL_STATE_REGISTRATION_CDMA boolean isDataRoaming = regCodeIsRoaming(registrationState); mNewSS.setDataRoaming(isDataRoaming); if (DBG) { log("handlPollStateResultMessage: CdmaLteSST dataServiceState=" + serviceState + " registrationState=" + registrationState + " dataRadioTechnology=" + newDataRat); } } updateServiceStateLteEarfcnBoost(mNewSS, Loading Loading @@ -2869,19 +2900,25 @@ public class ServiceStateTracker extends Handler { default: // Issue all poll-related commands at once then count down the responses, which // are allowed to arrive out-of-order // TODO: Add WLAN support. mPollingContext[0]++; mCi.getOperator(obtainMessage(EVENT_POLL_STATE_OPERATOR, mPollingContext)); mPollingContext[0]++; mRegStateManagers.get(AccessNetworkConstants.TransportType.WWAN) .getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, obtainMessage(EVENT_POLL_STATE_GPRS, mPollingContext)); mRegStateManagers.get(TransportType.WWAN).getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, obtainMessage(EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, mPollingContext)); mPollingContext[0]++; mRegStateManagers.get(AccessNetworkConstants.TransportType.WWAN) mRegStateManagers.get(TransportType.WWAN) .getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_CS, obtainMessage(EVENT_POLL_STATE_REGISTRATION, mPollingContext)); obtainMessage(EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, mPollingContext)); if (mRegStateManagers.get(TransportType.WLAN) != null) { mPollingContext[0]++; mRegStateManagers.get(TransportType.WLAN).getNetworkRegistrationState( NetworkRegistrationState.DOMAIN_PS, obtainMessage(EVENT_POLL_STATE_PS_IWLAN_REGISTRATION, mPollingContext)); } if (mPhone.isPhoneTypeGsm()) { mPollingContext[0]++; Loading
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java +53 −30 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import android.os.Process; import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.CarrierConfigManager; import android.telephony.CellIdentity; import android.telephony.CellIdentityCdma; Loading Loading @@ -641,7 +642,9 @@ public class ServiceStateTrackerTest extends TelephonyTest { CellIdentityGsm cellIdentityGsm = new CellIdentityGsm( 2, 3, 900, 5, "001", "01", "test", "tst"); NetworkRegistrationState result = new NetworkRegistrationState( 0, 0, 0, 0, 0, false, null, cellIdentityGsm); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, 0, 0, false, null, cellIdentityGsm); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_GET_LOC_DONE, new AsyncResult(null, result, null))); Loading @@ -660,7 +663,8 @@ public class ServiceStateTrackerTest extends TelephonyTest { public void testCdmaCellLocation() { CellIdentityCdma cellIdentityCdma = new CellIdentityCdma(1, 2, 3, 4, 5, "test", "tst"); NetworkRegistrationState result = new NetworkRegistrationState( 0, 0, 0, 0, 0, false, null, cellIdentityCdma); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, 0, 0, false, null, cellIdentityCdma); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_GET_LOC_DONE, new AsyncResult(null, result, null))); Loading Loading @@ -1569,16 +1573,19 @@ public class ServiceStateTrackerTest extends TelephonyTest { new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE, LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE); NetworkRegistrationState dataResult = new NetworkRegistrationState( 0, 0, state, dataRat, 0, false, null, cid, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, state, dataRat, 0, false, null, cid, 1, false, false, false, lteVopsSupportInfo); sst.mPollingContext[0] = 2; // update data reg state to be in service sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 0, 0, state, voiceRat, 0, false, null, cid, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, state, voiceRat, 0, false, null, cid, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); } Loading Loading @@ -1664,17 +1671,21 @@ public class ServiceStateTrackerTest extends TelephonyTest { new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE, LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE); NetworkRegistrationState dataResult = new NetworkRegistrationState( 2, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 1, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); sst.mPollingContext[0] = 2; // update data reg state to be in service sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); } Loading Loading @@ -1731,16 +1742,21 @@ public class ServiceStateTrackerTest extends TelephonyTest { new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE, LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE); NetworkRegistrationState dataResult = new NetworkRegistrationState( 2, 1, 0, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_NOT_REG_NOT_SEARCHING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 1, 1, 0, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, false, 0, 0, 0); NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_NOT_REG_NOT_SEARCHING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, false, null, null, false, 0, 0, 0); sst.mPollingContext[0] = 2; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); assertTrue(Arrays.equals(new int[0], sst.mSS.getCellBandwidths())); Loading Loading @@ -1806,32 +1822,40 @@ public class ServiceStateTrackerTest extends TelephonyTest { LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED); NetworkRegistrationState dataResult = new NetworkRegistrationState( 2, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); sst.mPollingContext[0] = 2; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); NetworkRegistrationState voiceResult = new NetworkRegistrationState( 1, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_REGISTRATION, NetworkRegistrationState.DOMAIN_CS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, false, 0, 0, 0); sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, voiceResult, null))); waitForMs(200); assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState()); NetworkRegistrationState sSnetworkRegistrationState = sst.mSS.getNetworkRegistrationState(2, 1); sst.mSS.getNetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN); assertEquals(lteVopsSupportInfo, sSnetworkRegistrationState.getDataSpecificStates().lteVopsSupportInfo); lteVopsSupportInfo = new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_SUPPORTED, LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED); dataResult = new NetworkRegistrationState( 2, 1, 1, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); dataResult = new NetworkRegistrationState(NetworkRegistrationState.DOMAIN_PS, TransportType.WWAN, NetworkRegistrationState.REG_STATE_HOME, TelephonyManager.NETWORK_TYPE_LTE, 0, false, null, cellId, 1, false, false, false, lteVopsSupportInfo); sst.mPollingContext[0] = 1; sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_POLL_STATE_GPRS, sst.sendMessage(sst.obtainMessage( ServiceStateTracker.EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION, new AsyncResult(sst.mPollingContext, dataResult, null))); waitForMs(200); Loading @@ -1839,6 +1863,5 @@ public class ServiceStateTrackerTest extends TelephonyTest { sst.mSS.getNetworkRegistrationState(2, 1); assertEquals(lteVopsSupportInfo, sSnetworkRegistrationState.getDataSpecificStates().lteVopsSupportInfo); } }