Search in sources :

Example 21 with ImsReasonInfo

use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleImsCall_codecSwitch.

@Test
@SmallTest
public void singleImsCall_codecSwitch() {
    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 | 1L << AudioCodec.AUDIO_CODEC_EVS_SWB;
    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(4000L);
    mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection0, ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB);
    mVoiceCallSessionStats0.setTimeMillis(8000L);
    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());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) 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 22 with ImsReasonInfo

use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleImsCall_dsdsMode.

@Test
@SmallTest
public void singleImsCall_dsdsMode() {
    doReturn(mActiveCard).when(mEsimSlot).getUiccCard();
    doReturn(new UiccSlot[] { mPhysicalSlot, mEsimSlot }).when(mUiccController).getUiccSlots();
    doReturn(mEsimSlot).when(mUiccController).getUiccSlot(eq(1));
    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_LOCAL_CALL_DECLINE);
    expectedCall.setupFailed = true;
    expectedCall.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
    expectedCall.isMultiSim = 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());
}
Also used : VoiceCallSession(com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession) ArrayList(java.util.ArrayList) 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 23 with ImsReasonInfo

use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method singleImsCall_ratSwitch.

@Test
@SmallTest
public void singleImsCall_ratSwitch() {
    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;
    expectedCall.ratSwitchCount = 2L;
    expectedCall.ratAtEnd = TelephonyManager.NETWORK_TYPE_UMTS;
    RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 4000L, 1L);
    RawVoiceCallRatUsage expectedRatUsageHspa = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_HSPA, 4000L, 6000L, 1L);
    RawVoiceCallRatUsage expectedRatUsageUmts = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_UMTS, 6000L, 8000L, 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(4000L);
    doReturn(TelephonyManager.NETWORK_TYPE_HSPA).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    mVoiceCallSessionStats0.setTimeMillis(6000L);
    doReturn(TelephonyManager.NETWORK_TYPE_UMTS).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    mVoiceCallSessionStats0.setTimeMillis(8000L);
    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());
    assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageHspa, expectedRatUsageUmts }, ratUsage.get());
}
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 24 with ImsReasonInfo

use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.

the class VoiceCallSessionStatsTest method concurrentImsCalls_firstCallHangupDuringSecondCallSetup.

@Test
@SmallTest
public void concurrentImsCalls_firstCallHangupDuringSecondCallSetup() {
    doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mServiceState).getVoiceNetworkType();
    // call 0 starts first, MO
    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 expectedCall0 = makeSlot0CallProto(VOICE_CALL_SESSION__BEARER_AT_END__CALL_BEARER_IMS, VOICE_CALL_SESSION__DIRECTION__CALL_DIRECTION_MO, TelephonyManager.NETWORK_TYPE_LTE, ImsReasonInfo.CODE_USER_TERMINATED);
    expectedCall0.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_ULTRA_FAST;
    expectedCall0.setupFailed = false;
    expectedCall0.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
    expectedCall0.concurrentCallCountAtStart = 0;
    expectedCall0.concurrentCallCountAtEnd = 1;
    expectedCall0.ratSwitchCount = 0L;
    expectedCall0.ratAtEnd = TelephonyManager.NETWORK_TYPE_LTE;
    // call 1 starts later, MT
    doReturn(true).when(mImsConnection1).isIncoming();
    doReturn(60000L).when(mImsConnection1).getCreateTime();
    doReturn(mImsCall1).when(mImsConnection1).getCall();
    doReturn(new ArrayList(List.of(mImsConnection1))).when(mImsCall1).getConnections();
    VoiceCallSession expectedCall1 = 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_BY_REMOTE);
    expectedCall1.setupDuration = VOICE_CALL_SESSION__SETUP_DURATION__CALL_SETUP_DURATION_EXTREMELY_FAST;
    expectedCall1.setupFailed = false;
    expectedCall1.codecBitmask = 1L << AudioCodec.AUDIO_CODEC_AMR;
    expectedCall1.concurrentCallCountAtStart = 1;
    expectedCall1.concurrentCallCountAtEnd = 0;
    expectedCall1.ratSwitchCount = 1L;
    expectedCall1.ratAtEnd = TelephonyManager.NETWORK_TYPE_HSPA;
    RawVoiceCallRatUsage expectedRatUsageLte = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_LTE, 2000L, 80000L, 2L);
    RawVoiceCallRatUsage expectedRatUsageHspa = makeRatUsageProto(CARRIER_ID_SLOT_0, TelephonyManager.NETWORK_TYPE_HSPA, 80000L, 90000L, 1L);
    final AtomicReference<RawVoiceCallRatUsage[]> ratUsage = setupRatUsageCapture();
    // call 0 dial
    mVoiceCallSessionStats0.setTimeMillis(2000L);
    doReturn(Call.State.DIALING).when(mImsCall0).getState();
    doReturn(Call.State.DIALING).when(mImsConnection0).getState();
    mVoiceCallSessionStats0.onImsDial(mImsConnection0);
    mVoiceCallSessionStats0.setTimeMillis(2020L);
    mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection0, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
    mVoiceCallSessionStats0.setTimeMillis(2080L);
    doReturn(Call.State.ALERTING).when(mImsCall0).getState();
    doReturn(Call.State.ALERTING).when(mImsConnection0).getState();
    mVoiceCallSessionStats0.onCallStateChanged(mImsCall0);
    mVoiceCallSessionStats0.setTimeMillis(4000L);
    doReturn(Call.State.ACTIVE).when(mImsCall0).getState();
    doReturn(Call.State.ACTIVE).when(mImsConnection0).getState();
    mVoiceCallSessionStats0.onCallStateChanged(mImsCall0);
    // call 1 ring
    mVoiceCallSessionStats0.setTimeMillis(60000L);
    doReturn(Call.State.INCOMING).when(mImsCall1).getState();
    doReturn(Call.State.INCOMING).when(mImsConnection1).getState();
    mVoiceCallSessionStats0.onImsCallReceived(mImsConnection1);
    mVoiceCallSessionStats0.setTimeMillis(60100L);
    mVoiceCallSessionStats0.onAudioCodecChanged(mImsConnection1, ImsStreamMediaProfile.AUDIO_QUALITY_AMR);
    // call 0 hangup by local
    mVoiceCallSessionStats0.setTimeMillis(61000L);
    mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection0, new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED, 0));
    mVoiceCallSessionStats0.setTimeMillis(65000L);
    mVoiceCallSessionStats0.onImsAcceptCall(List.of(mImsConnection1));
    mVoiceCallSessionStats0.setTimeMillis(65020L);
    doReturn(Call.State.ACTIVE).when(mImsCall1).getState();
    doReturn(Call.State.ACTIVE).when(mImsConnection1).getState();
    mVoiceCallSessionStats0.onCallStateChanged(mImsCall1);
    // RAT change, LTE to HSPA
    mVoiceCallSessionStats0.setTimeMillis(80000L);
    doReturn(TelephonyManager.NETWORK_TYPE_HSPA).when(mServiceState).getVoiceNetworkType();
    mVoiceCallSessionStats0.onServiceStateChanged(mServiceState);
    // call 1 hangup by remote
    mVoiceCallSessionStats0.setTimeMillis(90000L);
    mVoiceCallSessionStats0.onImsCallTerminated(mImsConnection1, new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE, 0));
    ArgumentCaptor<VoiceCallSession> callCaptor = ArgumentCaptor.forClass(VoiceCallSession.class);
    verify(mPersistAtomsStorage, times(2)).addVoiceCallSession(callCaptor.capture());
    verify(mPersistAtomsStorage, times(1)).addVoiceCallRatUsage(any());
    verifyNoMoreInteractions(mPersistAtomsStorage);
    assertSortedProtoArrayEquals(new VoiceCallSession[] { expectedCall0, expectedCall1 }, callCaptor.getAllValues().stream().toArray(VoiceCallSession[]::new));
    assertSortedProtoArrayEquals(new RawVoiceCallRatUsage[] { expectedRatUsageLte, expectedRatUsageHspa }, ratUsage.get());
}
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 25 with ImsReasonInfo

