Search in sources :

Example 26 with ImsReasonInfo

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

the class TelephonyMetricsTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp(getClass().getSimpleName());
    mMetrics = new TelephonyMetrics();
    mMetrics.setContext(mContext);
    mUusInfo = new UUSInfo(1, 2, new byte[] { 1, 2 });
    doReturn("123").when(mImsCallSession).getCallId();
    mImsReasonInfo = new ImsReasonInfo();
    mImsReasonInfo.mExtraMessage = "extramessage";
    mImsReasonInfo.mCode = 123;
    mImsReasonInfo.mExtraCode = 456;
    doReturn(ROAMING_TYPE_DOMESTIC).when(mServiceState).getVoiceRoamingType();
    doReturn(ROAMING_TYPE_DOMESTIC).when(mServiceState).getDataRoamingType();
    doReturn("short").when(mServiceState).getOperatorAlphaShort();
    doReturn("long").when(mServiceState).getOperatorAlphaLong();
    doReturn("123456").when(mServiceState).getOperatorNumeric();
    doReturn(RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState).getRilVoiceRadioTechnology();
    doReturn(RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState).getRilDataRadioTechnology();
    doReturn(FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange();
    doReturn(NR_STATE_NONE).when(mServiceState).getNrState();
}
Also used : UUSInfo(com.android.internal.telephony.UUSInfo) ImsReasonInfo(android.telephony.ims.ImsReasonInfo) Before(org.junit.Before)

Example 27 with ImsReasonInfo

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

the class ImsPhoneCallTrackerTest method testNotifyHandovers.

/**
 * Test notification of handover from LTE to WIFI and WIFI to LTE and ensure that the expected
 * connection events are sent.
 */
@Test
@SmallTest
public void testNotifyHandovers() {
    setupCarrierConfig();
    // establish a MT call
    testImsMTCallAccept();
    ImsPhoneConnection connection = (ImsPhoneConnection) mCTUT.mForegroundCall.getConnections().get(0);
    ImsCall call = connection.getImsCall();
    // Needs to be a video call to see this signalling.
    mImsCallProfile.mCallType = ImsCallProfile.CALL_TYPE_VT;
    // First handover from LTE to WIFI; this takes us into a mid-call state.
    call.getImsCallSessionListenerProxy().callSessionHandover(call.getCallSession(), TelephonyManager.NETWORK_TYPE_LTE, TelephonyManager.NETWORK_TYPE_IWLAN, new ImsReasonInfo());
    // Handover back to LTE.
    call.getImsCallSessionListenerProxy().callSessionHandover(call.getCallSession(), TelephonyManager.NETWORK_TYPE_IWLAN, TelephonyManager.NETWORK_TYPE_LTE, new ImsReasonInfo());
    verify(mImsPhoneConnectionListener).onConnectionEvent(eq(TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_WIFI_TO_LTE), isNull());
    // Finally hand back to WIFI
    call.getImsCallSessionListenerProxy().callSessionHandover(call.getCallSession(), TelephonyManager.NETWORK_TYPE_LTE, TelephonyManager.NETWORK_TYPE_IWLAN, new ImsReasonInfo());
    verify(mImsPhoneConnectionListener).onConnectionEvent(eq(TelephonyManager.EVENT_HANDOVER_VIDEO_FROM_LTE_TO_WIFI), isNull());
}
Also used : ImsCall(com.android.ims.ImsCall) 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)

Example 28 with ImsReasonInfo

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

the class ImsPhoneCallTrackerTest method testNoHoldErrorMessageWhenCallDisconnected.

