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.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * CDMA Service Category Program Results from SCPT teleservice SMS.
24  *
25  * {@hide}
26  */
27 public class CdmaSmsCbProgramResults implements Parcelable {
28 
29     /** Program result: success. */
30     public static final int RESULT_SUCCESS                  = 0;
31 
32     /** Program result: memory limit exceeded. */
33     public static final int RESULT_MEMORY_LIMIT_EXCEEDED    = 1;
34 
35     /** Program result: limit exceeded. */
36     public static final int RESULT_CATEGORY_LIMIT_EXCEEDED  = 2;
37 
38     /** Program result: category already opted in. */
39     public static final int RESULT_CATEGORY_ALREADY_ADDED   = 3;
40 
41     /** Program result: category already opted in. */
42     public static final int RESULT_CATEGORY_ALREADY_DELETED = 4;
43 
44     /** Program result: invalid MAX_MESSAGES. */
45     public static final int RESULT_INVALID_MAX_MESSAGES     = 5;
46 
47     /** Program result: invalid ALERT_OPTION. */
48     public static final int RESULT_INVALID_ALERT_OPTION     = 6;
49 
50     /** Program result: invalid service category name. */
51     public static final int RESULT_INVALID_CATEGORY_NAME    = 7;
52 
53     /** Program result: unspecified programming failure. */
54     public static final int RESULT_UNSPECIFIED_FAILURE      = 8;
55 
56     /** Service category to modify. */
57     private final int mCategory;
58 
59     /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
60     private final int mLanguage;
61 
62     /** Result of service category programming for this category. */
63     private final int mCategoryResult;
64 
65     /** Create a new CdmaSmsCbProgramResults object with the specified values. */
CdmaSmsCbProgramResults(int category, int language, int categoryResult)66     public CdmaSmsCbProgramResults(int category, int language, int categoryResult) {
67         mCategory = category;
68         mLanguage = language;
69         mCategoryResult = categoryResult;
70     }
71 
72     /** Create a new CdmaSmsCbProgramResults object from a Parcel. */
CdmaSmsCbProgramResults(Parcel in)73     CdmaSmsCbProgramResults(Parcel in) {
74         mCategory = in.readInt();
75         mLanguage = in.readInt();
76         mCategoryResult = in.readInt();
77     }
78 
79     /**
80      * Flatten this object into a Parcel.
81      *
82      * @param dest  The Parcel in which the object should be written.
83      * @param flags Additional flags about how the object should be written (ignored).
84      */
85     @Override
writeToParcel(Parcel dest, int flags)86     public void writeToParcel(Parcel dest, int flags) {
87         dest.writeInt(mCategory);
88         dest.writeInt(mLanguage);
89         dest.writeInt(mCategoryResult);
90     }
91 
92     /**
93      * Returns the CDMA service category to modify.
94      * @return a 16-bit CDMA service category value
95      */
getCategory()96     public int getCategory() {
97         return mCategory;
98     }
99 
100     /**
101      * Returns the CDMA language code for this service category.
102      * @return one of the language values defined in BearerData.LANGUAGE_*
103      */
getLanguage()104     public int getLanguage() {
105         return mLanguage;
106     }
107 
108     /**
109      * Returns the result of service programming for this category
110      * @return the result of service programming for this category
111      */
getCategoryResult()112     public int getCategoryResult() {
113         return mCategoryResult;
114     }
115 
116     @Override
toString()117     public String toString() {
118         return "CdmaSmsCbProgramResults{category=" + mCategory
119                 + ", language=" + mLanguage + ", result=" + mCategoryResult + '}';
120     }
121 
122     /**
123      * Describe the kinds of special objects contained in the marshalled representation.
124      * @return a bitmask indicating this Parcelable contains no special objects
125      */
126     @Override
describeContents()127     public int describeContents() {
128         return 0;
129     }
130 
131     /** Creator for unparcelling objects. */
132     public static final Parcelable.Creator<CdmaSmsCbProgramResults>
133             CREATOR = new Parcelable.Creator<CdmaSmsCbProgramResults>() {
134         @Override
135         public CdmaSmsCbProgramResults createFromParcel(Parcel in) {
136             return new CdmaSmsCbProgramResults(in);
137         }
138 
139         @Override
140         public CdmaSmsCbProgramResults[] newArray(int size) {
141             return new CdmaSmsCbProgramResults[size];
142         }
143     };
144 }
145