use of android.telephony.ims.ImsReasonInfo in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneTest method testProcessDisconnectReason.

@Test
@SmallTest
public void testProcessDisconnectReason() throws Exception {
    // set up CarrierConfig
    mBundle.putStringArray(CarrierConfigManager.KEY_WFC_OPERATOR_ERROR_CODES_STRING_ARRAY, new String[] { "REG09|0" });
    doReturn(true).when(mImsManager).isWfcEnabledByUser();
    // set up overlays
    String title = "title";
    String messageAlert = "Alert!";
    String messageNotification = "Notification!";
    mContextFixture.putStringArrayResource(com.android.internal.R.array.wfcOperatorErrorAlertMessages, new String[] { messageAlert });
    mContextFixture.putStringArrayResource(com.android.internal.R.array.wfcOperatorErrorNotificationMessages, new String[] { messageNotification });
    mContextFixture.putResource(com.android.internal.R.string.wfcRegErrorTitle, title);
    mImsPhoneUT.processDisconnectReason(new ImsReasonInfo(ImsReasonInfo.CODE_REGISTRATION_ERROR, 0, "REG09"));
    ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
    verify(mContext).sendOrderedBroadcast(intent.capture(), nullable(String.class), any(BroadcastReceiver.class), nullable(Handler.class), eq(Activity.RESULT_OK), nullable(String.class), nullable(Bundle.class));
    assertEquals(android.telephony.ims.ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR, intent.getValue().getAction());
    assertEquals(title, intent.getValue().getStringExtra(android.telephony.ims.ImsManager.EXTRA_WFC_REGISTRATION_FAILURE_TITLE));
    assertEquals(messageAlert, intent.getValue().getStringExtra(android.telephony.ims.ImsManager.EXTRA_WFC_REGISTRATION_FAILURE_MESSAGE));
    assertEquals(messageNotification, intent.getValue().getStringExtra(Phone.EXTRA_KEY_NOTIFICATION_MESSAGE));
}
Also used : Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) Handler(android.os.Handler) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) ImsReasonInfo(android.telephony.ims.ImsReasonInfo) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ImsReasonInfo (android.telephony.ims.ImsReasonInfo)31 Test (org.junit.Test)26 SmallTest (android.test.suitebuilder.annotation.SmallTest)25 TelephonyTest (com.android.internal.telephony.TelephonyTest)25 VoiceCallSession (com.android.internal.telephony.nano.PersistAtomsProto.VoiceCallSession)21 ArrayList (java.util.ArrayList)21 RawVoiceCallRatUsage (com.android.internal.telephony.nano.PersistAtomsProto.RawVoiceCallRatUsage)13 FlakyTest (androidx.test.filters.FlakyTest)3 ImsCall (com.android.ims.ImsCall)3 BroadcastReceiver (android.content.BroadcastReceiver)1 Intent (android.content.Intent)1 NetworkCapabilities (android.net.NetworkCapabilities)1 AsyncResult (android.os.AsyncResult)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 PersistableBundle (android.os.PersistableBundle)1 ImsCallProfile (android.telephony.ims.ImsCallProfile)1 RegistrationCallback (android.telephony.ims.ImsMmTelManager.RegistrationCallback)1 RegistrationCallback (android.telephony.ims.RegistrationManager.RegistrationCallback)1 ImsFeature (android.telephony.ims.feature.ImsFeature)1