Search in sources :

Example 1 with ImsPhoneCallTracker

use of com.android.internal.telephony.imsphone.ImsPhoneCallTracker in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhone method dial.

@Override
public Connection dial(String dialString, @NonNull DialArgs dialArgs) throws CallStateException {
    if (!isPhoneTypeGsm() && dialArgs.uusInfo != null) {
        throw new CallStateException("Sending UUS information NOT supported in CDMA!");
    }
    String possibleEmergencyNumber = checkForTestEmergencyNumber(dialString);
    // Record if the dialed number was swapped for a test emergency number.
    boolean isDialedNumberSwapped = !TextUtils.equals(dialString, possibleEmergencyNumber);
    if (isDialedNumberSwapped) {
        logi("dialString replaced for possible emergency number: " + dialString + " -> " + possibleEmergencyNumber);
        dialString = possibleEmergencyNumber;
    }
    boolean isEmergency = PhoneNumberUtils.isEmergencyNumber(getSubId(), dialString);
    Phone imsPhone = mImsPhone;
    mDialArgs = dialArgs;
    CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
    boolean alwaysTryImsForEmergencyCarrierConfig = configManager.getConfigForSubId(getSubId()).getBoolean(CarrierConfigManager.KEY_CARRIER_USE_IMS_FIRST_FOR_EMERGENCY_BOOL);
    /**
     * Check if the call is Wireless Priority Service call
     */
    boolean isWpsCall = dialString != null ? (dialString.startsWith(PREFIX_WPS) || dialString.startsWith(PREFIX_WPS_CLIR_ACTIVATE) || dialString.startsWith(PREFIX_WPS_CLIR_DEACTIVATE)) : false;
    boolean allowWpsOverIms = configManager.getConfigForSubId(getSubId()).getBoolean(CarrierConfigManager.KEY_SUPPORT_WPS_OVER_IMS_BOOL);
    boolean useImsForEmergency = imsPhone != null && isEmergency && alwaysTryImsForEmergencyCarrierConfig && ImsManager.getInstance(mContext, mPhoneId).isNonTtyOrTtyOnVolteEnabled() && imsPhone.isImsAvailable();
    String dialPart = PhoneNumberUtils.extractNetworkPortionAlt(PhoneNumberUtils.stripSeparators(dialString));
    boolean isMmiCode = (dialPart.startsWith("*") || dialPart.startsWith("#")) && dialPart.endsWith("#");
    boolean isSuppServiceCode = ImsPhoneMmiCode.isSuppServiceCodes(dialPart, this);
    boolean isPotentialUssdCode = isMmiCode && !isSuppServiceCode;
    boolean useImsForUt = imsPhone != null && imsPhone.isUtEnabled();
    boolean useImsForCall = useImsForCall(dialArgs) && (isWpsCall ? allowWpsOverIms : true);
    if (DBG) {
        logd("useImsForCall=" + useImsForCall + ", isEmergency=" + isEmergency + ", useImsForEmergency=" + useImsForEmergency + ", useImsForUt=" + useImsForUt + ", isUt=" + isMmiCode + ", isSuppServiceCode=" + isSuppServiceCode + ", isPotentialUssdCode=" + isPotentialUssdCode + ", isWpsCall=" + isWpsCall + ", allowWpsOverIms=" + allowWpsOverIms + ", imsPhone=" + imsPhone + ", imsPhone.isVolteEnabled()=" + ((imsPhone != null) ? imsPhone.isVolteEnabled() : "N/A") + ", imsPhone.isVowifiEnabled()=" + ((imsPhone != null) ? imsPhone.isWifiCallingEnabled() : "N/A") + ", imsPhone.isVideoEnabled()=" + ((imsPhone != null) ? imsPhone.isVideoEnabled() : "N/A") + ", imsPhone.getServiceState().getState()=" + ((imsPhone != null) ? imsPhone.getServiceState().getState() : "N/A"));
    }
    Phone.checkWfcWifiOnlyModeBeforeDial(mImsPhone, mPhoneId, mContext);
    if (imsPhone != null && !allowWpsOverIms && !useImsForCall && isWpsCall && imsPhone.getCallTracker() instanceof ImsPhoneCallTracker) {
        logi("WPS call placed over CS; disconnecting all IMS calls..");
        ImsPhoneCallTracker tracker = (ImsPhoneCallTracker) imsPhone.getCallTracker();
        tracker.hangupAllConnections();
    }
    if ((useImsForCall && (!isMmiCode || isPotentialUssdCode)) || (isMmiCode && useImsForUt) || useImsForEmergency) {
        try {
            if (DBG)
                logd("Trying IMS PS call");
            return imsPhone.dial(dialString, dialArgs);
        } catch (CallStateException e) {
            if (DBG)
                logd("IMS PS call exception " + e + "useImsForCall =" + useImsForCall + ", imsPhone =" + imsPhone);
            // for emergency calls and MMI codes.
            if (Phone.CS_FALLBACK.equals(e.getMessage()) || isEmergency) {
                logi("IMS call failed with Exception: " + e.getMessage() + ". Falling back " + "to CS.");
            } else {
                CallStateException ce = new CallStateException(e.getError(), e.getMessage());
                ce.setStackTrace(e.getStackTrace());
                throw ce;
            }
        }
    }
    if (mSST != null && mSST.mSS.getState() == ServiceState.STATE_OUT_OF_SERVICE && mSST.mSS.getDataRegistrationState() != ServiceState.STATE_IN_SERVICE && !isEmergency) {
        throw new CallStateException("cannot dial in current state");
    }
    // Check non-emergency voice CS call - shouldn't dial when POWER_OFF
    if (mSST != null && mSST.mSS.getState() == ServiceState.STATE_POWER_OFF && /* CS POWER_OFF */
    !VideoProfile.isVideo(dialArgs.videoState) && /* voice call */
    !isEmergency && /* non-emergency call */
    !(isMmiCode && useImsForUt) && /* If config_allow_ussd_over_ims is false, USSD is sent over the CS pipe instead */
    !isPotentialUssdCode) {
        throw new CallStateException(CallStateException.ERROR_POWER_OFF, "cannot dial voice call in airplane mode");
    }
    // Allow dial only if either CS is camped on any RAT (or) PS is in LTE/NR service.
    if (mSST != null && mSST.mSS.getState() == ServiceState.STATE_OUT_OF_SERVICE && /* CS out of service */
    !(mSST.mSS.getDataRegistrationState() == ServiceState.STATE_IN_SERVICE && ServiceState.isPsOnlyTech(mSST.mSS.getRilDataRadioTechnology())) && /* PS not in LTE/NR */
    !VideoProfile.isVideo(dialArgs.videoState) && /* voice call */
    !isEmergency && /* If config_allow_ussd_over_ims is false, USSD is sent over the CS pipe instead */
    !isPotentialUssdCode) {
        throw new CallStateException(CallStateException.ERROR_OUT_OF_SERVICE, "cannot dial voice call in out of service");
    }
    if (DBG)
        logd("Trying (non-IMS) CS call");
    if (isDialedNumberSwapped && isEmergency) {
        // Triggers ECM when CS call ends only for test emergency calls using
        // ril.test.emergencynumber.
        mIsTestingEmergencyCallbackMode = true;
        mCi.testingEmergencyCall();
    }
    if (isPhoneTypeGsm()) {
        return dialInternal(dialString, new DialArgs.Builder<>().setIntentExtras(dialArgs.intentExtras).build());
    } else {
        return dialInternal(dialString, dialArgs);
    }
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) ImsPhoneCallTracker(com.android.internal.telephony.imsphone.ImsPhoneCallTracker)

