• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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 android.telephony.cdma;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.IntDef;
21 import android.annotation.NonNull;
22 import android.annotation.SystemApi;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 
26 import com.android.internal.telephony.flags.Flags;
27 
28 import java.lang.annotation.Retention;
29 import java.lang.annotation.RetentionPolicy;
30 
31 /**
32  * CDMA Service Category Program Data from SCPT (Service Category Programming Teleservice) SMS,
33  * as defined in 3GPP2 C.S0015-B section 4.5.19.
34  * <p>
35  * The CellBroadcastReceiver app receives an Intent with action
36  * {@link android.provider.Telephony.Sms.Intents#SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION}
37  * containing an array of these objects to update its list of cell broadcast service categories
38  * to display.
39  *
40  * @deprecated Legacy CDMA is unsupported.
41  * {@hide}
42  */
43 @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
44 @Deprecated
45 @SystemApi
46 public final class CdmaSmsCbProgramData implements Parcelable {
47 
48     /**
49      * Delete the specified service category from the list of enabled categories.
50      * @deprecated Legacy CDMA is unsupported.
51      */
52     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
53     @Deprecated
54     public static final int OPERATION_DELETE_CATEGORY   = 0;
55 
56     /**
57      * Add the specified service category to the list of enabled categories.
58      * @deprecated Legacy CDMA is unsupported.
59      */
60     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
61     @Deprecated
62     public static final int OPERATION_ADD_CATEGORY      = 1;
63 
64     /**
65      * Clear all service categories from the list of enabled categories.
66      * @deprecated Legacy CDMA is unsupported.
67      */
68     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
69     @Deprecated
70     public static final int OPERATION_CLEAR_CATEGORIES  = 2;
71 
72     /** @hide */
73     @Retention(RetentionPolicy.SOURCE)
74     @IntDef(prefix = {"OPERATION_"},
75             value = {
76                     OPERATION_DELETE_CATEGORY,
77                     OPERATION_ADD_CATEGORY,
78                     OPERATION_CLEAR_CATEGORIES,
79             })
80     public @interface Operation {}
81 
82     // CMAS alert service category assignments, see 3GPP2 C.R1001 table 9.3.3-1
83     /**
84      * Indicates a presidential-level alert
85      * @deprecated Legacy CDMA is unsupported.
86      */
87     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
88     @Deprecated
89     public static final int CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT  = 0x1000;
90 
91     /**
92      * Indicates an extreme threat to life and property
93      * @deprecated Legacy CDMA is unsupported.
94      */
95     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
96     @Deprecated
97     public static final int CATEGORY_CMAS_EXTREME_THREAT            = 0x1001;
98 
99     /**
100      * Indicates an severe threat to life and property
101      * @deprecated Legacy CDMA is unsupported.
102      */
103     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
104     @Deprecated
105     public static final int CATEGORY_CMAS_SEVERE_THREAT             = 0x1002;
106 
107     /**
108      * Indicates an AMBER child abduction emergency
109      * @deprecated Legacy CDMA is unsupported.
110      */
111     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
112     @Deprecated
113     public static final int CATEGORY_CMAS_CHILD_ABDUCTION_EMERGENCY = 0x1003;
114 
115     /**
116      * Indicates a CMAS test message
117      * @deprecated Legacy CDMA is unsupported.
118      */
119     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
120     @Deprecated
121     public static final int CATEGORY_CMAS_TEST_MESSAGE              = 0x1004;
122 
123     /**
124      * The last reserved value of a CMAS service category according to 3GPP C.R1001 table
125      * 9.3.3-1.
126      * @deprecated Legacy CDMA is unsupported.
127      */
128     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
129     @Deprecated
130     public static final int CATEGORY_CMAS_LAST_RESERVED_VALUE       = 0x10ff;
131 
132     /** @hide */
133     @Retention(RetentionPolicy.SOURCE)
134     @IntDef(prefix = {"CATEGORY_"},
135             value = {
136                     CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT,
137                     CATEGORY_CMAS_EXTREME_THREAT,
138                     CATEGORY_CMAS_SEVERE_THREAT,
139                     CATEGORY_CMAS_CHILD_ABDUCTION_EMERGENCY,
140                     CATEGORY_CMAS_TEST_MESSAGE,
141                     CATEGORY_CMAS_LAST_RESERVED_VALUE,
142             })
143     public @interface Category {}
144 
145     /** Alert option: no alert. @hide */
146     public static final int ALERT_OPTION_NO_ALERT               = 0;
147 
148     /** Alert option: default alert. @hide */
149     public static final int ALERT_OPTION_DEFAULT_ALERT          = 1;
150 
151     /** Alert option: vibrate alert once. @hide */
152     public static final int ALERT_OPTION_VIBRATE_ONCE           = 2;
153 
154     /** Alert option: vibrate alert - repeat. @hide */
155     public static final int ALERT_OPTION_VIBRATE_REPEAT         = 3;
156 
157     /** Alert option: visual alert once. @hide */
158     public static final int ALERT_OPTION_VISUAL_ONCE            = 4;
159 
160     /** Alert option: visual alert - repeat. @hide */
161     public static final int ALERT_OPTION_VISUAL_REPEAT          = 5;
162 
163     /** Alert option: low-priority alert once. @hide */
164     public static final int ALERT_OPTION_LOW_PRIORITY_ONCE      = 6;
165 
166     /** Alert option: low-priority alert - repeat. @hide */
167     public static final int ALERT_OPTION_LOW_PRIORITY_REPEAT    = 7;
168 
169     /** Alert option: medium-priority alert once. @hide */
170     public static final int ALERT_OPTION_MED_PRIORITY_ONCE      = 8;
171 
172     /** Alert option: medium-priority alert - repeat. @hide */
173     public static final int ALERT_OPTION_MED_PRIORITY_REPEAT    = 9;
174 
175     /** Alert option: high-priority alert once. @hide */
176     public static final int ALERT_OPTION_HIGH_PRIORITY_ONCE     = 10;
177 
178     /** Alert option: high-priority alert - repeat. @hide */
179     public static final int ALERT_OPTION_HIGH_PRIORITY_REPEAT   = 11;
180 
181     /** Service category operation (add/delete/clear). */
182     private final int mOperation;
183 
184     /** Service category to modify. */
185     private final int mCategory;
186 
187     /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
188     private final int mLanguage;
189 
190     /** Maximum number of messages to store for this service category. */
191     private final int mMaxMessages;
192 
193     /** Service category alert option. */
194     private final int mAlertOption;
195 
196     /** Name of service category. */
197     private final String mCategoryName;
198 
199     /**
200      * Create a new CdmaSmsCbProgramData object with the specified values.
201      * @hide
202      */
CdmaSmsCbProgramData(@peration int operation, @Category int category, int language, int maxMessages, int alertOption, @NonNull String categoryName)203     public CdmaSmsCbProgramData(@Operation int operation, @Category int category, int language,
204             int maxMessages, int alertOption, @NonNull String categoryName) {
205         mOperation = operation;
206         mCategory = category;
207         mLanguage = language;
208         mMaxMessages = maxMessages;
209         mAlertOption = alertOption;
210         mCategoryName = categoryName;
211     }
212 
213     /**
214      * Create a new CdmaSmsCbProgramData object from a Parcel.
215      * @hide
216      */
CdmaSmsCbProgramData(Parcel in)217     CdmaSmsCbProgramData(Parcel in) {
218         mOperation = in.readInt();
219         mCategory = in.readInt();
220         mLanguage = in.readInt();
221         mMaxMessages = in.readInt();
222         mAlertOption = in.readInt();
223         mCategoryName = in.readString();
224     }
225 
226     /**
227      * Flatten this object into a Parcel.
228      *
229      * @param dest  The Parcel in which the object should be written.
230      * @param flags Additional flags about how the object should be written (ignored).
231      * @deprecated Legacy CDMA is unsupported.
232      */
233     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
234     @Deprecated
235     @Override
writeToParcel(Parcel dest, int flags)236     public void writeToParcel(Parcel dest, int flags) {
237         dest.writeInt(mOperation);
238         dest.writeInt(mCategory);
239         dest.writeInt(mLanguage);
240         dest.writeInt(mMaxMessages);
241         dest.writeInt(mAlertOption);
242         dest.writeString(mCategoryName);
243     }
244 
245     /**
246      * Returns the service category operation, e.g. {@link #OPERATION_ADD_CATEGORY}.
247      *
248      * @return the service category operation
249      * @deprecated Legacy CDMA is unsupported.
250      */
251     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
252     @Deprecated
getOperation()253     public @Operation int getOperation() {
254         return mOperation;
255     }
256 
257     /**
258      * Returns the CDMA service category to modify. See 3GPP2 C.S0015-B section 3.4.3.2 for more
259      * information on the service category. Currently only CMAS service categories 0x1000 through
260      * 0x10FF are supported.
261      *
262      * @return a 16-bit CDMA service category value
263      * @deprecated Legacy CDMA is unsupported.
264      */
265     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
266     @Deprecated
getCategory()267     public @Category int getCategory() {
268         return mCategory;
269     }
270 
271     /**
272      * Returns the CDMA language code for this service category.
273      * @return one of the language values defined in BearerData.LANGUAGE_*
274      * @hide
275      */
getLanguage()276     public int getLanguage() {
277         return mLanguage;
278     }
279 
280     /**
281      * Returns the maximum number of messages to store for this service category.
282      * @return the maximum number of messages to store for this service category
283      * @hide
284      */
getMaxMessages()285     public int getMaxMessages() {
286         return mMaxMessages;
287     }
288 
289     /**
290      * Returns the service category alert option, e.g. {@link #ALERT_OPTION_DEFAULT_ALERT}.
291      * @return one of the {@code ALERT_OPTION_*} values
292      * @hide
293      */
getAlertOption()294     public int getAlertOption() {
295         return mAlertOption;
296     }
297 
298     /**
299      * Returns the service category name, in the language specified by {@link #getLanguage()}.
300      * @return an optional service category name
301      * @hide
302      */
303     @NonNull
getCategoryName()304     public String getCategoryName() {
305         return mCategoryName;
306     }
307 
308     @Override
toString()309     public String toString() {
310         return "CdmaSmsCbProgramData{operation=" + mOperation + ", category=" + mCategory
311                 + ", language=" + mLanguage + ", max messages=" + mMaxMessages
312                 + ", alert option=" + mAlertOption + ", category name=" + mCategoryName + '}';
313     }
314 
315     /**
316      * Describe the kinds of special objects contained in the marshalled representation.
317      * @return a bitmask indicating this Parcelable contains no special objects
318      *
319      * @deprecated Legacy CDMA is unsupported.
320      */
321     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
322     @Deprecated
323     @Override
describeContents()324     public int describeContents() {
325         return 0;
326     }
327 
328     /**
329      * Creator for unparcelling objects.
330      *
331      * @deprecated Legacy CDMA is unsupported.
332      */
333     @FlaggedApi(Flags.FLAG_DEPRECATE_CDMA)
334     @Deprecated
335     @NonNull
336     public static final Parcelable.Creator<CdmaSmsCbProgramData>
337             CREATOR = new Parcelable.Creator<CdmaSmsCbProgramData>() {
338         @Override
339         public CdmaSmsCbProgramData createFromParcel(Parcel in) {
340             return new CdmaSmsCbProgramData(in);
341         }
342 
343         @Override
344         public CdmaSmsCbProgramData[] newArray(int size) {
345             return new CdmaSmsCbProgramData[size];
346         }
347     };
348 }
349