use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleImsCall_mtRejected.
@Test
@SmallTest
public void singleImsCall_mtRejected() {
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
doReturn(true).when(mImsConnection0).isIncoming();
doReturn(2000L).when(mImsConnection0).getCreateTime();
doReturn(mImsCall0).when(mImsConnection0).getCall();
doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsCall0).getConnections();
VoiceCallSession expectedCall = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT, TelephonyManager.NETWORK_TYPE_LTE, ImsReasonInfo.CODE_LOCAL_CALL_DECLINE);
expectedCall.setupFailed = true;
expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
RawVoiceCallRatUsage expectedRatUsage = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 8000L, 1L);
final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
mVoiceCallSessionStats0.setTimeMillis(2000L);
doReturn(Call.State.INCOMING).when(mImsCall0).getState();
doReturn(Call.State.INCOMING).when(mImsConnection0).getState();
mVoiceCallSessionStats0.onImsCallReceived(mImsConnection0);
mVoiceCallSessionStats0.setTimeMillis(2100L);
mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection0, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
mVoiceCallSessionStats0.setTimeMillis(8000L);
mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_CALL_DECLINE, 0));
ArgumentCaptor<VoiceCallSession> callCaptor = ArgumentCaptor.forClass(VoiceCallSession.class);
verify(mPersistAtomsStorage, times(1)).addVoiceCallSession(callCaptor.capture());
verify(mPersistAtomsStorage, times(1)).addVoiceCallRatUsage(any());
verifyNoMoreInteractions(mPersistAtomsStorage);
assertProtoEquals(expectedCall, callCaptor.getValue());
assertThat(ratUsage.get()).hasLength(1);
assertProtoEquals(expectedRatUsage, ratUsage.get()[0]);
}
use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleImsCall_rttStartedMidCall.
@Test
@SmallTest
public void singleImsCall_rttStartedMidCall() {
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
doReturn(true).when(mImsConnection0).isIncoming();
doReturn(2000L).when(mImsConnection0).getCreateTime();
doReturn(mImsCall0).when(mImsConnection0).getCall();
doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsCall0).getConnections();
VoiceCallSession expectedCall = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT, TelephonyManager.NETWORK_TYPE_LTE, ImsReasonInfo.CODE_USER_TERMINATED);
expectedCall.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_ULTRA_FAST;
expectedCall.setupFailed = false;
expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
expectedCall.rttEnabled = true;
mVoiceCallSessionStats0.setTimeMillis(2000L);
doReturn(Call.State.INCOMING).when(mImsCall0).getState();
doReturn(Call.State.INCOMING).when(mImsConnection0).getState();
mVoiceCallSessionStats0.onImsCallReceived(mImsConnection0);
mVoiceCallSessionStats0.setTimeMillis(2100L);
mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection0, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
mVoiceCallSessionStats0.setTimeMillis(2200L);
mVoiceCallSessionStats0.onImsAcceptCall(List.of(mImsConnection0));
mVoiceCallSessionStats0.setTimeMillis(2280L);
doReturn(Call.State.ACTIVE).when(mImsCall0).getState();
doReturn(Call.State.ACTIVE).when(mImsConnection0).getState();
mVoiceCallSessionStats0.onCallStateChanged(mImsCall0);
mVoiceCallSessionStats0.setTimeMillis(4000L);
mVoiceCallSessionStats0.onRttStarted(mImsConnection0);
mVoiceCallSessionStats0.setTimeMillis(8000L);
mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED, 0));
ArgumentCaptor<VoiceCallSession> callCaptor = ArgumentCaptor.forClass(VoiceCallSession.class);
verify(mPersistAtomsStorage, times(1)).addVoiceCallSession(callCaptor.capture());
verify(mPersistAtomsStorage, times(1)).addVoiceCallRatUsage(any());
verifyNoMoreInteractions(mPersistAtomsStorage);
assertProtoEquals(expectedCall, callCaptor.getValue());
}
use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleImsCall_emergency.
@Test
@SmallTest
public void singleImsCall_emergency() {
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
doReturn(true).when(mImsConnection0).isIncoming();
doReturn(2000L).when(mImsConnection0).getCreateTime();
doReturn(true).when(mImsConnection0).isEmergencyCall();
doReturn(mImsCall0).when(mImsConnection0).getCall();
doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsCall0).getConnections();
VoiceCallSession expectedCall = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT, TelephonyManager.NETWORK_TYPE_LTE, ImsReasonInfo.CODE_LOCAL_CALL_DECLINE);
expectedCall.setupFailed = true;
expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
expectedCall.isEmergency = true;
mVoiceCallSessionStats0.setTimeMillis(2000L);
doReturn(Call.State.INCOMING).when(mImsCall0).getState();
doReturn(Call.State.INCOMING).when(mImsConnection0).getState();
mVoiceCallSessionStats0.onImsCallReceived(mImsConnection0);
mVoiceCallSessionStats0.setTimeMillis(2100L);
mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection0, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
mVoiceCallSessionStats0.setTimeMillis(8000L);
mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_CALL_DECLINE, 0));
ArgumentCaptor<VoiceCallSession> callCaptor = ArgumentCaptor.forClass(VoiceCallSession.class);
verify(mPersistAtomsStorage, times(1)).addVoiceCallSession(callCaptor.capture());
verify(mPersistAtomsStorage, times(1)).addVoiceCallRatUsage(any());
verifyNoMoreInteractions(mPersistAtomsStorage);
assertProtoEquals(expectedCall, callCaptor.getValue());
}
use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleImsCall_moFailed.
@Test
@SmallTest
public void singleImsCall_moFailed() {
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
doReturn(false).when(mImsConnection0).isIncoming();
doReturn(2000L).when(mImsConnection0).getCreateTime();
doReturn(mImsCall0).when(mImsConnection0).getCall();
doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsCall0).getConnections();
VoiceCallSession expectedCall = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MO, TelephonyManager.NETWORK_TYPE_LTE, ImsReasonInfo.CODE_SIP_FORBIDDEN);
expectedCall.setupFailed = true;
RawVoiceCallRatUsage expectedRatUsage = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 2200L, 1L);
final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
mVoiceCallSessionStats0.setTimeMillis(2000L);
doReturn(Call.State.DIALING).when(mImsCall0).getState();
doReturn(Call.State.DIALING).when(mImsConnection0).getState();
mVoiceCallSessionStats0.onImsDial(mImsConnection0);
mVoiceCallSessionStats0.setTimeMillis(2200L);
mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_SIP_FORBIDDEN, 0));
ArgumentCaptor<VoiceCallSession> callCaptor = ArgumentCaptor.forClass(VoiceCallSession.class);
verify(mPersistAtomsStorage, times(1)).addVoiceCallSession(callCaptor.capture());
verify(mPersistAtomsStorage, times(1)).addVoiceCallRatUsage(any());
verifyNoMoreInteractions(mPersistAtomsStorage);
assertProtoEquals(expectedCall, callCaptor.getValue());
assertThat(ratUsage.get()).hasLength(1);
assertProtoEquals(expectedRatUsage, ratUsage.get()[0]);
}
use of android.telephony.ims.ImsReasonInfo in project robolectric by robolectric.
the class ShadowImsMmTelManagerTest method registerImsRegistrationCallback_imsUnregistered_onUnregisteredInvoked.
@Test
public void registerImsRegistrationCallback_imsUnregistered_onUnregisteredInvoked() throws ImsException {
RegistrationCallback registrationCallback = mock(RegistrationCallback.class);
shadowImsMmTelManager.registerImsRegistrationCallback(Runnable::run, registrationCallback);
ImsReasonInfo imsReasonInfoWithCallbackRegistered = new ImsReasonInfo();
shadowImsMmTelManager.setImsUnregistered(imsReasonInfoWithCallbackRegistered);
verify(registrationCallback).onUnregistered(imsReasonInfoWithCallbackRegistered);
ImsReasonInfo imsReasonInfoAfterUnregisteringCallback = new ImsReasonInfo();
shadowImsMmTelManager.unregisterImsRegistrationCallback(registrationCallback);
shadowImsMmTelManager.setImsUnregistered(imsReasonInfoAfterUnregisteringCallback);
verifyNoMoreInteractions(registrationCallback);
}
Aggregations