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 import android.compat.annotation.UnsupportedAppUsage;
20 
21 public abstract class SmsAddress {
22     // From TS 23.040 9.1.2.5 and TS 24.008 table 10.5.118
23     // and C.S0005-D table 2.7.1.3.2.4-2
24     public static final int TON_UNKNOWN = 0;
25     public static final int TON_INTERNATIONAL = 1;
26     public static final int TON_NATIONAL = 2;
27     public static final int TON_NETWORK = 3;
28     public static final int TON_SUBSCRIBER = 4;
29     public static final int TON_ALPHANUMERIC = 5;
30     public static final int TON_ABBREVIATED = 6;
31 
32     public int ton;
33     public String address;
34     @UnsupportedAppUsage
35     public byte[] origBytes;
36 
37     /**
38      * Returns the address of the SMS message in String form or null if unavailable
39      */
getAddressString()40     public String getAddressString() {
41         return address;
42     }
43 
44     /**
45      * Returns true if this is an alphanumeric address
46      */
isAlphanumeric()47     public boolean isAlphanumeric() {
48         return ton == TON_ALPHANUMERIC;
49     }
50 
51     /**
52      * Returns true if this is a network address
53      */
isNetworkSpecific()54     public boolean isNetworkSpecific() {
55         return ton == TON_NETWORK;
56     }
57 
couldBeEmailGateway()58     public boolean couldBeEmailGateway() {
59         // Some carriers seems to send email gateway messages in this form:
60         // from: an UNKNOWN TON, 3 or 4 digits long, beginning with a 5
61         // PID: 0x00, Data coding scheme 0x03
62         // So we just attempt to treat any message from an address length <= 4
63         // as an email gateway
64 
65         return address.length() <= 4;
66     }
67 
68 }
69