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;
}
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]);
}
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
}
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();
}
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();
}
Aggregations