FileDocCategorySizeDatePackage
CdmaSmsAddress.javaAPI DocAndroid 5.1 API8405Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.cdma.sms

CdmaSmsAddress

public class CdmaSmsAddress extends com.android.internal.telephony.SmsAddress

Fields Summary
public static final int
DIGIT_MODE_4BIT_DTMF
Digit Mode Indicator is a 1-bit value that indicates whether the address digits are 4-bit DTMF codes or 8-bit codes. (See 3GPP2 C.S0015-B, v2, 3.4.3.3)
public static final int
DIGIT_MODE_8BIT_CHAR
public int
digitMode
public static final int
NUMBER_MODE_NOT_DATA_NETWORK
Number Mode Indicator is 1-bit value that indicates whether the address type is a data network address or not. (See 3GPP2 C.S0015-B, v2, 3.4.3.3)
public static final int
NUMBER_MODE_DATA_NETWORK
public int
numberMode
public static final int
TON_UNKNOWN
Number Types for data networks. (See 3GPP2 C.S005-D, table2.7.1.3.2.4-2 for complete table) (See 3GPP2 C.S0015-B, v2, 3.4.3.3 for data network subset) NOTE: value is stored in the parent class ton field.
public static final int
TON_INTERNATIONAL_OR_IP
public static final int
TON_NATIONAL_OR_EMAIL
public static final int
TON_NETWORK
public static final int
TON_SUBSCRIBER
public static final int
TON_ALPHANUMERIC
public static final int
TON_ABBREVIATED
public static final int
TON_RESERVED
public static final int
SMS_ADDRESS_MAX
Maximum lengths for fields as defined in ril_cdma_sms.h.
public static final int
SMS_SUBADDRESS_MAX
public int
numberOfDigits
This field shall be set to the number of address digits (See 3GPP2 C.S0015-B, v2, 3.4.3.3)
public static final int
NUMBERING_PLAN_UNKNOWN
Numbering Plan identification is a 0 or 4-bit value that indicates which numbering plan identification is set. (See 3GPP2, C.S0015-B, v2, 3.4.3.3 and C.S005-D, table2.7.1.3.2.4-3)
public static final int
NUMBERING_PLAN_ISDN_TELEPHONY
public int
numberPlan
private static final char[]
numericCharsDialable
private static final char[]
numericCharsSugar
private static final android.util.SparseBooleanArray
numericCharDialableMap
Constructors Summary
public CdmaSmsAddress()
NOTE: the parsed string address and the raw byte array values are stored in the parent class address and origBytes fields, respectively.


                               

     
    
Methods Summary
private static java.lang.StringfilterNumericSugar(java.lang.String address)
Given a numeric address string, return the string without syntactic sugar, meaning parens, spaces, hyphens/minuses, or plus signs. If the input string contains non-numeric non-punctuation characters, return null.

     
        for (int i = 0; i < numericCharsDialable.length; i++) {
            numericCharDialableMap.put(numericCharsDialable[i], true);
        }
        for (int i = 0; i < numericCharsSugar.length; i++) {
            numericCharDialableMap.put(numericCharsSugar[i], false);
        }
    
        StringBuilder builder = new StringBuilder();
        int len = address.length();
        for (int i = 0; i < len; i++) {
            char c = address.charAt(i);
            int mapIndex = numericCharDialableMap.indexOfKey(c);
            if (mapIndex < 0) return null;
            if (! numericCharDialableMap.valueAt(mapIndex)) continue;
            builder.append(c);
        }
        return builder.toString();
    
private static java.lang.StringfilterWhitespace(java.lang.String address)
Given a string, return the string without whitespace, including CR/LF.

        StringBuilder builder = new StringBuilder();
        int len = address.length();
        for (int i = 0; i < len; i++) {
            char c = address.charAt(i);
            if ((c == ' ") || (c == '\r") || (c == '\n") || (c == '\t")) continue;
            builder.append(c);
        }
        return builder.toString();
    
public static com.android.internal.telephony.cdma.sms.CdmaSmsAddressparse(java.lang.String address)
Given a string, create a corresponding CdmaSmsAddress object. The result will be null if the input string is not representable using printable ASCII. For numeric addresses, the string is cleaned up by removing common punctuation. For alpha addresses, the string is cleaned up by removing whitespace.

        CdmaSmsAddress addr = new CdmaSmsAddress();
        addr.address = address;
        addr.ton = CdmaSmsAddress.TON_UNKNOWN;
        byte[] origBytes = null;
        String filteredAddr = filterNumericSugar(address);
        if (filteredAddr != null) {
            origBytes = parseToDtmf(filteredAddr);
        }
        if (origBytes != null) {
            addr.digitMode = DIGIT_MODE_4BIT_DTMF;
            addr.numberMode = NUMBER_MODE_NOT_DATA_NETWORK;
            if (address.indexOf('+") != -1) {
                addr.ton = TON_INTERNATIONAL_OR_IP;
            }
        } else {
            filteredAddr = filterWhitespace(address);
            origBytes = UserData.stringToAscii(filteredAddr);
            if (origBytes == null) {
                return null;
            }
            addr.digitMode = DIGIT_MODE_8BIT_CHAR;
            addr.numberMode = NUMBER_MODE_DATA_NETWORK;
            if (address.indexOf('@") != -1) {
                addr.ton = TON_NATIONAL_OR_EMAIL;
            }
        }
        addr.origBytes = origBytes;
        addr.numberOfDigits = origBytes.length;
        return addr;
    
private static byte[]parseToDtmf(java.lang.String address)

        int digits = address.length();
        byte[] result = new byte[digits];
        for (int i = 0; i < digits; i++) {
            char c = address.charAt(i);
            int val = 0;
            if ((c >= '1") && (c <= '9")) val = c - '0";
            else if (c == '0") val = 10;
            else if (c == '*") val = 11;
            else if (c == '#") val = 12;
            else return null;
            result[i] = (byte)val;
        }
        return result;
    
public java.lang.StringtoString()

        StringBuilder builder = new StringBuilder();
        builder.append("CdmaSmsAddress ");
        builder.append("{ digitMode=" + digitMode);
        builder.append(", numberMode=" + numberMode);
        builder.append(", numberPlan=" + numberPlan);
        builder.append(", numberOfDigits=" + numberOfDigits);
        builder.append(", ton=" + ton);
        builder.append(", address=\"" + address + "\"");
        builder.append(", origBytes=" + HexDump.toHexString(origBytes));
        builder.append(" }");
        return builder.toString();