Search in sources :

Example 31 with VoiceCallSession

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

the class PersistAtomsStorageTest method makeTestData.

private void makeTestData() {
    // MO call with SRVCC (LTE to UMTS)
    mCall1Proto = new VoiceCallSession();
    mCall1Proto.bearerAtStart = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS;
    mCall1Proto.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS;
    mCall1Proto.direction = VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MO;
    mCall1Proto.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_VERY_FAST;
    mCall1Proto.setupFailed = false;
    mCall1Proto.disconnectReasonCode = DisconnectCause.LOCAL;
    mCall1Proto.disconnectExtraCode = 0;
    mCall1Proto.disconnectExtraMessage = "";
    mCall1Proto.ratAtStart = TelephonyManager.NETWORK_TYPE_LTE;
    mCall1Proto.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    mCall1Proto.ratSwitchCount = 1L;
    mCall1Proto.codecBitmask = (1 << AudioCodec.AUDIO_CODEC_EVS_SWB) | (1 << AudioCodec.AUDIO_CODEC_AMR);
    mCall1Proto.concurrentCallCountAtStart = 0;
    mCall1Proto.concurrentCallCountAtEnd = 0;
    mCall1Proto.simSlotIndex = 0;
    mCall1Proto.isMultiSim = false;
    mCall1Proto.isEsim = false;
    mCall1Proto.carrierId = CARRIER1_ID;
    mCall1Proto.srvccCompleted = true;
    mCall1Proto.srvccFailureCount = 0L;
    mCall1Proto.srvccCancellationCount = 0L;
    mCall1Proto.rttEnabled = false;
    mCall1Proto.isEmergency = false;
    mCall1Proto.isRoaming = false;
    // VoLTE MT call on DSDS/eSIM, hanged up by remote
    // concurrent with mCall3Proto, started first and ended first
    mCall2Proto = new VoiceCallSession();
    mCall2Proto.bearerAtStart = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS;
    mCall2Proto.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS;
    mCall2Proto.direction = VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT;
    mCall2Proto.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_VERY_FAST;
    mCall2Proto.setupFailed = false;
    mCall2Proto.disconnectReasonCode = ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE;
    mCall2Proto.disconnectExtraCode = 0;
    mCall2Proto.disconnectExtraMessage = "normal call clearing";
    mCall2Proto.ratAtStart = TelephonyManager.NETWORK_TYPE_LTE;
    mCall2Proto.ratAtEnd = TelephonyManager.NETWORK_TYPE_LTE;
    mCall2Proto.ratSwitchCount = 0L;
    mCall2Proto.codecBitmask = (1 << AudioCodec.AUDIO_CODEC_EVS_SWB);
    mCall2Proto.concurrentCallCountAtStart = 0;
    mCall2Proto.concurrentCallCountAtEnd = 1;
    mCall2Proto.simSlotIndex = 1;
    mCall2Proto.isMultiSim = true;
    mCall2Proto.isEsim = true;
    mCall2Proto.carrierId = CARRIER2_ID;
    mCall2Proto.srvccCompleted = false;
    mCall2Proto.srvccFailureCount = 0L;
    mCall2Proto.srvccCancellationCount = 0L;
    mCall2Proto.rttEnabled = false;
    mCall2Proto.isEmergency = false;
    mCall2Proto.isRoaming = false;
    // VoLTE MT call on DSDS/eSIM, hanged up by local, with RTT
    // concurrent with mCall2Proto, started last and ended last
    mCall3Proto = new VoiceCallSession();
    mCall3Proto.bearerAtStart = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS;
    mCall3Proto.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS;
    mCall3Proto.direction = VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MT;
    mCall3Proto.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_EXTREMELY_FAST;
    mCall3Proto.setupFailed = false;
    mCall3Proto.disconnectReasonCode = ImsReasonInfo.CODE_USER_TERMINATED;
    mCall3Proto.disconnectExtraCode = 0;
    mCall3Proto.disconnectExtraMessage = "normal call clearing";
    mCall3Proto.ratAtStart = TelephonyManager.NETWORK_TYPE_LTE;
    mCall3Proto.ratAtEnd = TelephonyManager.NETWORK_TYPE_LTE;
    mCall3Proto.ratSwitchCount = 0L;
    mCall3Proto.codecBitmask = (1 << AudioCodec.AUDIO_CODEC_EVS_SWB);
    mCall3Proto.concurrentCallCountAtStart = 1;
    mCall3Proto.concurrentCallCountAtEnd = 0;
    mCall3Proto.simSlotIndex = 1;
    mCall3Proto.isMultiSim = true;
    mCall3Proto.isEsim = true;
    mCall3Proto.carrierId = CARRIER2_ID;
    mCall3Proto.srvccCompleted = false;
    mCall3Proto.srvccFailureCount = 0L;
    mCall3Proto.srvccCancellationCount = 0L;
    mCall3Proto.rttEnabled = true;
    mCall3Proto.isEmergency = false;
    mCall3Proto.isRoaming = false;
    // CS MO call while camped on LTE
    mCall4Proto = new VoiceCallSession();
    mCall4Proto.bearerAtStart = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS;
    mCall4Proto.bearerAtEnd = VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_CS;
    mCall4Proto.direction = VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MO;
    mCall4Proto.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_VERY_SLOW;
    mCall4Proto.setupFailed = true;
    mCall4Proto.disconnectReasonCode = DisconnectCause.NORMAL;
    mCall4Proto.disconnectExtraCode = 0;
    mCall4Proto.disconnectExtraMessage = "";
    mCall4Proto.ratAtStart = TelephonyManager.NETWORK_TYPE_LTE;
    mCall4Proto.ratAtEnd = TelephonyManager.NETWORK_TYPE_GSM;
    mCall4Proto.ratSwitchCount = 1L;
    mCall4Proto.codecBitmask = (1 << AudioCodec.AUDIO_CODEC_AMR);
    mCall4Proto.concurrentCallCountAtStart = 0;
    mCall4Proto.concurrentCallCountAtEnd = 0;
    mCall4Proto.simSlotIndex = 0;
    mCall4Proto.isMultiSim = true;
    mCall4Proto.isEsim = false;
    mCall4Proto.carrierId = CARRIER3_ID;
    mCall4Proto.srvccCompleted = false;
    mCall4Proto.srvccFailureCount = 0L;
    mCall4Proto.srvccCancellationCount = 0L;
    mCall4Proto.rttEnabled = false;
    mCall4Proto.isEmergency = false;
    mCall4Proto.isRoaming = true;
    mCarrier1LteUsageProto = new RawVoiceCallRatUsage();
    mCarrier1LteUsageProto.carrierId = CARRIER1_ID;
    mCarrier1LteUsageProto.rat = TelephonyManager.NETWORK_TYPE_LTE;
    mCarrier1LteUsageProto.callCount = 1L;
    mCarrier1LteUsageProto.totalDurationMillis = 8000L;
    mCarrier1UmtsUsageProto = new RawVoiceCallRatUsage();
    mCarrier1UmtsUsageProto.carrierId = CARRIER1_ID;
    mCarrier1UmtsUsageProto.rat = TelephonyManager.NETWORK_TYPE_UMTS;
    mCarrier1UmtsUsageProto.callCount = 1L;
    mCarrier1UmtsUsageProto.totalDurationMillis = 6000L;
    mCarrier2LteUsageProto = new RawVoiceCallRatUsage();
    mCarrier2LteUsageProto.carrierId = CARRIER2_ID;
    mCarrier2LteUsageProto.rat = TelephonyManager.NETWORK_TYPE_LTE;
    mCarrier2LteUsageProto.callCount = 2L;
    mCarrier2LteUsageProto.totalDurationMillis = 20000L;
    mCarrier3LteUsageProto = new RawVoiceCallRatUsage();
    mCarrier3LteUsageProto.carrierId = CARRIER3_ID;
    mCarrier3LteUsageProto.rat = TelephonyManager.NETWORK_TYPE_LTE;
    mCarrier3LteUsageProto.callCount = 1L;
    mCarrier3LteUsageProto.totalDurationMillis = 1000L;
    mCarrier3GsmUsageProto = new RawVoiceCallRatUsage();
    mCarrier3GsmUsageProto.carrierId = CARRIER3_ID;
    mCarrier3GsmUsageProto.rat = TelephonyManager.NETWORK_TYPE_GSM;
    mCarrier3GsmUsageProto.callCount = 1L;
    mCarrier3GsmUsageProto.totalDurationMillis = 100000L;
    mVoiceCallRatUsages = new RawVoiceCallRatUsage[] { mCarrier1UmtsUsageProto, mCarrier1LteUsageProto, mCarrier2LteUsageProto, mCarrier3LteUsageProto, mCarrier3GsmUsageProto };
    mVoiceCallSessions = new VoiceCallSession[] { mCall1Proto, mCall2Proto, mCall3Proto, mCall4Proto };
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage)

