Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1f5f293 authored by Qiang Chen's avatar Qiang Chen
Browse files

Add support for IP call prefix

Append the user configured IP prefix ahead of the calling number
in case of calling via IP.

CRs-Fixed: 516042

Change-Id: Idf73f06c7030df4124f737433839efddcd089c23
parent 40afb319
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.telephony.Rlog;
import android.util.SparseIntArray;

import static com.android.internal.telephony.MSimConstants.SUBSCRIPTION_KEY;
import static com.android.internal.telephony.PhoneConstants.IP_CALL;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_IDP_STRING;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY;
@@ -81,6 +82,11 @@ public class PhoneNumberUtils
    static final String LOG_TAG = "PhoneNumberUtils";
    private static final boolean DBG = false;

    /**
     * Used for multi Sim IP Call Prefix Setting.
     */
    private static final String IP_CALL_PREFIX = "ip_call_prefix_sub";

    /*
     * global-phone-number = ["+"] 1*( DIGIT / written-sep )
     * written-sep         = ("-"/".")
@@ -143,6 +149,16 @@ public class PhoneNumberUtils
        return !isDialable(ch) && !(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'));
    }

    private static String checkAndAppendPrefix(Intent intent, int subscription, String number,
            Context context) {
        boolean isIPPrefix = intent.getBooleanExtra(IP_CALL, false);
        if (isIPPrefix && number != null
                && subscription < MSimTelephonyManager.getDefault().getPhoneCount()) {
            return IP_CALL_PREFIX + subscription + number;
        }
        return number;
    }

    /** Extracts the phone number from an Intent.
     *
     * @param intent the intent to get the number of
@@ -161,17 +177,21 @@ public class PhoneNumberUtils
        }

        String scheme = uri.getScheme();
        int subscription = 0;

        if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
            subscription = intent.getIntExtra(SUBSCRIPTION_KEY,
                    MSimTelephonyManager.getDefault().getPreferredVoiceSubscription());
        }

        if (scheme.equals("tel") || scheme.equals("sip")) {
            return uri.getSchemeSpecificPart();
            return checkAndAppendPrefix(intent, subscription, uri.getSchemeSpecificPart(), context);
        }

        // TODO: We don't check for SecurityException here (requires
        // CALL_PRIVILEGED permission).
        if (scheme.equals("voicemail")) {
            if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                int subscription = intent.getIntExtra(SUBSCRIPTION_KEY,
                        MSimTelephonyManager.getDefault().getPreferredVoiceSubscription());
                return MSimTelephonyManager.getDefault()
                        .getCompleteVoiceMailNumber(subscription);
            }
@@ -206,7 +226,7 @@ public class PhoneNumberUtils
            }
        }

        return number;
        return checkAndAppendPrefix(intent, subscription, number, context);
    }

    /** Extracts the network address portion and canonicalizes
+2 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ public class PhoneConstants {

    public static final String REASON_LINK_PROPERTIES_CHANGED = "linkPropertiesChanged";

    public static final String IP_CALL = "ip_call";

    /**
     * Return codes for supplyPinReturnResult and
     * supplyPukReturnResult APIs