@Test
@SmallTest
public void testNoHoldErrorMessageWhenCallDisconnected() {
    when(mImsPhoneConnection.getImsCall()).thenReturn(mImsCall);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) {
            fail("Error message showed when the call has already been disconnected!");
            return null;
        }
    }).when(mImsPhoneConnection).onConnectionEvent(eq(android.telecom.Connection.EVENT_CALL_HOLD_FAILED), any());
    mCTUT.getConnections().add(mImsPhoneConnection);
    when(mImsPhoneConnection.getState()).thenReturn(ImsPhoneCall.State.DISCONNECTED);
    ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_UNSPECIFIED, ImsReasonInfo.CODE_UNSPECIFIED, null);
    mCTUT.getImsCallListener().onCallHoldFailed(mImsPhoneConnection.getImsCall(), info);
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) 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)

Example 29 with ImsReasonInfo

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

the class ImsPhoneCallTracker method handleMessage.

// ****** Overridden from Handler
@Override
public void handleMessage(Message msg) {
    AsyncResult ar;
    if (DBG)
        log("handleMessage what=" + msg.what);
    switch(msg.what) {
        case EVENT_HANGUP_PENDINGMO:
            if (mPendingMO != null) {
                mPendingMO.onDisconnect();
                removeConnection(mPendingMO);
                mPendingMO = null;
            }
            mPendingIntentExtras = null;
            updatePhoneState();
            mPhone.notifyPreciseCallStateChanged();
            break;
        case EVENT_RESUME_NOW_FOREGROUND_CALL:
            try {
                resumeForegroundCall();
            } catch (ImsException e) {
                if (Phone.DEBUG_PHONE) {
                    loge("handleMessage EVENT_RESUME_NOW_FOREGROUND_CALL exception=" + e);
                }
            }
            break;
        case EVENT_ANSWER_WAITING_CALL:
            try {
                answerWaitingCall();
            } catch (ImsException e) {
                if (Phone.DEBUG_PHONE) {
                    loge("handleMessage EVENT_ANSWER_WAITING_CALL exception=" + e);
                }
            }
            break;
        case EVENT_DIAL_PENDINGMO:
            dialInternal(mPendingMO, mClirMode, mPendingCallVideoState, mPendingIntentExtras);
            mPendingIntentExtras = null;
            break;
        case EVENT_EXIT_ECBM_BEFORE_PENDINGMO:
            if (mPendingMO != null) {
                // Send ECBM exit request
                try {
                    getEcbmInterface().exitEmergencyCallbackMode();
                    mPhone.setOnEcbModeExitResponse(this, EVENT_EXIT_ECM_RESPONSE_CDMA, null);
                    pendingCallClirMode = mClirMode;
                    pendingCallInEcm = true;
                } catch (ImsException e) {
                    e.printStackTrace();
                    mPendingMO.setDisconnectCause(DisconnectCause.ERROR_UNSPECIFIED);
                    sendEmptyMessageDelayed(EVENT_HANGUP_PENDINGMO, TIMEOUT_HANGUP_PENDINGMO);
                }
            }
            break;
        case EVENT_EXIT_ECM_RESPONSE_CDMA:
            // no matter the result, we still do the same here
            if (pendingCallInEcm) {
                dialInternal(mPendingMO, pendingCallClirMode, mPendingCallVideoState, mPendingIntentExtras);
                mPendingIntentExtras = null;
                pendingCallInEcm = false;
            }
            mPhone.unsetOnEcbModeExitResponse(this);
            break;
        case EVENT_VT_DATA_USAGE_UPDATE:
            ar = (AsyncResult) msg.obj;
            ImsCall call = (ImsCall) ar.userObj;
            Long usage = (long) ar.result;
            log("VT data usage update. usage = " + usage + ", imsCall = " + call);
            if (usage > 0) {
                updateVtDataUsage(call, usage);
            }
            break;
        case EVENT_DATA_ENABLED_CHANGED:
            ar = (AsyncResult) msg.obj;
            if (ar.result instanceof Pair) {
                Pair<Boolean, Integer> p = (Pair<Boolean, Integer>) ar.result;
                onDataEnabledChanged(p.first, p.second);
            }
            break;
        case EVENT_CHECK_FOR_WIFI_HANDOVER:
            if (msg.obj instanceof ImsCall) {
                ImsCall imsCall = (ImsCall) msg.obj;
                if (imsCall != mForegroundCall.getImsCall()) {
                    Rlog.i(LOG_TAG, "handoverCheck: no longer FG; check skipped.");
                    unregisterForConnectivityChanges();
                    // Handover check and its not the foreground call any more.
                    return;
                }
                if (!mHasAttemptedStartOfCallHandover) {
                    mHasAttemptedStartOfCallHandover = true;
                }
                if (!imsCall.isWifiCall()) {
                    // Call did not handover to wifi, notify of handover failure.
                    ImsPhoneConnection conn = findConnection(imsCall);
                    if (conn != null) {
                        Rlog.i(LOG_TAG, "handoverCheck: handover failed.");
                        conn.onHandoverToWifiFailed();
                    }
                    if (imsCall.isVideoCall() && conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) {
                        registerForConnectivityChanges();
                    }
                }
            }
            break;
        case EVENT_ON_FEATURE_CAPABILITY_CHANGED:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    ImsFeature.Capabilities capabilities = (ImsFeature.Capabilities) args.arg1;
                    handleFeatureCapabilityChanged(capabilities);
                } finally {
                    args.recycle();
                }
                break;
            }
        case EVENT_SUPP_SERVICE_INDICATION:
            {
                ar = (AsyncResult) msg.obj;
                ImsPhoneMmiCode mmiCode = new ImsPhoneMmiCode(mPhone);
                try {
                    mmiCode.setIsSsInfo(true);
                    mmiCode.processImsSsData(ar);
                } catch (ImsException e) {
                    Rlog.e(LOG_TAG, "Exception in parsing SS Data: " + e);
                }
                break;
            }
        case EVENT_REDIAL_WIFI_E911_CALL:
            {
                Pair<ImsCall, ImsReasonInfo> callInfo = (Pair<ImsCall, ImsReasonInfo>) ((AsyncResult) msg.obj).userObj;
                removeMessages(EVENT_REDIAL_WIFI_E911_TIMEOUT);
                mPhone.getDefaultPhone().mCi.unregisterForOn(this);
                ImsPhoneConnection oldConnection = findConnection(callInfo.first);
                if (oldConnection == null) {
                    sendCallStartFailedDisconnect(callInfo.first, callInfo.second);
                    break;
                }
                mForegroundCall.detach(oldConnection);
                removeConnection(oldConnection);
                try {
                    Connection newConnection = mPhone.getDefaultPhone().dial(mLastDialString, mLastDialArgs);
                    oldConnection.onOriginalConnectionReplaced(newConnection);
                    final ImsCall imsCall = mForegroundCall.getImsCall();
                    final ImsCallProfile callProfile = imsCall.getCallProfile();
                    /* update EXTRA_EMERGENCY_CALL for clients to infer
                       from this extra that the call is emergency call */
                    callProfile.setCallExtraBoolean(ImsCallProfile.EXTRA_EMERGENCY_CALL, true);
                    ImsPhoneConnection conn = findConnection(imsCall);
                    conn.updateExtras(imsCall);
                } catch (CallStateException e) {
                    sendCallStartFailedDisconnect(callInfo.first, callInfo.second);
                }
                break;
            }
        case EVENT_REDIAL_WIFI_E911_TIMEOUT:
            {
                Pair<ImsCall, ImsReasonInfo> callInfo = (Pair<ImsCall, ImsReasonInfo>) msg.obj;
                mPhone.getDefaultPhone().mCi.unregisterForOn(this);
                removeMessages(EVENT_REDIAL_WIFI_E911_CALL);
                sendCallStartFailedDisconnect(callInfo.first, callInfo.second);
                break;
            }
        case EVENT_REDIAL_WITHOUT_RTT:
            {
                Pair<ImsCall, ImsReasonInfo> callInfo = (Pair<ImsCall, ImsReasonInfo>) msg.obj;
                removeMessages(EVENT_REDIAL_WITHOUT_RTT);
                ImsPhoneConnection oldConnection = findConnection(callInfo.first);
                if (oldConnection == null) {
                    sendCallStartFailedDisconnect(callInfo.first, callInfo.second);
                    break;
                }
                mForegroundCall.detach(oldConnection);
                removeConnection(oldConnection);
                try {
                    mPendingMO = null;
                    ImsDialArgs newDialArgs = ImsDialArgs.Builder.from(mLastDialArgs).setRttTextStream(null).setRetryCallFailCause(ImsReasonInfo.CODE_RETRY_ON_IMS_WITHOUT_RTT).setRetryCallFailNetworkType(ServiceState.rilRadioTechnologyToNetworkType(oldConnection.getCallRadioTech())).build();
                    Connection newConnection = mPhone.getDefaultPhone().dial(mLastDialString, newDialArgs);
                    oldConnection.onOriginalConnectionReplaced(newConnection);
                } catch (CallStateException e) {
                    sendCallStartFailedDisconnect(callInfo.first, callInfo.second);
                }
                break;
            }
    }
}
Also used : CallStateException(com.android.internal.telephony.CallStateException) ImsException(com.android.ims.ImsException) Connection(com.android.internal.telephony.Connection) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ImsFeature(android.telephony.ims.feature.ImsFeature) ImsDialArgs(com.android.internal.telephony.imsphone.ImsPhone.ImsDialArgs) SomeArgs(com.android.internal.os.SomeArgs) ImsCallProfile(android.telephony.ims.ImsCallProfile) ImsCall(com.android.ims.ImsCall) NetworkCapabilities(android.net.NetworkCapabilities) AsyncResult(android.os.AsyncResult) ImsReasonInfo(android.telephony.ims.ImsReasonInfo) Pair(android.util.Pair)

