use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleCsCall_mtRejected.
@Test
@SmallTest
public void singleCsCall_mtRejected() {
doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
doReturn(true).when(mGsmConnection0).isIncoming();
doReturn(2000L).when(mGsmConnection0).getCreateTime();
doReturn(mCsCall0).when(mGsmConnection0).getCall();
VoiceCallSession expectedCall = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT, TelephonyManager.NETWORK_TYPE_UMTS, DisconnectCause.NORMAL);
expectedCall.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_UNKNOWN;
expectedCall.disconnectExtraCode = PreciseDisconnectCause.CALL_REJECTED;
expectedCall.setupFailed = true;
expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
RawVoiceCallRatUsage expectedRatUsage = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 2500L, 15000L, 1L);
final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
mVoiceCallSessionStats0.setTimeMillis(2000L);
mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
mVoiceCallSessionStats0.setTimeMillis(2500L);
doReturn(Call.State.INCOMING).when(mCsCall0).getState();
doReturn(Call.State.INCOMING).when(mGsmConnection0).getState();
doReturn(DisconnectCause.NOT_DISCONNECTED).when(mGsmConnection0).getDisconnectCause();
mVoiceCallSessionStats0.onRilCallListChanged(List.of(mGsmConnection0));
mVoiceCallSessionStats0.setTimeMillis(3000L);
mVoiceCallSessionStats0.onAudioCodecChanged(mGsmConnection0, DriverCall.AUDIO_QUALITY_AMR);
mVoiceCallSessionStats0.setTimeMillis(15000L);
doReturn(DisconnectCause.NORMAL).when(mGsmConnection0).getDisconnectCause();
doReturn(PreciseDisconnectCause.CALL_REJECTED).when(mGsmConnection0).getPreciseDisconnectCause();
mVoiceCallSessionStats0.onRilCallListChanged(List.of(mGsmConnection0));
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 com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleCall_srvccFailed.
@Test
@SmallTest
public void singleCall_srvccFailed() {
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();
doReturn(mImsPhone).when(mPhone).getImsPhone();
doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsPhone).getHandoverConnection();
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_HO_NOT_FEASIBLE);
expectedCall.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_ULTRA_FAST;
expectedCall.setupFailed = false;
expectedCall.srvccFailureCount = 2L;
expectedCall.ratSwitchCount = 1L;
expectedCall.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 10000L, 1L);
RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 10000L, 12000L, 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(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(9000L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
mVoiceCallSessionStats0.setTimeMillis(10000L);
doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
mVoiceCallSessionStats0.setTimeMillis(11000L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_FAILED);
mVoiceCallSessionStats0.setTimeMillis(11100L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
mVoiceCallSessionStats0.setTimeMillis(11500L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_FAILED);
mVoiceCallSessionStats0.setTimeMillis(12000L);
mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_HO_NOT_FEASIBLE, 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());
assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageUmts }, ratUsage.get());
}
use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleCall_srvccCanceled.
@Test
@SmallTest
public void singleCall_srvccCanceled() {
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();
doReturn(mImsPhone).when(mPhone).getImsPhone();
doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsPhone).getHandoverConnection();
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.srvccCancellationCount = 2L;
expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
RawVoiceCallRatUsage expectedRatUsage = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 12000L, 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(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(9500L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
mVoiceCallSessionStats0.setTimeMillis(10000L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_CANCELED);
mVoiceCallSessionStats0.setTimeMillis(10500L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
mVoiceCallSessionStats0.setTimeMillis(11000L);
mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_CANCELED);
mVoiceCallSessionStats0.setTimeMillis(12000L);
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());
assertThat(ratUsage.get()).hasLength(1);
assertProtoEquals(expectedRatUsage, ratUsage.get()[0]);
}
use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method singleWifiCall_airPlaneMode.
@Test
@SmallTest
public void singleWifiCall_airPlaneMode() {
doReturn(TelephonyManager.NETWORK_TYPE_UNKNOWN).when(mServiceState).getVoiceNetworkType();
doReturn(TelephonyManager.NETWORK_TYPE_IWLAN).when(mServiceState).getDataNetworkType();
doReturn(mImsPhone).when(mPhone).getImsPhone();
doReturn(true).when(mImsPhone).isWifiCallingEnabled();
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_IWLAN, 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_IWLAN, 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 com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.
the class VoiceCallSessionStatsTest method makeRatUsageProto.
private static RawVoiceCallRatUsage makeRatUsageProto(int carrierId, int rat, long beginMillis, long endMillis, long callCount) {
RawVoiceCallRatUsage usage = new RawVoiceCallRatUsage();
usage.carrierId = carrierId;
usage.rat = rat;
usage.totalDurationMillis = endMillis - beginMillis;
usage.callCount = callCount;
return usage;
}
Aggregations