1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.telephony;
18 
19 public abstract class SmsAddress {
20     // From TS 23.040 9.1.2.5 and TS 24.008 table 10.5.118
21     // and C.S0005-D table 2.7.1.3.2.4-2
22     public static final int TON_UNKNOWN = 0;
23     public static final int TON_INTERNATIONAL = 1;
24     public static final int TON_NATIONAL = 2;
25     public static final int TON_NETWORK = 3;
26     public static final int TON_SUBSCRIBER = 4;
27     public static final int TON_ALPHANUMERIC = 5;
28     public static final int TON_ABBREVIATED = 6;
29 
30     public int ton;
31     public String address;
32     public byte[] origBytes;
33 
34     /**
35      * Returns the address of the SMS message in String form or null if unavailable
36      */
getAddressString()37     public String getAddressString() {
38         return address;
39     }
40 
41     /**
42      * Returns true if this is an alphanumeric address
43      */
isAlphanumeric()44     public boolean isAlphanumeric() {
45         return ton == TON_ALPHANUMERIC;
46     }
47 
48     /**
49      * Returns true if this is a network address
50      */
isNetworkSpecific()51     public boolean isNetworkSpecific() {
52         return ton == TON_NETWORK;
53     }
54 
couldBeEmailGateway()55     public boolean couldBeEmailGateway() {
56         // Some carriers seems to send email gateway messages in this form:
57         // from: an UNKNOWN TON, 3 or 4 digits long, beginning with a 5
58         // PID: 0x00, Data coding scheme 0x03
59         // So we just attempt to treat any message from an address length <= 4
60         // as an email gateway
61 
62         return address.length() <= 4;
63     }
64 
65 }
66