Search in sources :

Example 6 with VoiceCallSession

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

the class VoiceCallSessionStats method finishCall.

/**
 * Sends the call metrics to persist storage when it is finished.
 */
private void finishCall(int connectionId) {
    VoiceCallSession proto = mCallProtos.get(connectionId);
    if (proto == null) {
        loge("finishCall: could not find call to be removed");
        return;
    }
    mCallProtos.delete(connectionId);
    proto.concurrentCallCountAtEnd = mCallProtos.size();
    // ensure internal fields are cleared
    proto.setupBeginMillis = 0L;
    // sanitize for javanano & StatsEvent
    if (proto.disconnectExtraMessage == null) {
        proto.disconnectExtraMessage = "";
    }
    mAtomsStorage.addVoiceCallSession(proto);
    // merge RAT usages to PersistPullers when the call session ends (i.e. no more active calls)
    if (!hasCalls()) {
        mRatUsage.conclude(getTimeMillis());
        mAtomsStorage.addVoiceCallRatUsage(mRatUsage);
        mRatUsage.clear();
    }
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession)

Example 7 with VoiceCallSession

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

the class PersistAtomsStorageTest method addVoiceCallSession_emptyProto.

@Test
@SmallTest
public void addVoiceCallSession_emptyProto() throws Exception {
    createEmptyTestFile();
    mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
    mPersistAtomsStorage.addVoiceCallSession(mCall1Proto);
    mPersistAtomsStorage.incTimeMillis(100L);
    // call should be added successfully, there should be no RAT usage, changes should be saved
    RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(0L);
    VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(0L);
    assertNotNull(voiceCallRatUsage);
    assertEquals(0, voiceCallRatUsage.length);
    assertProtoArrayEquals(new VoiceCallSession[] { mCall1Proto }, voiceCallSession);
    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 8 with VoiceCallSession

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

the class PersistAtomsStorageTest method getVoiceCallRatUsages_withSavedAtoms.

@Test
@SmallTest
public void getVoiceCallRatUsages_withSavedAtoms() throws Exception {
    createTestFile(START_TIME_MILLIS);
    mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
    mPersistAtomsStorage.incTimeMillis(100L);
    RawVoiceCallRatUsage[] voiceCallRatUsage1 = mPersistAtomsStorage.getVoiceCallRatUsages(50L);
    mPersistAtomsStorage.incTimeMillis(100L);
    RawVoiceCallRatUsage[] voiceCallRatUsage2 = mPersistAtomsStorage.getVoiceCallRatUsages(50L);
    long voiceCallSessionPullTimestampMillis = mPersistAtomsStorage.getAtomsProto().voiceCallSessionPullTimestampMillis;
    VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(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(mVoiceCallRatUsages, voiceCallRatUsage1);
    assertProtoArrayEquals(new RawVoiceCallRatUsage[0], voiceCallRatUsage2);
    assertEquals(START_TIME_MILLIS + 200L, mPersistAtomsStorage.getAtomsProto().rawVoiceCallRatUsagePullTimestampMillis);
    assertProtoArrayEquals(mVoiceCallSessions, voiceCallSession);
    assertEquals(START_TIME_MILLIS, voiceCallSessionPullTimestampMillis);
    InOrder inOrder = inOrder(mTestFileOutputStream);
    assertEquals(START_TIME_MILLIS + 100L, getAtomsWritten(inOrder).rawVoiceCallRatUsagePullTimestampMillis);
    assertEquals(START_TIME_MILLIS + 200L, getAtomsWritten(inOrder).rawVoiceCallRatUsagePullTimestampMillis);
    assertEquals(START_TIME_MILLIS + 200L, getAtomsWritten(inOrder).voiceCallSessionPullTimestampMillis);
    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 9 with VoiceCallSession

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

the class PersistAtomsStorageTest method addVoiceCallSession_withExistingCalls.

@Test
@SmallTest
public void addVoiceCallSession_withExistingCalls() throws Exception {
    createTestFile(100L);
    mPersistAtomsStorage = new TestablePersistAtomsStorage(mContext);
    mPersistAtomsStorage.addVoiceCallSession(mCall1Proto);
    mPersistAtomsStorage.incTimeMillis(100L);
    // call should be added successfully, RAT usages should not change, changes should be saved
    RawVoiceCallRatUsage[] voiceCallRatUsage = mPersistAtomsStorage.getVoiceCallRatUsages(0L);
    VoiceCallSession[] voiceCallSession = mPersistAtomsStorage.getVoiceCallSessions(0L);
    assertNotNull(voiceCallRatUsage);
    assertEquals(mVoiceCallRatUsages.length, voiceCallRatUsage.length);
    assertNotNull(voiceCallSession);
    // call lists are randomized, but sorted version should be identical
    VoiceCallSession[] expectedVoiceCallSessions = new VoiceCallSession[] { mCall1Proto, mCall1Proto, mCall2Proto, mCall3Proto, mCall4Proto };
    Arrays.sort(expectedVoiceCallSessions, sProtoComparator);
    Arrays.sort(voiceCallSession, sProtoComparator);
    assertProtoArrayEquals(expectedVoiceCallSessions, voiceCallSession);
    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 10 with VoiceCallSession

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

the class PersistAtomsStorageTest method assertHasCall.

private static void assertHasCall(VoiceCallSession[] calls, @Nullable VoiceCallSession expectedCall, int expectedCount) {
    assertNotNull(calls);
    int actualCount = 0;
    for (VoiceCallSession call : calls) {
        if (call != null && expectedCall != null) {
            if (MessageNano.messageNanoEquals(call, expectedCall)) {
                actualCount++;
            }
        }
    }
    assertEquals(expectedCount, actualCount);
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession)

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