Search in sources :

Example 21 with ImsException

use of com.android.ims.ImsException in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiCallingSettingsForSub method onPause.

@Override
public void onPause() {
    super.onPause();
    final Context context = getActivity();
    if (mValidListener) {
        mValidListener = false;
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
        mSwitchBar.removeOnSwitchChangeListener(this);
    }
    context.unregisterReceiver(mIntentReceiver);
    // Remove callback for provisioning changes.
    try {
        mImsManager.getConfigInterface().removeConfigCallback(mProvisioningCallback.getBinder());
    } catch (ImsException e) {
        Log.w(TAG, "onPause: Unable to remove callback for provisioning changes");
    }
}
Also used : Context(android.content.Context) TelephonyManager(android.telephony.TelephonyManager) ImsException(com.android.ims.ImsException)

Example 22 with ImsException

use of com.android.ims.ImsException in project android_packages_apps_Settings by DirtyUnicorns.

the class RadioInfo method isFeatureProvisioned.

private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
    boolean provisioned = defaultValue;
    if (mImsManager != null) {
        try {
            ImsConfig imsConfig = mImsManager.getConfigInterface();
            if (imsConfig != null) {
                provisioned = (imsConfig.getProvisionedValue(featureId) == ImsConfig.FeatureValueConstants.ON);
            }
        } catch (ImsException ex) {
            Log.e(TAG, "isFeatureProvisioned() exception:", ex);
        }
    }
    log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
    return provisioned;
}
Also used : ImsConfig(com.android.ims.ImsConfig) ImsException(com.android.ims.ImsException)

Example 23 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method acceptCall.

/**
 * Accepts a call with the specified video state.  The video state is the video state that the
 * user has agreed upon in the InCall UI.
 *
 * @param videoState The video State
 * @throws CallStateException
 */
public void acceptCall(int videoState) throws CallStateException {
    if (DBG)
        log("acceptCall");
    if (mForegroundCall.getState().isAlive() && mBackgroundCall.getState().isAlive()) {
        throw new CallStateException("cannot accept call");
    }
    if ((mRingingCall.getState() == ImsPhoneCall.State.WAITING) && mForegroundCall.getState().isAlive()) {
        setMute(false);
        boolean answeringWillDisconnect = false;
        ImsCall activeCall = mForegroundCall.getImsCall();
        ImsCall ringingCall = mRingingCall.getImsCall();
        if (mForegroundCall.hasConnections() && mRingingCall.hasConnections()) {
            answeringWillDisconnect = shouldDisconnectActiveCallOnAnswer(activeCall, ringingCall);
        }
        // Cache video state for pending MT call.
        mPendingCallVideoState = videoState;
        if (answeringWillDisconnect) {
            // We need to disconnect the foreground call before answering the background call.
            mForegroundCall.hangup();
            try {
                ringingCall.accept(ImsCallProfile.getCallTypeFromVideoState(videoState));
            } catch (ImsException e) {
                throw new CallStateException("cannot accept call");
            }
        } else {
            switchWaitingOrHoldingAndActive();
        }
    } else if (mRingingCall.getState().isRinging()) {
        if (DBG)
            log("acceptCall: incoming...");
        // Always unmute when answering a new call
        setMute(false);
        try {
            ImsCall imsCall = mRingingCall.getImsCall();
            if (imsCall != null) {
                imsCall.accept(ImsCallProfile.getCallTypeFromVideoState(videoState));
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_ACCEPT);
            } else {
                throw new CallStateException("no valid ims call");
            }
        } catch (ImsException e) {
            throw new CallStateException("cannot accept call");
        }
    } else {
        throw new CallStateException("phone not ringing");
    }
}
Also used : CallStateException(com.android.internal.telephony.CallStateException) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException)

Example 24 with ImsException

use of com.android.ims.ImsException in project android_frameworks_opt_telephony by LineageOS.

the class ImsPhoneCallTracker method resumeWaitingOrHolding.

