Search in sources :

Example 16 with RawVoiceCallRatUsage

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

the class MetricsCollectorTest method onPullAtom_voiceCallRatUsage_bucketWithTooFewCalls.

@Test
@SmallTest
public void onPullAtom_voiceCallRatUsage_bucketWithTooFewCalls() throws Exception {
    RawVoiceCallRatUsage usage1 = new RawVoiceCallRatUsage();
    usage1.callCount = MIN_CALLS_PER_BUCKET;
    RawVoiceCallRatUsage usage2 = new RawVoiceCallRatUsage();
    usage2.callCount = MIN_CALLS_PER_BUCKET - 1L;
    doReturn(new RawVoiceCallRatUsage[] { usage1, usage1, usage1, usage2 }).when(mPersistAtomsStorage).getVoiceCallRatUsages(anyLong());
    List<StatsEvent> actualAtoms = new ArrayList<>();
    int result = mMetricsCollector.onPullAtom(VOICE_CALL_RAT_USAGE, actualAtoms);
    // usage 2 should be dropped
    assertThat(actualAtoms).hasSize(3);
    assertThat(result).isEqualTo(StatsManager.PULL_SUCCESS);
// TODO(b/153196254): verify atom contents
}
Also used : ArrayList(java.util.ArrayList) RawVoiceCallRatUsage(com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage) 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 17 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage 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 18 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage 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)

Example 19 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage 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 20 with RawVoiceCallRatUsage

use of com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage 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)

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