Loading src/java/com/android/internal/telephony/metrics/ImsStats.java +0 −1 Original line number Diff line number Diff line Loading @@ -369,7 +369,6 @@ public class ImsStats { * TelephonyManager#NETWORK_TYPE_UNKNOWN} if there isn't any. */ @NetworkType @VisibleForTesting public synchronized int getImsVoiceRadioTech() { if (mLastRegistrationStats == null || !mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VOICE)) { Loading src/java/com/android/internal/telephony/metrics/ServiceStateStats.java +17 −23 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package com.android.internal.telephony.metrics; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS; import android.annotation.Nullable; import android.os.SystemClock; import android.telephony.AccessNetworkConstants; Loading @@ -27,6 +25,10 @@ import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneFactory; Loading Loading @@ -241,22 +243,7 @@ public class ServiceStateStats { * despite that the device may have emergency service over a certain RAT. */ static @NetworkType int getVoiceRat(Phone phone, @Nullable ServiceState state) { if (state == null) { return TelephonyManager.NETWORK_TYPE_UNKNOWN; } ImsPhone imsPhone = (ImsPhone) phone.getImsPhone(); if (imsPhone != null) { @NetworkType int imsVoiceRat = imsPhone.getImsStats().getImsVoiceRadioTech(); if (imsVoiceRat != TelephonyManager.NETWORK_TYPE_UNKNOWN) { // If IMS is over WWAN but WWAN PS is not in-service, then IMS RAT is invalid boolean isImsVoiceRatValid = (imsVoiceRat == TelephonyManager.NETWORK_TYPE_IWLAN || getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_UNKNOWN); return isImsVoiceRatValid ? imsVoiceRat : TelephonyManager.NETWORK_TYPE_UNKNOWN; } } return getRat(state, NetworkRegistrationInfo.DOMAIN_CS); return getVoiceRat(phone, state, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN); } /** Loading @@ -265,6 +252,7 @@ public class ServiceStateStats { * <p>If the device is not in service, {@code TelephonyManager.NETWORK_TYPE_UNKNOWN} is returned * despite that the device may have emergency service over a certain RAT. */ @VisibleForTesting public static @NetworkType int getVoiceRat(Phone phone, @Nullable ServiceState state, int bearer) { if (state == null) { return TelephonyManager.NETWORK_TYPE_UNKNOWN; Loading @@ -273,16 +261,23 @@ public class ServiceStateStats { if (bearer != VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS && imsPhone != null) { @NetworkType int imsVoiceRat = imsPhone.getImsStats().getImsVoiceRadioTech(); if (imsVoiceRat != TelephonyManager.NETWORK_TYPE_UNKNOWN) { // If IMS is over WWAN but WWAN PS is not in-service, then IMS RAT is invalid // If IMS is registered over WWAN but WWAN PS is not in service, // fallback to WWAN CS RAT boolean isImsVoiceRatValid = (imsVoiceRat == TelephonyManager.NETWORK_TYPE_IWLAN || getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_UNKNOWN); return isImsVoiceRatValid ? imsVoiceRat : TelephonyManager.NETWORK_TYPE_UNKNOWN; if (isImsVoiceRatValid) { return imsVoiceRat; } } } if (bearer == VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS) { return TelephonyManager.NETWORK_TYPE_UNKNOWN; } else { return getRat(state, NetworkRegistrationInfo.DOMAIN_CS); } } /** Returns RAT used by WWAN if WWAN is in service. */ public static @NetworkType int getRat( Loading @@ -304,8 +299,7 @@ public class ServiceStateStats { } private static boolean isEndc(ServiceState state) { if (getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_LTE) { if (getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_LTE) { return false; } int nrState = state.getNrState(); Loading tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,10 @@ import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN; import com.android.internal.telephony.Phone; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.nano.PersistAtomsProto.CellularDataServiceSwitch; Loading Loading @@ -149,6 +153,7 @@ public class ServiceStateStatsTest extends TelephonyTest { doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegState(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getVoiceNetworkType(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getDataNetworkType(); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mServiceStateStats.onServiceStateChanged(mServiceState); Loading Loading @@ -248,6 +253,7 @@ public class ServiceStateStatsTest extends TelephonyTest { doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegState(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getVoiceNetworkType(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getDataNetworkType(); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); doReturn(-1).when(mPhone).getCarrierId(); mServiceStateStats.onServiceStateChanged(mServiceState); Loading Loading @@ -395,6 +401,7 @@ public class ServiceStateStatsTest extends TelephonyTest { @SmallTest public void onServiceStateChanged_differentDataRats() throws Exception { doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getDataNetworkType(); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mServiceStateStats.onServiceStateChanged(mServiceState); Loading Loading @@ -881,6 +888,29 @@ public class ServiceStateStatsTest extends TelephonyTest { verifyNoMoreInteractions(mPersistAtomsStorage); } @Test @SmallTest public void getVoiceRat_bearer() throws Exception { mockWwanPsRat(TelephonyManager.NETWORK_TYPE_LTE); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_LTE); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mImsStats).getImsVoiceRadioTech(); assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS)); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS)); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN)); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UMTS); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UMTS); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mImsStats).getImsVoiceRadioTech(); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS)); assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS)); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN)); } private void mockWwanPsRat(@NetworkType int rat) { mockWwanRat( NetworkRegistrationInfo.DOMAIN_PS, Loading tests/telephonytests/src/com/android/internal/telephony/metrics/VoiceCallSessionStatsTest.java +59 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/java/com/android/internal/telephony/metrics/ImsStats.java +0 −1 Original line number Diff line number Diff line Loading @@ -369,7 +369,6 @@ public class ImsStats { * TelephonyManager#NETWORK_TYPE_UNKNOWN} if there isn't any. */ @NetworkType @VisibleForTesting public synchronized int getImsVoiceRadioTech() { if (mLastRegistrationStats == null || !mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VOICE)) { Loading
src/java/com/android/internal/telephony/metrics/ServiceStateStats.java +17 −23 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package com.android.internal.telephony.metrics; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS; import android.annotation.Nullable; import android.os.SystemClock; import android.telephony.AccessNetworkConstants; Loading @@ -27,6 +25,10 @@ import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneFactory; Loading Loading @@ -241,22 +243,7 @@ public class ServiceStateStats { * despite that the device may have emergency service over a certain RAT. */ static @NetworkType int getVoiceRat(Phone phone, @Nullable ServiceState state) { if (state == null) { return TelephonyManager.NETWORK_TYPE_UNKNOWN; } ImsPhone imsPhone = (ImsPhone) phone.getImsPhone(); if (imsPhone != null) { @NetworkType int imsVoiceRat = imsPhone.getImsStats().getImsVoiceRadioTech(); if (imsVoiceRat != TelephonyManager.NETWORK_TYPE_UNKNOWN) { // If IMS is over WWAN but WWAN PS is not in-service, then IMS RAT is invalid boolean isImsVoiceRatValid = (imsVoiceRat == TelephonyManager.NETWORK_TYPE_IWLAN || getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_UNKNOWN); return isImsVoiceRatValid ? imsVoiceRat : TelephonyManager.NETWORK_TYPE_UNKNOWN; } } return getRat(state, NetworkRegistrationInfo.DOMAIN_CS); return getVoiceRat(phone, state, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN); } /** Loading @@ -265,6 +252,7 @@ public class ServiceStateStats { * <p>If the device is not in service, {@code TelephonyManager.NETWORK_TYPE_UNKNOWN} is returned * despite that the device may have emergency service over a certain RAT. */ @VisibleForTesting public static @NetworkType int getVoiceRat(Phone phone, @Nullable ServiceState state, int bearer) { if (state == null) { return TelephonyManager.NETWORK_TYPE_UNKNOWN; Loading @@ -273,16 +261,23 @@ public class ServiceStateStats { if (bearer != VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS && imsPhone != null) { @NetworkType int imsVoiceRat = imsPhone.getImsStats().getImsVoiceRadioTech(); if (imsVoiceRat != TelephonyManager.NETWORK_TYPE_UNKNOWN) { // If IMS is over WWAN but WWAN PS is not in-service, then IMS RAT is invalid // If IMS is registered over WWAN but WWAN PS is not in service, // fallback to WWAN CS RAT boolean isImsVoiceRatValid = (imsVoiceRat == TelephonyManager.NETWORK_TYPE_IWLAN || getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_UNKNOWN); return isImsVoiceRatValid ? imsVoiceRat : TelephonyManager.NETWORK_TYPE_UNKNOWN; if (isImsVoiceRatValid) { return imsVoiceRat; } } } if (bearer == VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS) { return TelephonyManager.NETWORK_TYPE_UNKNOWN; } else { return getRat(state, NetworkRegistrationInfo.DOMAIN_CS); } } /** Returns RAT used by WWAN if WWAN is in service. */ public static @NetworkType int getRat( Loading @@ -304,8 +299,7 @@ public class ServiceStateStats { } private static boolean isEndc(ServiceState state) { if (getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_LTE) { if (getRat(state, NetworkRegistrationInfo.DOMAIN_PS) != TelephonyManager.NETWORK_TYPE_LTE) { return false; } int nrState = state.getNrState(); Loading
tests/telephonytests/src/com/android/internal/telephony/metrics/ServiceStateStatsTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,10 @@ import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS; import static com.android.internal.telephony.TelephonyStatsLog.VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN; import com.android.internal.telephony.Phone; import com.android.internal.telephony.TelephonyTest; import com.android.internal.telephony.nano.PersistAtomsProto.CellularDataServiceSwitch; Loading Loading @@ -149,6 +153,7 @@ public class ServiceStateStatsTest extends TelephonyTest { doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegState(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getVoiceNetworkType(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getDataNetworkType(); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mServiceStateStats.onServiceStateChanged(mServiceState); Loading Loading @@ -248,6 +253,7 @@ public class ServiceStateStatsTest extends TelephonyTest { doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegState(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getVoiceNetworkType(); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getDataNetworkType(); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); doReturn(-1).when(mPhone).getCarrierId(); mServiceStateStats.onServiceStateChanged(mServiceState); Loading Loading @@ -395,6 +401,7 @@ public class ServiceStateStatsTest extends TelephonyTest { @SmallTest public void onServiceStateChanged_differentDataRats() throws Exception { doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getDataNetworkType(); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UNKNOWN); mServiceStateStats.onServiceStateChanged(mServiceState); Loading Loading @@ -881,6 +888,29 @@ public class ServiceStateStatsTest extends TelephonyTest { verifyNoMoreInteractions(mPersistAtomsStorage); } @Test @SmallTest public void getVoiceRat_bearer() throws Exception { mockWwanPsRat(TelephonyManager.NETWORK_TYPE_LTE); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_LTE); doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mImsStats).getImsVoiceRadioTech(); assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS)); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS)); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN)); mockWwanPsRat(TelephonyManager.NETWORK_TYPE_UMTS); mockWwanCsRat(TelephonyManager.NETWORK_TYPE_UMTS); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mImsStats).getImsVoiceRadioTech(); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS)); assertEquals(TelephonyManager.NETWORK_TYPE_UMTS, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS)); assertEquals(TelephonyManager.NETWORK_TYPE_LTE, mServiceStateStats.getVoiceRat( mPhone, mServiceState, VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_UNKNOWN)); } private void mockWwanPsRat(@NetworkType int rat) { mockWwanRat( NetworkRegistrationInfo.DOMAIN_PS, Loading
tests/telephonytests/src/com/android/internal/telephony/metrics/VoiceCallSessionStatsTest.java +59 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes