Search in sources :

Example 1 with ImsCallProfile

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

the class TelephonyMetrics method writeAudioCodecIms.

/**
 * Write audio codec event
 *
 * @param phoneId Phone id
 * @param session IMS call session
 */
public void writeAudioCodecIms(int phoneId, ImsCallSession session) {
    InProgressCallSession callSession = mInProgressCallSessions.get(phoneId);
    if (callSession == null) {
        Rlog.e(TAG, "Call session is missing");
        return;
    }
    ImsCallProfile localCallProfile = session.getLocalCallProfile();
    if (localCallProfile != null) {
        int codec = convertImsCodec(localCallProfile.mMediaProfile.mAudioQuality);
        callSession.addEvent(new CallSessionEventBuilder(TelephonyCallSession.Event.Type.AUDIO_CODEC).setCallIndex(getCallId(session)).setAudioCodec(codec));
        logv("Logged Audio Codec event. Value: " + codec);
    }
}
Also used : ImsCallProfile(android.telephony.ims.ImsCallProfile)

Example 2 with ImsCallProfile

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

the class ImsPhoneCallTracker method dialInternal.

private void dialInternal(ImsPhoneConnection conn, int clirMode, int videoState, int retryCallFailCause, int retryCallFailNetworkType, Bundle intentExtras) {
    if (conn == null) {
        return;
    }
    if (!conn.isAdhocConference() && (conn.getAddress() == null || conn.getAddress().length() == 0 || conn.getAddress().indexOf(PhoneNumberUtils.WILD) >= 0)) {
        // Phone number is invalid
        conn.setDisconnectCause(DisconnectCause.INVALID_NUMBER);
        sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
        return;
    }
    // Always unmute when initiating a new call
    setMute(false);
    boolean isEmergencyCall = mPhoneNumberUtilsProxy.isEmergencyNumber(conn.getAddress());
    int serviceType = isEmergencyCall ? ImsCallProfile.SERVICE_TYPE_EMERGENCY : ImsCallProfile.SERVICE_TYPE_NORMAL;
    int callType = ImsCallProfile.getCallTypeFromVideoState(videoState);
    // TODO(vt): Is this sufficient?  At what point do we know the video state of the call?
    conn.setVideoState(videoState);
    try {
        String[] callees = new String[] { conn.getAddress() };
        ImsCallProfile profile = mImsManager.createCallProfile(serviceType, callType);
        if (conn.isAdhocConference()) {
            profile.setCallExtraBoolean(ImsCallProfile.EXTRA_CONFERENCE, true);
        }
        profile.setCallExtraInt(ImsCallProfile.EXTRA_OIR, clirMode);
        profile.setCallExtraInt(ImsCallProfile.EXTRA_RETRY_CALL_FAIL_REASON, retryCallFailCause);
        profile.setCallExtraInt(ImsCallProfile.EXTRA_RETRY_CALL_FAIL_NETWORKTYPE, retryCallFailNetworkType);
        if (isEmergencyCall) {
            // Set emergency call information in ImsCallProfile
            setEmergencyCallInfo(profile, conn);
        }
        // ImsCallProfile key.
        if (intentExtras != null) {
            if (intentExtras.containsKey(android.telecom.TelecomManager.EXTRA_CALL_SUBJECT)) {
                intentExtras.putString(ImsCallProfile.EXTRA_DISPLAY_TEXT, cleanseInstantLetteringMessage(intentExtras.getString(android.telecom.TelecomManager.EXTRA_CALL_SUBJECT)));
            }
            if (conn.hasRttTextStream()) {
                profile.mMediaProfile.mRttMode = ImsStreamMediaProfile.RTT_MODE_FULL;
            }
            if (intentExtras.containsKey(ImsCallProfile.EXTRA_IS_CALL_PULL)) {
                profile.mCallExtras.putBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL, intentExtras.getBoolean(ImsCallProfile.EXTRA_IS_CALL_PULL));
                int dialogId = intentExtras.getInt(ImsExternalCallTracker.EXTRA_IMS_EXTERNAL_CALL_ID);
                conn.setIsPulledCall(true);
                conn.setPulledDialogId(dialogId);
            }
            // Pack the OEM-specific call extras.
            profile.mCallExtras.putBundle(ImsCallProfile.EXTRA_OEM_EXTRAS, intentExtras);
        // NOTE: Extras to be sent over the network are packed into the
        // intentExtras individually, with uniquely defined keys.
        // These key-value pairs are processed by IMS Service before
        // being sent to the lower layers/to the network.
        }
        mPhone.getVoiceCallSessionStats().onImsDial(conn);
        ImsCall imsCall = mImsManager.makeCall(profile, conn.isAdhocConference() ? conn.getParticipantsToDial() : callees, mImsCallListener);
        conn.setImsCall(imsCall);
        mMetrics.writeOnImsCallStart(mPhone.getPhoneId(), imsCall.getSession());
        setVideoCallProvider(conn, imsCall);
        conn.setAllowAddCallDuringVideoCall(mAllowAddCallDuringVideoCall);
        conn.setAllowHoldingVideoCall(mAllowHoldingVideoCall);
    } catch (ImsException e) {
        loge("dialInternal : " + e);
        mOperationLocalLog.log("dialInternal exception: " + e);
        conn.setDisconnectCause(DisconnectCause.ERROR_UNSPECIFIED);
        sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
        retryGetImsService();
    } catch (RemoteException e) {
    }
}
Also used : ImsCallProfile(android.telephony.ims.ImsCallProfile) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException) RemoteException(android.os.RemoteException) ImsMultiEndpoint(com.android.ims.ImsMultiEndpoint)

Example 3 with ImsCallProfile

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

the class ImsPhoneCallTracker method sendUSSD.

public void sendUSSD(String ussdString, Message response) {
    if (DBG)
        log("sendUSSD");
    try {
        if (mUssdSession != null) {
            // Doesn't need mPendingUssd here. Listeners would use it if not null.
            mPendingUssd = null;
            mUssdSession.sendUssd(ussdString);
            AsyncResult.forMessage(response, null, null);
            response.sendToTarget();
            return;
        }
        if (mImsManager == null) {
            mPhone.sendErrorResponse(response, getImsManagerIsNullException());
            return;
        }
        String[] callees = new String[] { ussdString };
        ImsCallProfile profile = mImsManager.createCallProfile(ImsCallProfile.SERVICE_TYPE_NORMAL, ImsCallProfile.CALL_TYPE_VOICE);
        profile.setCallExtraInt(ImsCallProfile.EXTRA_DIALSTRING, ImsCallProfile.DIALSTRING_USSD);
        mUssdSession = mImsManager.makeCall(profile, callees, mImsUssdListener);
        mPendingUssd = response;
        if (DBG)
            log("pending ussd updated, " + mPendingUssd);
    } catch (ImsException e) {
        loge("sendUSSD : " + e);
        mPhone.sendErrorResponse(response, e);
        retryGetImsService();
    }
}
Also used : ImsCallProfile(android.telephony.ims.ImsCallProfile) ImsException(com.android.ims.ImsException)

Example 4 with ImsCallProfile

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

the class TelephonyTest method setUp.