Example 32 with VoiceCallSession

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

the class PersistAtomsStorageTest method addVoiceCallRatUsage_emptyProto.

@Test
@SmallTest
public void addVoiceCallRatUsage_emptyProto() throws Exception {
    createEmptyTestFile();
    VoiceCallRatTracker ratTracker = VoiceCallRatTracker.fromProto(mVoiceCallRatUsages);
    mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
    mPersistAtomsStorage.addVoiceCallRatUsage(ratTracker);
    mPersistAtomsStorage.incTimeMillis(100L);
    // RAT should be added successfully, calls should not change, changes should be saved
    RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(0L);
    VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(0L);
    RawVoiceCallRatUsage[] expectedVoiceCallRatUsage = mVoiceCallRatUsages.clone();
    Arrays.sort(expectedVoiceCallRatUsage, sProtoComparator);
    Arrays.sort(voiceCallRatUsage, sProtoComparator);
    assertProtoArrayEquals(expectedVoiceCallRatUsage, voiceCallRatUsage);
    assertNotNull(voiceCallSession);
    assertEquals(0, voiceCallSession.length);
    InOrder inOrder = inOrder(mTestFileOutputStream);
    inOrder.verify(mTestFileOutputStream, times(1)).write(eq(PersistAtoms.toByteArray(mPersistAtomsStorage.getAtomsProto())));
    inOrder.verify(mTestFileOutputStream, times(1)).close();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 33 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method concurrentImsCalls_firstCallHangupLast.

@Test
@SmallTest
public void concurrentImsCalls_firstCallHangupLast() {
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
    // 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();
    VoiceCallSession expectedCall0 = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MO, TelephonyManager.NETWORK_TYPE_LTE, ImsReasonInfo.CODE_USER_TERMINATED);
    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 = 0;
    expectedCall0.ratSwitchCount = 2L;
    expectedCall0.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    // 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();
    VoiceCallSession expectedCall1 = 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_BY_REMOTE);
    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 = 1;
    expectedCall1.ratSwitchCount = 1L;
    expectedCall1.ratAtEnd = TelephonyManager.NETWORK_TYPE_HSPA;
    RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 80000L, 2L);
    RawVoiceCallRatUsage expectedRatUsageHspa = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_HSPA, 80000L, 100000L, 2L);
    RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 100000L, 120000L, 1L);
    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);
    // RAT change, LTE to HSPA
    mVoiceCallSessionStats0.setTimeMillis(80000L);
    doReturn(TelephonyManager.NETWORK_TYPE_HSPA).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    // call 1 hangup by remote
    mVoiceCallSessionStats0.setTimeMillis(90000L);
    mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection1, new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE, 0));
    // RAT change, HSPA to UMTS
    mVoiceCallSessionStats0.setTimeMillis(100000L);
    doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    // call 0 hangup by local
    mVoiceCallSessionStats0.setTimeMillis(120000L);
    mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED, 0));
    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, 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 34 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method singleImsCall_dsdsModeSingleSim.

