Search in sources :

Example 26 with VoiceCallSession

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

the class VoiceCallSessionStatsTest method makeSlot0CallProto.

private static VoiceCallSession makeSlot0CallProto(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 = 0;
    call.isMultiSim = false;
    call.isEsim = false;
    call.carrierId = CARRIER_ID_SLOT_0;
    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 27 with VoiceCallSession

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

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

the class MetricsCollectorTest method onPullAtom_voiceCallSession_multipleCalls.

@Test
@SmallTest
public void onPullAtom_voiceCallSession_multipleCalls() throws Exception {
    VoiceCallSession call = new VoiceCallSession();
    doReturn(new VoiceCallSession[] { call, call, call, call }).when(mPersistAtomsStorage).getVoiceCallSessions(anyLong());
    List<StatsEvent> actualAtoms = new ArrayList<>();
    int result = mMetricsCollector.onPullAtom(VOICE_CALL_SESSION, actualAtoms);
    assertThat(actualAtoms).hasSize(4);
    assertThat(result).isEqualTo(StatsManager.PULL_SUCCESS);
// TODO(b/153196254): verify atom contents
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) StatsEvent(android.util.StatsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 29 with VoiceCallSession

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

the class PersistAtomsStorageTest method getVoiceCallSessions_withSavedAtoms.

@Test
@SmallTest
public void getVoiceCallSessions_withSavedAtoms() throws Exception {
    createTestFile(START_TIME_MILLIS);
    mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
    mPersistAtomsStorage.incTimeMillis(100L);
    VoiceCallSession[] voiceCallSession1 = mPersistAtomsStorage.getVoiceCallSessions(50L);
    mPersistAtomsStorage.incTimeMillis(100L);
    VoiceCallSession[] voiceCallSession2 = mPersistAtomsStorage.getVoiceCallSessions(50L);
    long voiceCallRatUsagePullTimestampMillis = mPersistAtomsStorage.getAtomsProto().rawVoiceCallRatUsagePullTimestampMillis;
    RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(50L);
    // first set of results should equal to file contents, second should be empty, corresponding
    // pull timestamp should be updated and saved, other fields should be unaffected
    assertProtoArrayEquals(mVoiceCallSessions, voiceCallSession1);
    assertProtoArrayEquals(new VoiceCallSession[0], voiceCallSession2);
    assertEquals(START_TIME_MILLIS + 200L, mPersistAtomsStorage.getAtomsProto().voiceCallSessionPullTimestampMillis);
    assertProtoArrayEquals(mVoiceCallRatUsages, voiceCallRatUsage);
    assertEquals(START_TIME_MILLIS, voiceCallRatUsagePullTimestampMillis);
    InOrder inOrder = inOrder(mTestFileOutputStream);
    assertEquals(START_TIME_MILLIS + 100L, getAtomsWritten(inOrder).voiceCallSessionPullTimestampMillis);
    assertEquals(START_TIME_MILLIS + 200L, getAtomsWritten(inOrder).voiceCallSessionPullTimestampMillis);
    assertEquals(START_TIME_MILLIS + 200L, getAtomsWritten(inOrder).rawVoiceCallRatUsagePullTimestampMillis);
    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 30 with VoiceCallSession

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

the class PersistAtomsStorageTest method addVoiceCallRatUsage_withExistingUsages.

@Test
@SmallTest
public void addVoiceCallRatUsage_withExistingUsages() throws Exception {
    createTestFile(100L);
    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);
    // call count and duration should become doubled since mVoiceCallRatUsages applied through
    // both file and addVoiceCallRatUsage()
    RawVoiceCallRatUsage[] expectedVoiceCallRatUsage = multiplyVoiceCallRatUsage(mVoiceCallRatUsages, 2);
    Arrays.sort(expectedVoiceCallRatUsage, sProtoComparator);
    Arrays.sort(voiceCallRatUsage, sProtoComparator);
    assertProtoArrayEquals(expectedVoiceCallRatUsage, voiceCallRatUsage);
    assertNotNull(voiceCallSession);
    assertEquals(mVoiceCallSessions.length, 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)

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