Search in sources :

Example 11 with VoiceCallSession

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

the class PersistAtomsStorageTest method loadAtoms_malformedFile.

@Test
@SmallTest
public void loadAtoms_malformedFile() throws Exception {
    FileOutputStream stream = new FileOutputStream(mTestFile);
    stream.write("This is not a proto file.".getBytes(StandardCharsets.UTF_8));
    stream.close();
    mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
    mPersistAtomsStorage.incTimeMillis(100L);
    // no exception should be thrown, storage should be empty, pull time should be start time
    assertEquals(START_TIME_MILLIS, mPersistAtomsStorage.getAtomsProto().rawVoiceCallRatUsagePullTimestampMillis);
    assertEquals(START_TIME_MILLIS, mPersistAtomsStorage.getAtomsProto().voiceCallSessionPullTimestampMillis);
    RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(0L);
    VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(0L);
    assertNotNull(voiceCallRatUsage);
    assertEquals(0, voiceCallRatUsage.length);
    assertNotNull(voiceCallSession);
    assertEquals(0, voiceCallSession.length);
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) FileOutputStream(java.io.FileOutputStream) 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 12 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method singleImsCall_mtAccepted.

@Test
@SmallTest
public void singleImsCall_mtAccepted() {
    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;
    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(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]);
}
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 13 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method makeSlot1CallProto.

private static VoiceCallSession makeSlot1CallProto(int bearer, int direction, int rat, int reason) {
    VoiceCallSession call = new VoiceCallSession();
    call.bearerAtStart = bearer;
    call.bearerAtEnd = bearer;
    call.direction = direction;
    call.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_UNKNOWN;
    call.setupFailed = true;
    call.disconnectReasonCode = reason;
    call.disconnectExtraCode = 0;
    call.disconnectExtraMessage = "";
    call.ratAtStart = rat;
    call.ratAtEnd = rat;
    call.ratSwitchCount = 0L;
    call.codecBitmask = 0L;
    call.simSlotIndex = 1;
    call.isMultiSim = true;
    call.isEsim = true;
    call.carrierId = CARRIER_ID_SLOT_1;
    call.srvccCompleted = false;
    call.srvccFailureCount = 0L;
    call.srvccCancellationCount = 0L;
    call.rttEnabled = false;
    call.isEmergency = false;
    call.isRoaming = false;
    call.setupBeginMillis = 0L;
    return call;
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession)

Example 14 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method singleImsCall_roaming.

@Test
@SmallTest
public void singleImsCall_roaming() {
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
    doReturn(true).when(mServiceState).getVoiceRoaming();
    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;
    expectedCall.isRoaming = 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());
}
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 15 with VoiceCallSession

use of com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession 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]);
}
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

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