protected void setUp(String tag) throws Exception {
    TAG = tag;
    MockitoAnnotations.initMocks(this);
    TelephonyManager.disableServiceHandleCaching();
    SubscriptionController.disableCaching();
    mPhones = new Phone[] { mPhone };
    mImsCallProfile = new ImsCallProfile();
    mImsCallProfile.setCallerNumberVerificationStatus(ImsCallProfile.VERIFICATION_STATUS_PASSED);
    mSimulatedCommands = new SimulatedCommands();
    mContextFixture = new ContextFixture();
    mContext = mContextFixture.getTestDouble();
    mFakeBlockedNumberContentProvider = new FakeBlockedNumberContentProvider();
    ((MockContentResolver) mContext.getContentResolver()).addProvider(BlockedNumberContract.AUTHORITY, mFakeBlockedNumberContentProvider);
    mPhone.mCi = mSimulatedCommands;
    mCT.mCi = mSimulatedCommands;
    doReturn(mUiccCard).when(mPhone).getUiccCard();
    doReturn(mUiccProfile).when(mUiccCard).getUiccProfile();
    mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    mTelephonyRegistryManager = (TelephonyRegistryManager) mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE);
    mSubscriptionManager = (SubscriptionManager) mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
    mEuiccManager = (EuiccManager) mContext.getSystemService(Context.EUICC_SERVICE);
    mConnectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    mPackageManager = mContext.getPackageManager();
    mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
    mCarrierConfigManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
    mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    // mTelephonyComponentFactory
    doReturn(mTelephonyComponentFactory).when(mTelephonyComponentFactory).inject(anyString());
    doReturn(mSST).when(mTelephonyComponentFactory).makeServiceStateTracker(nullable(GsmCdmaPhone.class), nullable(CommandsInterface.class));
    doReturn(mEmergencyNumberTracker).when(mTelephonyComponentFactory).makeEmergencyNumberTracker(nullable(Phone.class), nullable(CommandsInterface.class));
    doReturn(getTestEmergencyNumber()).when(mEmergencyNumberTracker).getEmergencyNumber(any());
    doReturn(mUiccProfile).when(mTelephonyComponentFactory).makeUiccProfile(nullable(Context.class), nullable(CommandsInterface.class), nullable(IccCardStatus.class), anyInt(), nullable(UiccCard.class), nullable(Object.class));
    doReturn(mCT).when(mTelephonyComponentFactory).makeGsmCdmaCallTracker(nullable(GsmCdmaPhone.class));
    doReturn(mIccPhoneBookIntManager).when(mTelephonyComponentFactory).makeIccPhoneBookInterfaceManager(nullable(Phone.class));
    doReturn(mDcTracker).when(mTelephonyComponentFactory).makeDcTracker(nullable(Phone.class), anyInt());
    doReturn(mDisplayInfoController).when(mTelephonyComponentFactory).makeDisplayInfoController(nullable(Phone.class));
    doReturn(mWspTypeDecoder).when(mTelephonyComponentFactory).makeWspTypeDecoder(nullable(byte[].class));
    doReturn(mImsCT).when(mTelephonyComponentFactory).makeImsPhoneCallTracker(nullable(ImsPhone.class));
    doReturn(mCdmaSSM).when(mTelephonyComponentFactory).getCdmaSubscriptionSourceManagerInstance(nullable(Context.class), nullable(CommandsInterface.class), nullable(Handler.class), anyInt(), nullable(Object.class));
    doReturn(mImsExternalCallTracker).when(mTelephonyComponentFactory).makeImsExternalCallTracker(nullable(ImsPhone.class));
    doReturn(mAppSmsManager).when(mTelephonyComponentFactory).makeAppSmsManager(nullable(Context.class));
    doReturn(mCarrierSignalAgent).when(mTelephonyComponentFactory).makeCarrierSignalAgent(nullable(Phone.class));
    doReturn(mCarrierActionAgent).when(mTelephonyComponentFactory).makeCarrierActionAgent(nullable(Phone.class));
    doReturn(mDeviceStateMonitor).when(mTelephonyComponentFactory).makeDeviceStateMonitor(nullable(Phone.class));
    doReturn(mTransportManager).when(mTelephonyComponentFactory).makeTransportManager(nullable(Phone.class));
    doReturn(mNitzStateMachine).when(mTelephonyComponentFactory).makeNitzStateMachine(nullable(GsmCdmaPhone.class));
    doReturn(mLocaleTracker).when(mTelephonyComponentFactory).makeLocaleTracker(nullable(Phone.class), nullable(NitzStateMachine.class), nullable(Looper.class));
    doReturn(mDataEnabledSettings).when(mTelephonyComponentFactory).makeDataEnabledSettings(nullable(Phone.class));
    doReturn(mEriManager).when(mTelephonyComponentFactory).makeEriManager(nullable(Phone.class), anyInt());
    // mPhone
    doReturn(mContext).when(mPhone).getContext();
    doReturn(mContext).when(mImsPhone).getContext();
    doReturn(true).when(mPhone).getUnitTestMode();
    doReturn(mUiccProfile).when(mPhone).getIccCard();
    doReturn(mServiceState).when(mPhone).getServiceState();
    doReturn(mServiceState).when(mImsPhone).getServiceState();
    doReturn(mPhone).when(mImsPhone).getDefaultPhone();
    doReturn(true).when(mPhone).isPhoneTypeGsm();
    doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mPhone).getPhoneType();
    doReturn(mCT).when(mPhone).getCallTracker();
    doReturn(mSST).when(mPhone).getServiceStateTracker();
    doReturn(mDeviceStateMonitor).when(mPhone).getDeviceStateMonitor();
    doReturn(mDisplayInfoController).when(mPhone).getDisplayInfoController();
    doReturn(mEmergencyNumberTracker).when(mPhone).getEmergencyNumberTracker();
    doReturn(mCarrierSignalAgent).when(mPhone).getCarrierSignalAgent();
    doReturn(mCarrierActionAgent).when(mPhone).getCarrierActionAgent();
    doReturn(mAppSmsManager).when(mPhone).getAppSmsManager();
    doReturn(mIccSmsInterfaceManager).when(mPhone).getIccSmsInterfaceManager();
    doReturn(mTransportManager).when(mPhone).getTransportManager();
    doReturn(mDataEnabledSettings).when(mPhone).getDataEnabledSettings();
    doReturn(mDcTracker).when(mPhone).getDcTracker(anyInt());
    doReturn(mCarrierPrivilegesTracker).when(mPhone).getCarrierPrivilegesTracker();
    doReturn(mVoiceCallSessionStats).when(mPhone).getVoiceCallSessionStats();
    doReturn(mVoiceCallSessionStats).when(mImsPhone).getVoiceCallSessionStats();
    mIccSmsInterfaceManager.mDispatchersController = mSmsDispatchersController;
    // mUiccController
    doReturn(mUiccCardApplication3gpp).when(mUiccController).getUiccCardApplication(anyInt(), eq(UiccController.APP_FAM_3GPP));
    doReturn(mUiccCardApplication3gpp2).when(mUiccController).getUiccCardApplication(anyInt(), eq(UiccController.APP_FAM_3GPP2));
    doReturn(mUiccCardApplicationIms).when(mUiccController).getUiccCardApplication(anyInt(), eq(UiccController.APP_FAM_IMS));
    doAnswer(new Answer<IccRecords>() {

        public IccRecords answer(InvocationOnMock invocation) {
            switch((Integer) invocation.getArguments()[1]) {
                case UiccController.APP_FAM_3GPP:
                    return mSimRecords;
                case UiccController.APP_FAM_3GPP2:
                    return mRuimRecords;
                case UiccController.APP_FAM_IMS:
                    return mIsimUiccRecords;
                default:
                    logd("Unrecognized family " + invocation.getArguments()[1]);
                    return null;
            }
        }
    }).when(mUiccController).getIccRecords(anyInt(), anyInt());
    // UiccCardApplication
    doReturn(mSimRecords).when(mUiccCardApplication3gpp).getIccRecords();
    doReturn(mRuimRecords).when(mUiccCardApplication3gpp2).getIccRecords();
    doReturn(mIsimUiccRecords).when(mUiccCardApplicationIms).getIccRecords();
    // mUiccProfile
    doReturn(mSimRecords).when(mUiccProfile).getIccRecords();
    doAnswer(new Answer<IccRecords>() {

        public IccRecords answer(InvocationOnMock invocation) {
            return (mPhone.isPhoneTypeGsm()) ? mSimRecords : mRuimRecords;
        }
    }).when(mUiccProfile).getIccRecords();
    // mUiccProfile
    doReturn(mUiccCardApplication3gpp).when(mUiccProfile).getApplication(eq(UiccController.APP_FAM_3GPP));
    doReturn(mUiccCardApplication3gpp2).when(mUiccProfile).getApplication(eq(UiccController.APP_FAM_3GPP2));
    doReturn(mUiccCardApplicationIms).when(mUiccProfile).getApplication(eq(UiccController.APP_FAM_IMS));
    // SMS
    doReturn(true).when(mSmsStorageMonitor).isStorageAvailable();
    doReturn(true).when(mSmsUsageMonitor).check(nullable(String.class), anyInt());
    doReturn(true).when(mTelephonyManager).getSmsReceiveCapableForPhone(anyInt(), anyBoolean());
    doReturn(true).when(mTelephonyManager).getSmsSendCapableForPhone(anyInt(), anyBoolean());
    // Misc
    doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS).when(mServiceState).getRilDataRadioTechnology();
    doReturn(mPhone).when(mCT).getPhone();
    mImsManagerInstances.put(mPhone.getPhoneId(), mImsManager);
    doReturn(mImsEcbm).when(mImsManager).getEcbmInterface();
    doReturn(mPhone).when(mInboundSmsHandler).getPhone();
    doReturn(mImsCallProfile).when(mImsCall).getCallProfile();
    doReturn(mIBinder).when(mIIntentSender).asBinder();
    doReturn(mIIntentSender).when(mIActivityManager).getIntentSenderWithFeature(anyInt(), nullable(String.class), nullable(String.class), nullable(IBinder.class), nullable(String.class), anyInt(), nullable(Intent[].class), nullable(String[].class), anyInt(), nullable(Bundle.class), anyInt());
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
    doReturn(true).when(mTelephonyManager).isDataCapable();
    doReturn(TelephonyManager.PHONE_TYPE_GSM).when(mTelephonyManager).getPhoneType();
    doReturn(mServiceState).when(mSST).getServiceState();
    mSST.mSS = mServiceState;
    mSST.mRestrictedState = mRestrictedState;
    mServiceManagerMockedServices.put("connectivity_metrics_logger", mConnMetLoggerBinder);
    mServiceManagerMockedServices.put("package", mMockPackageManager);
    mServiceManagerMockedServices.put("permissionmgr", mMockPermissionManager);
    logd("mMockPermissionManager replaced");
    doReturn(new int[] { AccessNetworkConstants.TRANSPORT_TYPE_WWAN, AccessNetworkConstants.TRANSPORT_TYPE_WLAN }).when(mTransportManager).getAvailableTransports();
    doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).when(mTransportManager).getCurrentTransport(anyInt());
    doReturn(true).when(mDataEnabledSettings).isDataEnabled();
    doReturn(true).when(mDataEnabledSettings).isDataEnabled(anyInt());
    doReturn(true).when(mDataEnabledSettings).isInternalDataEnabled();
    doReturn(mNetworkRegistrationInfo).when(mServiceState).getNetworkRegistrationInfo(anyInt(), anyInt());
    doReturn(new HalVersion(1, 4)).when(mPhone).getHalVersion();
    // SIM
    doReturn(1).when(mTelephonyManager).getSimCount();
    doReturn(1).when(mTelephonyManager).getPhoneCount();
    doReturn(1).when(mTelephonyManager).getActiveModemCount();
    // Have getMaxPhoneCount always return the same value with getPhoneCount by default.
    doAnswer((invocation) -> Math.max(mTelephonyManager.getActiveModemCount(), mTelephonyManager.getPhoneCount())).when(mTelephonyManager).getSupportedModemCount();
    doReturn(mStatsManager).when(mContext).getSystemService(eq(Context.NETWORK_STATS_SERVICE));
    // Data
    // Initial state is: userData enabled, provisioned.
    ContentResolver resolver = mContext.getContentResolver();
    Settings.Global.putInt(resolver, Settings.Global.MOBILE_DATA, 1);
    Settings.Global.putInt(resolver, Settings.Global.DEVICE_PROVISIONED, 1);
    Settings.Global.putInt(resolver, Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED, 1);
    // CellularNetworkValidator
    doReturn(SubscriptionManager.INVALID_PHONE_INDEX).when(mCellularNetworkValidator).getSubIdInValidation();
    doReturn(true).when(mCellularNetworkValidator).isValidationFeatureSupported();
    // Metrics
    doReturn(null).when(mContext).getFileStreamPath(anyString());
    doReturn(mPersistAtomsStorage).when(mMetricsCollector).getAtomsStorage();
    // Use reflection to mock singletons
    replaceInstance(CallManager.class, "INSTANCE", null, mCallManager);
    replaceInstance(TelephonyComponentFactory.class, "sInstance", null, mTelephonyComponentFactory);
    replaceInstance(UiccController.class, "mInstance", null, mUiccController);
    replaceInstance(CdmaSubscriptionSourceManager.class, "sInstance", null, mCdmaSSM);
    replaceInstance(ImsManager.class, "sImsManagerInstances", null, mImsManagerInstances);
    replaceInstance(SubscriptionController.class, "sInstance", null, mSubscriptionController);
    replaceInstance(ProxyController.class, "sProxyController", null, mProxyController);
    replaceInstance(ActivityManager.class, "IActivityManagerSingleton", null, mIActivityManagerSingleton);
    replaceInstance(CdmaSubscriptionSourceManager.class, "mCdmaSubscriptionSourceChangedRegistrants", mCdmaSSM, mRegistrantList);
    replaceInstance(SimulatedCommandsVerifier.class, "sInstance", null, mSimulatedCommandsVerifier);
    replaceInstance(Singleton.class, "mInstance", mIActivityManagerSingleton, mIActivityManager);
    replaceInstance(ServiceManager.class, "sCache", null, mServiceManagerMockedServices);
    replaceInstance(IntentBroadcaster.class, "sIntentBroadcaster", null, mIntentBroadcaster);
    replaceInstance(TelephonyManager.class, "sInstance", null, mContext.getSystemService(Context.TELEPHONY_SERVICE));
    replaceInstance(TelephonyManager.class, "sServiceHandleCacheEnabled", null, false);
    replaceInstance(PhoneFactory.class, "sMadeDefaults", null, true);
    replaceInstance(PhoneFactory.class, "sPhone", null, mPhone);
    replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
    replaceInstance(PhoneFactory.class, "sSubInfoRecordUpdater", null, mSubInfoRecordUpdater);
    replaceInstance(RadioConfig.class, "sRadioConfig", null, mMockRadioConfig);
    replaceInstance(PhoneConfigurationManager.class, "sInstance", null, mPhoneConfigurationManager);
    replaceInstance(CellularNetworkValidator.class, "sInstance", null, mCellularNetworkValidator);
    replaceInstance(MultiSimSettingController.class, "sInstance", null, mMultiSimSettingController);
    replaceInstance(SubscriptionInfoUpdater.class, "sIsSubInfoInitialized", null, true);
    replaceInstance(PhoneFactory.class, "sCommandsInterfaces", null, new CommandsInterface[] { mSimulatedCommands });
    replaceInstance(PhoneFactory.class, "sMetricsCollector", null, mMetricsCollector);
    assertNotNull("Failed to set up SubscriptionController singleton", SubscriptionController.getInstance());
    setReady(false);
    // create default TestableLooper for test and add to list of monitored loopers
    mTestableLooper = TestableLooper.get(TelephonyTest.this);
    if (mTestableLooper != null) {
        monitorTestableLooper(mTestableLooper);
    }
}
Also used : Context(android.content.Context) IccCardStatus(com.android.internal.telephony.uicc.IccCardStatus) SimulatedCommands(com.android.internal.telephony.test.SimulatedCommands) IccRecords(com.android.internal.telephony.uicc.IccRecords) Bundle(android.os.Bundle) Handler(android.os.Handler) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MockContentResolver(android.test.mock.MockContentResolver) ImsPhone(com.android.internal.telephony.imsphone.ImsPhone) MockContentResolver(android.test.mock.MockContentResolver) ContentResolver(android.content.ContentResolver) UiccCard(com.android.internal.telephony.uicc.UiccCard) Looper(android.os.Looper) TestableLooper(android.testing.TestableLooper) IBinder(android.os.IBinder) ImsCallProfile(android.telephony.ims.ImsCallProfile) ImsPhone(com.android.internal.telephony.imsphone.ImsPhone) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 5 with ImsCallProfile

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