@Test
@SmallTest
public void singleImsCall_dsdsModeSingleSim() {
    doReturn(mInactiveCard).when(mEsimSlot).getUiccCard();
    doReturn(new UiccSlot[] { mPhysicalSlot, mEsimSlot }).when(mUiccController).getUiccSlots();
    doReturn(mEsimSlot).when(mUiccController).getUiccSlot(eq(1));
    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;
    // DSDS with one active SIM profile should not count
    expectedCall.isMultiSim = false;
    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());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) 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 35 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method singleImsCall_esim.

@Test
@SmallTest
public void singleImsCall_esim() {
    doReturn(mActiveCard).when(mEsimSlot).getUiccCard();
    doReturn(new UiccSlot[] { mPhysicalSlot, mEsimSlot }).when(mUiccController).getUiccSlots();
    doReturn(mEsimSlot).when(mUiccController).getUiccSlot(eq(1));
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mSecondServiceState).getVoiceNetworkType();
    doReturn(true).when(mImsConnection1).isIncoming();
    doReturn(2000L).when(mImsConnection1).getCreateTime();
    doReturn(mImsCall1).when(mImsConnection1).getCall();
    doReturn(new ArrayList(List.of(mImsConnection1))).when(mImsCall1).getConnections();
    VoiceCallSession expectedCall = makeSlot1CallProto(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;
    mVoiceCallSessionStats1.setTimeMillis(2000L);
    doReturn(Call.State.INCOMING).when(mImsCall1).getState();
    doReturn(Call.State.INCOMING).when(mImsConnection1).getState();
    mVoiceCallSessionStats1.onImsCallReceived(mImsConnection1);
    mVoiceCallSessionStats1.setTimeMillis(2100L);
    mVoiceCallSessionStats1.onAudioCodecChanged(mImsConnection1, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
    mVoiceCallSessionStats1.setTimeMillis(8000L);
    mVoiceCallSessionStats1.onImsCallTerminated(mImsConnection1, 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());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) 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)

Aggregations

VoiceCallSession (com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession)48 SmallTest (android.test.suitebuilder.annotation.SmallTest)36 TelephonyTest (com.android.internal.telephony.TelephonyTest)36 Test (org.junit.Test)36 RawVoiceCallRatUsage (com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage)28 ArrayList (java.util.ArrayList)24 ImsReasonInfo (android.telephony.ims.ImsReasonInfo)21 InOrder (org.mockito.InOrder)6 Connection (com.android.internal.telephony.Connection)2 GsmCdmaConnection (com.android.internal.telephony.GsmCdmaConnection)2 ImsPhoneConnection (com.android.internal.telephony.imsphone.ImsPhoneConnection)2 ServiceState (android.telephony.ServiceState)1 StatsEvent (android.util.StatsEvent)1 FileOutputStream (java.io.FileOutputStream)1