Search in sources :

Example 26 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleWifiCall_preferred.

@Test
@SmallTest
public void singleWifiCall_preferred() {
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).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]);
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) ImsReasonInfo(android.telephony.ims.ImsReasonInfo) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 27 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleCall_srvccSuccess.

@Test
@SmallTest
public void singleCall_srvccSuccess() {
    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();
    doReturn(2000L).when(mGsmConnection0).getCreateTime();
    doReturn(mCsCall0).when(mGsmConnection0).getCall();
    VoiceCallSession expectedCall = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT, TelephonyManager.NETWORK_TYPE_LTE, DisconnectCause.NORMAL);
    expectedCall.disconnectExtraCode = PreciseDisconnectCause.NORMAL;
    expectedCall.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_ULTRA_FAST;
    expectedCall.setupFailed = false;
    expectedCall.srvccCancellationCount = 1L;
    expectedCall.srvccFailureCount = 1L;
    expectedCall.srvccCompleted = true;
    expectedCall.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS;
    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, 7000L, 1L);
    RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 7000L, 12000L, 1L);
    final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
    // IMS call created
    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);
    // canceled SRVCC attempt
    mVoiceCallSessionStats0.setTimeMillis(4500L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
    mVoiceCallSessionStats0.setTimeMillis(5000L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_CANCELED);
    // failed SRVCC attempt
    mVoiceCallSessionStats0.setTimeMillis(6500L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
    mVoiceCallSessionStats0.setTimeMillis(7000L);
    doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    mVoiceCallSessionStats0.setTimeMillis(8000L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_FAILED);
    // successful SRVCC attempt
    mVoiceCallSessionStats0.setTimeMillis(9000L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED);
    // CS call terminated
    mVoiceCallSessionStats0.setTimeMillis(12000L);
    doReturn(DisconnectCause.NORMAL).when(mGsmConnection0).getDisconnectCause();
    doReturn(PreciseDisconnectCause.NORMAL).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());
    assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageUmts }, ratUsage.get());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 28 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method concurrentCalls_srvcc.

@Test
@SmallTest
public void concurrentCalls_srvcc() {
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
    doReturn(mImsPhone).when(mPhone).getImsPhone();
    doReturn(new ArrayList(List.of(mImsConnection0, mImsConnection1))).when(mImsPhone).getHandoverConnection();
    // call 0 starts first, MO
    doReturn(false).when(mImsConnection0).isIncoming();
    doReturn(2000L).when(mImsConnection0).getCreateTime();
    doReturn(mImsCall0).when(mImsConnection0).getCall();
    doReturn(new ArrayList(List.of(mImsConnection0))).when(mImsCall0).getConnections();
    doReturn(2000L).when(mGsmConnection0).getCreateTime();
    doReturn(mCsCall0).when(mGsmConnection0).getCall();
    VoiceCallSession expectedCall0 = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MO, TelephonyManager.NETWORK_TYPE_LTE, DisconnectCause.NORMAL);
    expectedCall0.disconnectExtraCode = PreciseDisconnectCause.NORMAL;
    expectedCall0.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_ULTRA_FAST;
    expectedCall0.setupFailed = false;
    expectedCall0.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
    expectedCall0.concurrentCallCountAtStart = 0;
    expectedCall0.concurrentCallCountAtEnd = 1;
    expectedCall0.ratSwitchCount = 1L;
    expectedCall0.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    expectedCall0.srvccCompleted = true;
    expectedCall0.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS;
    // call 1 starts later, MT
    doReturn(true).when(mImsConnection1).isIncoming();
    doReturn(60000L).when(mImsConnection1).getCreateTime();
    doReturn(mImsCall1).when(mImsConnection1).getCall();
    doReturn(new ArrayList(List.of(mImsConnection1))).when(mImsCall1).getConnections();
    doReturn(60000L).when(mGsmConnection1).getCreateTime();
    doReturn(mCsCall1).when(mGsmConnection1).getCall();
    VoiceCallSession expectedCall1 = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT, TelephonyManager.NETWORK_TYPE_LTE, DisconnectCause.NORMAL);
    expectedCall1.disconnectExtraCode = PreciseDisconnectCause.NORMAL;
    expectedCall1.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_EXTREMELY_FAST;
    expectedCall1.setupFailed = false;
    expectedCall1.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
    expectedCall1.concurrentCallCountAtStart = 1;
    expectedCall1.concurrentCallCountAtEnd = 0;
    expectedCall1.ratSwitchCount = 1L;
    expectedCall1.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    expectedCall1.srvccCompleted = true;
    expectedCall1.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS;
    RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 80000L, 2L);
    RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 80000L, 120000L, 2L);
    final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
    // call 0 dial
    mVoiceCallSessionStats0.setTimeMillis(2000L);
    doReturn(Call.State.DIALING).when(mImsCall0).getState();
    doReturn(Call.State.DIALING).when(mImsConnection0).getState();
    mVoiceCallSessionStats0.onImsDial(mImsConnection0);
    mVoiceCallSessionStats0.setTimeMillis(2020L);
    mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection0, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
    mVoiceCallSessionStats0.setTimeMillis(2080L);
    doReturn(Call.State.ALERTING).when(mImsCall0).getState();
    doReturn(Call.State.ALERTING).when(mImsConnection0).getState();
    mVoiceCallSessionStats0.onCallStateChanged(mImsCall0);
    mVoiceCallSessionStats0.setTimeMillis(4000L);
    doReturn(Call.State.ACTIVE).when(mImsCall0).getState();
    doReturn(Call.State.ACTIVE).when(mImsConnection0).getState();
    mVoiceCallSessionStats0.onCallStateChanged(mImsCall0);
    // call 1 ring
    mVoiceCallSessionStats0.setTimeMillis(60000L);
    doReturn(Call.State.INCOMING).when(mImsCall1).getState();
    doReturn(Call.State.INCOMING).when(mImsConnection1).getState();
    mVoiceCallSessionStats0.onImsCallReceived(mImsConnection1);
    mVoiceCallSessionStats0.setTimeMillis(60100L);
    mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection1, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
    mVoiceCallSessionStats0.setTimeMillis(65000L);
    mVoiceCallSessionStats0.onImsAcceptCall(List.of(mImsConnection1));
    mVoiceCallSessionStats0.setTimeMillis(65020L);
    doReturn(Call.State.ACTIVE).when(mImsCall1).getState();
    doReturn(Call.State.ACTIVE).when(mImsConnection1).getState();
    mVoiceCallSessionStats0.onCallStateChanged(mImsCall1);
    // SRVCC affecting all IMS calls
    mVoiceCallSessionStats0.setTimeMillis(75000L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_STARTED);
    // RAT change, LTE to UMTS
    mVoiceCallSessionStats0.setTimeMillis(80000L);
    doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    mVoiceCallSessionStats0.setTimeMillis(85000L);
    mVoiceCallSessionStats0.onRilSrvccStateChanged(TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED);
    // call 0 hangup
    mVoiceCallSessionStats0.setTimeMillis(90000L);
    doReturn(DisconnectCause.NORMAL).when(mGsmConnection0).getDisconnectCause();
    doReturn(PreciseDisconnectCause.NORMAL).when(mGsmConnection0).getPreciseDisconnectCause();
    mVoiceCallSessionStats0.onRilCallListChanged(List.of(mGsmConnection0));
    // call 1 hangup
    mVoiceCallSessionStats0.setTimeMillis(120000L);
    doReturn(DisconnectCause.NORMAL).when(mGsmConnection1).getDisconnectCause();
    doReturn(PreciseDisconnectCause.NORMAL).when(mGsmConnection1).getPreciseDisconnectCause();
    mVoiceCallSessionStats0.onRilCallListChanged(List.of(mGsmConnection1));
    ArgumentCaptor<VoiceCallSession> callCaptor = ArgumentCaptor.forClass(VoiceCallSession.class);
    verify(mPersistAtomsStorage, times(2)).addVoiceCallSession(callCaptor.capture());
    verify(mPersistAtomsStorage, times(1)).addVoiceCallRatUsage(any());
    verifyNoMoreInteractions(mPersistAtomsStorage);
    assertSortedProtoArrayEquals(new VoiceCallSession[] { expectedCall0, expectedCall1 }, callCaptor.getAllValues().stream().toArray(VoiceCallSession[]::new));
    assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageUmts }, ratUsage.get());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 29 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleImsCall_ratSwitch.

