1 /*
2  * Copyright (C) 2007 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.gsm;
18 
19 import android.telephony.PhoneNumberUtils;
20 
21 import java.util.Arrays;
22 
23 /**
24  * Represents a Supplementary Service Notification received from the network.
25  *
26  * {@hide}
27  */
28 public class SuppServiceNotification {
29     /** Type of notification: 0 = code1; 1 = code2 */
30     public int notificationType;
31     /** TS 27.007 7.17 "code1" or "code2" */
32     public int code;
33     /** TS 27.007 7.17 "index" */
34     public int index;
35     /** TS 27.007 7.17 "type" (MT only) */
36     public int type;
37     /** TS 27.007 7.17 "number" (MT only) */
38     public String number;
39 
40     /** List of forwarded numbers, if any */
41     public String[] history;
42 
43     /**
44      * Notification type is from the "code 1" group (per TS 27.007 7.17).
45      * This means the {@link #code} will be a code such as {@link #CODE_1_CALL_FORWARDED}.
46      */
47     public static final int NOTIFICATION_TYPE_CODE_1 = 0;
48 
49     /**
50      * Notification type is from the "code 2" group (per TS 27.007 7.17).
51      * This means the {@link #code} will be a code such as {@link #CODE_2_CALL_ON_HOLD}.
52      */
53     public static final int NOTIFICATION_TYPE_CODE_2 = 1;
54 
55     /**
56      * Indicates that unconditional call forwarding is active.
57      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
58      * See TS 27.007 7.17.
59      */
60     public static final int CODE_1_UNCONDITIONAL_CF_ACTIVE     = 0;
61 
62     /**
63      * Indicates that some conditional call forwarding options are active.
64      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
65      * See TS 27.007 7.17.
66      */
67     public static final int CODE_1_SOME_CF_ACTIVE              = 1;
68 
69     /**
70      * Indicates that an outgoing call has been forwarded to another number.
71      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
72      * See TS 27.007 7.17.
73      */
74     public static final int CODE_1_CALL_FORWARDED              = 2;
75 
76     /**
77      * Indicates that an outgoing call is waiting.  This means that the called party is already in
78      * another call and is hearing the call waiting tone.
79      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
80      * See TS 27.007 7.17.
81      */
82     public static final int CODE_1_CALL_IS_WAITING             = 3;
83 
84     /**
85      * Indicates that an outgoing call is to a number in a closed user group.
86      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
87      * See TS 27.007 7.17.
88      */
89     public static final int CODE_1_CUG_CALL                    = 4;
90 
91     /**
92      * Indicates that outgoing calls are barred.
93      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
94      * See TS 27.007 7.17.
95      */
96     public static final int CODE_1_OUTGOING_CALLS_BARRED       = 5;
97 
98     /**
99      * Indicates that incoming calls are barred.
100      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
101      * See TS 27.007 7.17.
102      */
103     public static final int CODE_1_INCOMING_CALLS_BARRED       = 6;
104 
105     /**
106      * Indicates that CLIR suppression has been rejected for an outgoing call.
107      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
108      * See TS 27.007 7.17.
109      */
110     public static final int CODE_1_CLIR_SUPPRESSION_REJECTED   = 7;
111 
112     /**
113      * Indicates that an outgoing call bas been deflected to another number.
114      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_1}.
115      * See TS 27.007 7.17.
116      */
117     public static final int CODE_1_CALL_DEFLECTED              = 8;
118 
119     /**
120      * Indicates that an incoming call is a forwarded call.
121      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
122      * See TS 27.007 7.17.
123      */
124     public static final int CODE_2_FORWARDED_CALL              = 0;
125 
126     /**
127      * Indicates that an incoming call is from a member of a closed user group.
128      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
129      * See TS 27.007 7.17.
130      */
131     public static final int CODE_2_CUG_CALL                    = 1;
132 
133     /**
134      * Indicates that a call has been remotely put on hold.
135      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
136      * See TS 27.007 7.17.
137      */
138     public static final int CODE_2_CALL_ON_HOLD                = 2;
139 
140     /**
141      * Indicates that a call has been remotely resumed (retrieved).
142      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
143      * See TS 27.007 7.17.
144      */
145     public static final int CODE_2_CALL_RETRIEVED              = 3;
146 
147     /**
148      * Indicates that a conference call has been entered.
149      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
150      * See TS 27.007 7.17.
151      */
152     public static final int CODE_2_MULTI_PARTY_CALL            = 4;
153 
154     /**
155      * Indicates that an ongoing call on hold has been released.
156      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
157      * See TS 27.007 7.17.
158      */
159     public static final int CODE_2_ON_HOLD_CALL_RELEASED       = 5;
160 
161     /**
162      * Indicates that a forward check message was received.
163      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
164      * See TS 27.007 7.17.
165      */
166     public static final int CODE_2_FORWARD_CHECK_RECEIVED      = 6;
167 
168     /**
169      * Indicates that a call is being connected (alerting) with another party as a result of an
170      * explicit call transfer operation.
171      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
172      * See TS 27.007 7.17.
173      */
174     public static final int CODE_2_CALL_CONNECTING_ECT         = 7;
175 
176     /**
177      * Indicates that a call has been connected with another party as a result of an explicit call
178      * transfer operation.
179      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
180      * See TS 27.007 7.17.
181      */
182     public static final int CODE_2_CALL_CONNECTED_ECT          = 8;
183 
184     /**
185      * Indicates that an outgoing call has been deflected to another number.
186      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
187      * See TS 27.007 7.17.
188      */
189     public static final int CODE_2_DEFLECTED_CALL              = 9;
190 
191     /**
192      * Indicates that an additional incoming call has been forwarded.
193      * Valid {@link #code} when {@link #type} is {@link #NOTIFICATION_TYPE_CODE_2}.
194      * See TS 27.007 7.17.
195      */
196     public static final int CODE_2_ADDITIONAL_CALL_FORWARDED   = 10;
197 
198     @Override
toString()199     public String toString()
200     {
201         return super.toString() + " mobile"
202             + (notificationType == 0 ? " originated " : " terminated ")
203             + " code: " + code
204             + " index: " + index
205             + " history: " + Arrays.toString(history)
206             + " \""
207             + PhoneNumberUtils.stringFromStringAndTOA(number, type) + "\" ";
208     }
209 
210 }
211