Example 2 with ImsPhoneCallTracker

use of com.android.internal.telephony.imsphone.ImsPhoneCallTracker in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyTester method handleTestConferenceEventPackage.

/**
 * Handles request to send a test conference event package to the active Ims call.
 *
 * @see com.android.internal.telephony.test.TestConferenceEventPackageParser
 * @param context The context.
 * @param fileName The name of the test conference event package file to read.
 */
private void handleTestConferenceEventPackage(Context context, String fileName, boolean isBypassingImsCall) {
    // Attempt to get the active IMS call before parsing the test XML file.
    ImsPhone imsPhone = (ImsPhone) mPhone;
    if (imsPhone == null) {
        return;
    }
    ImsPhoneCallTracker tracker = (ImsPhoneCallTracker) imsPhone.getCallTracker();
    File packageFile = new File(context.getFilesDir(), fileName);
    final FileInputStream is;
    try {
        is = new FileInputStream(packageFile);
    } catch (FileNotFoundException ex) {
        log("Test conference event package file not found: " + packageFile.getAbsolutePath());
        return;
    }
    TestConferenceEventPackageParser parser = new TestConferenceEventPackageParser(is);
    ImsConferenceState imsConferenceState = parser.parse();
    if (imsConferenceState == null) {
        return;
    }
    if (isBypassingImsCall) {
        tracker.injectTestConferenceState(imsConferenceState);
    } else {
        ImsPhoneCall imsPhoneCall = imsPhone.getForegroundCall();
        if (imsPhoneCall == null) {
            return;
        }
        ImsCall imsCall = imsPhoneCall.getImsCall();
        if (imsCall == null) {
            return;
        }
        imsCall.conferenceStateUpdated(imsConferenceState);
    }
}
Also used : TestConferenceEventPackageParser(com.android.internal.telephony.test.TestConferenceEventPackageParser) ImsPhoneCallTracker(com.android.internal.telephony.imsphone.ImsPhoneCallTracker) ImsCall(com.android.ims.ImsCall) ImsPhoneCall(com.android.internal.telephony.imsphone.ImsPhoneCall) FileNotFoundException(java.io.FileNotFoundException) ImsPhone(com.android.internal.telephony.imsphone.ImsPhone) File(java.io.File) FileInputStream(java.io.FileInputStream) ImsConferenceState(android.telephony.ims.ImsConferenceState)

Aggregations

ImsPhoneCallTracker (com.android.internal.telephony.imsphone.ImsPhoneCallTracker)2 CarrierConfigManager (android.telephony.CarrierConfigManager)1 ImsConferenceState (android.telephony.ims.ImsConferenceState)1 ImsCall (com.android.ims.ImsCall)1 ImsPhone (com.android.internal.telephony.imsphone.ImsPhone)1 ImsPhoneCall (com.android.internal.telephony.imsphone.ImsPhoneCall)1 TestConferenceEventPackageParser (com.android.internal.telephony.test.TestConferenceEventPackageParser)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1