@Test
@SmallTest
public void singleImsCall_ratSwitch() {
    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.ratSwitchCount = 2L;
    expectedCall.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 4000L, 1L);
    RawVoiceCallRatUsage expectedRatUsageHspa = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_HSPA, 4000L, 6000L, 1L);
    RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 6000L, 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(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);
    doReturn(TelephonyManager.NETWORK_TYPE_HSPA).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    mVoiceCallSessionStats0.setTimeMillis(6000L);
    doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    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());
    assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageHspa, expectedRatUsageUmts }, ratUsage.get());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) ImsReasonInfo(android.telephony.ims.ImsReasonInfo) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 30 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleCsCall_moFailed.

@Test
@SmallTest
public void singleCsCall_moFailed() {
    doReturn(false).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_MO, TelephonyManager.NETWORK_TYPE_LTE, DisconnectCause.LOST_SIGNAL);
    expectedCall.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    expectedCall.ratSwitchCount = 1L;
    expectedCall.setupFailed = true;
    expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
    RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 3000L, 1L);
    RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 3000L, 15000L, 1L);
    final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
    mVoiceCallSessionStats0.setTimeMillis(2000L);
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
    doReturn(Call.State.DIALING).when(mCsCall0).getState();
    doReturn(Call.State.DIALING).when(mGsmConnection0).getState();
    doReturn(DisconnectCause.NOT_DISCONNECTED).when(mGsmConnection0).getDisconnectCause();
    mVoiceCallSessionStats0.onRilDial(mGsmConnection0);
    mVoiceCallSessionStats0.setTimeMillis(3000L);
    doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    mVoiceCallSessionStats0.setTimeMillis(3100L);
    mVoiceCallSessionStats0.onAudioCodecChanged(mGsmConnection0, DriverCall.AUDIO_QUALITY_AMR);
    mVoiceCallSessionStats0.setTimeMillis(15000L);
    doReturn(DisconnectCause.LOST_SIGNAL).when(mGsmConnection0).getDisconnectCause();
    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());
    assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageUmts }, ratUsage.get());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

RawVoiceCallRatUsage (com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage)32 SmallTest (android.test.suitebuilder.annotation.SmallTest)28 TelephonyTest (com.android.internal.telephony.TelephonyTest)28 VoiceCallSession (com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession)28 Test (org.junit.Test)28 ArrayList (java.util.ArrayList)16 ImsReasonInfo (android.telephony.ims.ImsReasonInfo)13 InOrder (org.mockito.InOrder)6 StatsEvent (android.util.StatsEvent)1 FileOutputStream (java.io.FileOutputStream)1