PhoneNumberUtils.java (frameworks\base\telephony\java\android\telephony)
package android.telephony;
import com.android.i18n.phonenumbers.NumberParseException;
import com.android.i18n.phonenumbers.PhoneNumberUtil;
import com.android.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.android.i18n.phonenumbers.ShortNumberUtil;
import com.android.i18n.phonenumbers.Phonemetadata.PhoneMetadata;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.location.CountryDetector;
import android.net.Uri;
import android.os.SystemProperties;
import android.provider.Contacts;
import android.provider.ContactsContract;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseIntArray;
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;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/// M : [mtk04070][111116][ALPS00093395]Use Gemini object @{
import static com.android.internal.telephony.PhoneConstants.GEMINI_SIM_1;
import static com.android.internal.telephony.PhoneConstants.GEMINI_DEFAULT_SIM_PROP;
import static com.android.internal.telephony.PhoneConstants.GEMINI_SIM_ID_KEY;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import com.mediatek.common.featureoption.FeatureOption;
import com.mediatek.common.MediatekClassFactory;
import com.mediatek.common.telephony.IPhoneNumberExt;
import com.android.internal.telephony.PhoneConstants;
/// @}
import android.os.ServiceManager;
import com.android.internal.telephony.ITelephony;
/**
* Various utilities for dealing with phone number strings.
*/
public class PhoneNumberUtils
/**
* Returns the last numDigits of the reversed phone number
* Returns null if np == null
*/
private static String
internalGetStrippedReversed(String np, int numDigits) {
if (np == null) return null;
StringBuilder ret = new StringBuilder(numDigits);
int length = np.length();
for (int i = length - 1, s = length
; i >= 0 && (s - i) <= numDigits ; i--
) {
char c = np.charAt(i);
ret.append(c);
}
return ret.toString();
}
/**
* Basically: makes sure there's a + in front of a
* TOA_International number
*
* Returns null if s == null
*/
public static String
stringFromStringAndTOA(String s, int TOA) {
if (s == null) return null;
if (TOA == TOA_International && s.length() > 0 && s.charAt(0) != '+') {
return "+" + s;
}
return s;
}
/**
* Returns the TOA for the given dial string
* Basically, returns TOA_International if there's a + prefix
*/
public static int
toaFromString(String s) {
if (s != null && s.length() > 0 && s.charAt(0) == '+') {
return TOA_International;
}
return TOA_Unknown;
}
/**
* 3GPP TS 24.008 10.5.4.7
* Called Party BCD Number
*
* See Also TS 51.011 10.5.1 "dialing number/ssc string"
* and TS 11.11 "10.3.1 EF adn (Abbreviated dialing numbers)"
*
* @param bytes the data buffer
* @param offset should point to the TOA (aka. TON/NPI) octet after the length byte
* @param length is the number of bytes including TOA byte
* and must be at least 2
*
* @return partial string on invalid decode
*
* FIXME(mkf) support alphanumeric address type
* currently implemented in SMSMessage.getAddress()
*/
public static String calle