Example 30 with ImsReasonInfo

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

the class TelephonyMetrics method writeOnImsConnectionState.

/**
 * Write the IMS connection state changed event
 *
 * @param phoneId Phone id
 * @param state IMS connection state
 * @param reasonInfo The reason info. Only used for disconnected state.
 */
public synchronized void writeOnImsConnectionState(int phoneId, int state, ImsReasonInfo reasonInfo) {
    ImsConnectionState imsState = new ImsConnectionState();
    imsState.state = state;
    if (reasonInfo != null) {
        TelephonyProto.ImsReasonInfo ri = new TelephonyProto.ImsReasonInfo();
        ri.reasonCode = reasonInfo.getCode();
        ri.extraCode = reasonInfo.getExtraCode();
        String extraMessage = reasonInfo.getExtraMessage();
        if (extraMessage != null) {
            ri.extraMessage = extraMessage;
        }
        imsState.reasonInfo = ri;
    }
    // If the connection state does not change, do not log it.
    if (mLastImsConnectionState.get(phoneId) != null && Arrays.equals(ImsConnectionState.toByteArray(mLastImsConnectionState.get(phoneId)), ImsConnectionState.toByteArray(imsState))) {
        return;
    }
    mLastImsConnectionState.put(phoneId, imsState);
    TelephonyEvent event = new TelephonyEventBuilder(phoneId).setImsConnectionState(imsState).build();
    addTelephonyEvent(event);
    annotateInProgressCallSession(event.timestampMillis, phoneId, new CallSessionEventBuilder(TelephonyCallSession.Event.Type.IMS_CONNECTION_STATE_CHANGED).setImsConnectionState(event.imsConnectionState));
    annotateInProgressSmsSession(event.timestampMillis, phoneId, new SmsSessionEventBuilder(SmsSession.Event.Type.IMS_CONNECTION_STATE_CHANGED).setImsConnectionState(event.imsConnectionState));
}
Also used : TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent) ImsConnectionState(com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState) TelephonyProto(com.android.internal.telephony.nano.TelephonyProto) ImsReasonInfo(android.telephony.ims.ImsReasonInfo)

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