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