/* package */
void resumeWaitingOrHolding() throws CallStateException {
    if (DBG)
        log("resumeWaitingOrHolding");
    try {
        if (mForegroundCall.getState().isAlive()) {
            // resume foreground call after holding background call
            // they were switched before holding
            ImsCall imsCall = mForegroundCall.getImsCall();
            if (imsCall != null) {
                imsCall.resume();
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_RESUME);
            }
        } else if (mRingingCall.getState() == ImsPhoneCall.State.WAITING) {
            // accept waiting call after holding background call
            ImsCall imsCall = mRingingCall.getImsCall();
            if (imsCall != null) {
                imsCall.accept(ImsCallProfile.getCallTypeFromVideoState(mPendingCallVideoState));
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_ACCEPT);
            }
        } else {
            // Just resume background call.
            // To distinguish resuming call with swapping calls
            // we do not switch calls.here
            // ImsPhoneConnection.update will chnage the parent when completed
            ImsCall imsCall = mBackgroundCall.getImsCall();
            if (imsCall != null) {
                imsCall.resume();
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(), ImsCommand.IMS_CMD_RESUME);
            }
        }
    } catch (ImsException e) {
        throw new CallStateException(e.getMessage());
    }
}
Also used : CallStateException(com.android.internal.telephony.CallStateException) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException)

Example 25 with ImsException

use of com.android.ims.ImsException 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_BACKGROUND:
            try {
                resumeWaitingOrHolding();
            } catch (CallStateException e) {
                if (Phone.DEBUG_PHONE) {
                    loge("handleMessage EVENT_RESUME_BACKGROUND 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_GET_IMS_SERVICE:
            try {
                getImsService();
            } catch (ImsException e) {
                loge("getImsService: " + e);
                retryGetImsService();
            }
            break;
        case EVENT_CHECK_FOR_WIFI_HANDOVER:
            if (msg.obj instanceof ImsCall) {
                ImsCall imsCall = (ImsCall) msg.obj;
                if (!imsCall.isWifiCall()) {
                    // Call did not handover to wifi, notify of handover failure.
                    ImsPhoneConnection conn = findConnection(imsCall);
                    if (conn != null) {
                        conn.onHandoverToWifiFailed();
                    }
                }
            }
            break;
        case EVENT_ON_FEATURE_CAPABILITY_CHANGED:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    int serviceClass = args.argi1;
                    int[] enabledFeatures = (int[]) args.arg1;
                    int[] disabledFeatures = (int[]) args.arg2;
                    handleFeatureCapabilityChanged(serviceClass, enabledFeatures, disabledFeatures);
                } finally {
                    args.recycle();
                }
                break;
            }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CallStateException(com.android.internal.telephony.CallStateException) SomeArgs(com.android.internal.os.SomeArgs) ImsCall(com.android.ims.ImsCall) ImsException(com.android.ims.ImsException) AsyncResult(android.os.AsyncResult) Pair(android.util.Pair)

Aggregations

ImsException (com.android.ims.ImsException)37 Message (android.os.Message)9 ImsUtInterface (com.android.ims.ImsUtInterface)8 ImsCall (com.android.ims.ImsCall)7 ImsConfig (com.android.ims.ImsConfig)7 SpannableStringBuilder (android.text.SpannableStringBuilder)6 CallStateException (com.android.internal.telephony.CallStateException)6 ImsCallProfile (com.android.ims.ImsCallProfile)4 Context (android.content.Context)3 PendingIntent (android.app.PendingIntent)2 Bundle (android.os.Bundle)2 FlakyTest (android.support.test.filters.FlakyTest)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 ImsConnectionStateListener (com.android.ims.ImsConnectionStateListener)2 ImsSsInfo (com.android.ims.ImsSsInfo)2 CommandException (com.android.internal.telephony.CommandException)2 TelephonyTest (com.android.internal.telephony.TelephonyTest)2 Test (org.junit.Test)2 Intent (android.content.Intent)1 AsyncResult (android.os.AsyncResult)1