the class ImsPhoneCallTrackerTest method testRemoteToneInactive.

/**
 * Verifies that a remote hold tone is played when the call is remotely held and the media
 * direction is inactive (i.e. the audio stream is not playing, so we should play the tone).
 */
@Test
@SmallTest
public void testRemoteToneInactive() {
    // establish a MT call
    testImsMTCallAccept();
    ImsPhoneConnection connection = mCTUT.mForegroundCall.getFirstConnection();
    ImsCall call = connection.getImsCall();
    // Set the media direction to inactive to trigger a hold tone.
    ImsCallProfile callProfile = new ImsCallProfile();
    callProfile.mMediaProfile.mAudioDirection = ImsStreamMediaProfile.DIRECTION_INACTIVE;
    call.setCallProfile(callProfile);
    try {
        mCTUT.onCallHoldReceived(call);
    } catch (Exception ex) {
        ex.printStackTrace();
        Assert.fail("unexpected exception thrown" + ex.getMessage());
    }
    verify(mImsPhone, times(1)).startOnHoldTone(nullable(Connection.class));
}
Also used : ImsCallProfile(android.telephony.ims.ImsCallProfile) ImsCall(com.android.ims.ImsCall) Connection(com.android.internal.telephony.Connection) ImsException(com.android.ims.ImsException) RemoteException(android.os.RemoteException) CallStateException(com.android.internal.telephony.CallStateException) 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

ImsCallProfile (android.telephony.ims.ImsCallProfile)16 ImsCall (com.android.ims.ImsCall)8 ImsException (com.android.ims.ImsException)8 RemoteException (android.os.RemoteException)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 CallStateException (com.android.internal.telephony.CallStateException)5 Test (org.junit.Test)5 Connection (com.android.internal.telephony.Connection)4 TelephonyTest (com.android.internal.telephony.TelephonyTest)4 Bundle (android.os.Bundle)3 FlakyTest (androidx.test.filters.FlakyTest)3 ImsPhone (com.android.internal.telephony.imsphone.ImsPhone)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ContentResolver (android.content.ContentResolver)1 Context (android.content.Context)1 NetworkCapabilities (android.net.NetworkCapabilities)1 AsyncResult (android.os.AsyncResult)1 Handler (android.os.Handler)1 IBinder (android.os.IBinder)1