Home | History | Annotate | Download | only in cdma
      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 Data from SCPT teleservice SMS.
     24  * The CellBroadcastReceiver app receives an Intent with action
     25  * {@link android.provider.Telephony.Sms.Intents#SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION}
     26  * containing an array of these objects to update its list of cell broadcast service categories
     27  * to display.
     28  *
     29  * {@hide}
     30  */
     31 public class CdmaSmsCbProgramData implements Parcelable {
     32 
     33     /** Delete the specified service category from the list of enabled categories. */
     34     public static final int OPERATION_DELETE_CATEGORY   = 0;
     35 
     36     /** Add the specified service category to the list of enabled categories. */
     37     public static final int OPERATION_ADD_CATEGORY      = 1;
     38 
     39     /** Clear all service categories from the list of enabled categories. */
     40     public static final int OPERATION_CLEAR_CATEGORIES  = 2;
     41 
     42     /** Alert option: no alert. */
     43     public static final int ALERT_OPTION_NO_ALERT               = 0;
     44 
     45     /** Alert option: default alert. */
     46     public static final int ALERT_OPTION_DEFAULT_ALERT          = 1;
     47 
     48     /** Alert option: vibrate alert once. */
     49     public static final int ALERT_OPTION_VIBRATE_ONCE           = 2;
     50 
     51     /** Alert option: vibrate alert - repeat. */
     52     public static final int ALERT_OPTION_VIBRATE_REPEAT         = 3;
     53 
     54     /** Alert option: visual alert once. */
     55     public static final int ALERT_OPTION_VISUAL_ONCE            = 4;
     56 
     57     /** Alert option: visual alert - repeat. */
     58     public static final int ALERT_OPTION_VISUAL_REPEAT          = 5;
     59 
     60     /** Alert option: low-priority alert once. */
     61     public static final int ALERT_OPTION_LOW_PRIORITY_ONCE      = 6;
     62 
     63     /** Alert option: low-priority alert - repeat. */
     64     public static final int ALERT_OPTION_LOW_PRIORITY_REPEAT    = 7;
     65 
     66     /** Alert option: medium-priority alert once. */
     67     public static final int ALERT_OPTION_MED_PRIORITY_ONCE      = 8;
     68 
     69     /** Alert option: medium-priority alert - repeat. */
     70     public static final int ALERT_OPTION_MED_PRIORITY_REPEAT    = 9;
     71 
     72     /** Alert option: high-priority alert once. */
     73     public static final int ALERT_OPTION_HIGH_PRIORITY_ONCE     = 10;
     74 
     75     /** Alert option: high-priority alert - repeat. */
     76     public static final int ALERT_OPTION_HIGH_PRIORITY_REPEAT   = 11;
     77 
     78     /** Service category operation (add/delete/clear). */
     79     private final int mOperation;
     80 
     81     /** Service category to modify. */
     82     private final int mCategory;
     83 
     84     /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
     85     private final int mLanguage;
     86 
     87     /** Maximum number of messages to store for this service category. */
     88     private final int mMaxMessages;
     89 
     90     /** Service category alert option. */
     91     private final int mAlertOption;
     92 
     93     /** Name of service category. */
     94     private final String mCategoryName;
     95 
     96     /** Create a new CdmaSmsCbProgramData object with the specified values. */
     97     public CdmaSmsCbProgramData(int operation, int category, int language, int maxMessages,
     98             int alertOption, String categoryName) {
     99         mOperation = operation;
    100         mCategory = category;
    101         mLanguage = language;
    102         mMaxMessages = maxMessages;
    103         mAlertOption = alertOption;
    104         mCategoryName = categoryName;
    105     }
    106 
    107     /** Create a new CdmaSmsCbProgramData object from a Parcel. */
    108     CdmaSmsCbProgramData(Parcel in) {
    109         mOperation = in.readInt();
    110         mCategory = in.readInt();
    111         mLanguage = in.readInt();
    112         mMaxMessages = in.readInt();
    113         mAlertOption = in.readInt();
    114         mCategoryName = in.readString();
    115     }
    116 
    117     /**
    118      * Flatten this object into a Parcel.
    119      *
    120      * @param dest  The Parcel in which the object should be written.
    121      * @param flags Additional flags about how the object should be written (ignored).
    122      */
    123     @Override
    124     public void writeToParcel(Parcel dest, int flags) {
    125         dest.writeInt(mOperation);
    126         dest.writeInt(mCategory);
    127         dest.writeInt(mLanguage);
    128         dest.writeInt(mMaxMessages);
    129         dest.writeInt(mAlertOption);
    130         dest.writeString(mCategoryName);
    131     }
    132 
    133     /**
    134      * Returns the service category operation, e.g. {@link #OPERATION_ADD_CATEGORY}.
    135      * @return one of the {@code OPERATION_*} values
    136      */
    137     public int getOperation() {
    138         return mOperation;
    139     }
    140 
    141     /**
    142      * Returns the CDMA service category to modify.
    143      * @return a 16-bit CDMA service category value
    144      */
    145     public int getCategory() {
    146         return mCategory;
    147     }
    148 
    149     /**
    150      * Returns the CDMA language code for this service category.
    151      * @return one of the language values defined in BearerData.LANGUAGE_*
    152      */
    153     public int getLanguage() {
    154         return mLanguage;
    155     }
    156 
    157     /**
    158      * Returns the maximum number of messages to store for this service category.
    159      * @return the maximum number of messages to store for this service category
    160      */
    161     public int getMaxMessages() {
    162         return mMaxMessages;
    163     }
    164 
    165     /**
    166      * Returns the service category alert option, e.g. {@link #ALERT_OPTION_DEFAULT_ALERT}.
    167      * @return one of the {@code ALERT_OPTION_*} values
    168      */
    169     public int getAlertOption() {
    170         return mAlertOption;
    171     }
    172 
    173     /**
    174      * Returns the service category name, in the language specified by {@link #getLanguage()}.
    175      * @return an optional service category name
    176      */
    177     public String getCategoryName() {
    178         return mCategoryName;
    179     }
    180 
    181     @Override
    182     public String toString() {
    183         return "CdmaSmsCbProgramData{operation=" + mOperation + ", category=" + mCategory
    184                 + ", language=" + mLanguage + ", max messages=" + mMaxMessages
    185                 + ", alert option=" + mAlertOption + ", category name=" + mCategoryName + '}';
    186     }
    187 
    188     /**
    189      * Describe the kinds of special objects contained in the marshalled representation.
    190      * @return a bitmask indicating this Parcelable contains no special objects
    191      */
    192     @Override
    193     public int describeContents() {
    194         return 0;
    195     }
    196 
    197     /** Creator for unparcelling objects. */
    198     public static final Parcelable.Creator<CdmaSmsCbProgramData>
    199             CREATOR = new Parcelable.Creator<CdmaSmsCbProgramData>() {
    200         @Override
    201         public CdmaSmsCbProgramData createFromParcel(Parcel in) {
    202             return new CdmaSmsCbProgramData(in);
    203         }
    204 
    205         @Override
    206         public CdmaSmsCbProgramData[] newArray(int size) {
    207             return new CdmaSmsCbProgramData[size];
    208         }
    209     };
    210 }
    211