summaryrefslogtreecommitdiffstats
path: root/telephony/java/android/telephony/cdma
diff options
context:
space:
mode:
authorJake Hamby <jhamby@google.com>2012-02-06 14:53:43 -0800
committerJake Hamby <jhamby@google.com>2012-03-13 15:31:33 -0700
commit3e3c3f80a90b156ff500076f8655647dfb317acf (patch)
tree27be104fb2617213805f4da4774f2a232d655921 /telephony/java/android/telephony/cdma
parent9dc348d75688faba645c03ecd6e72de7cecc87ba (diff)
downloadframeworks_base-3e3c3f80a90b156ff500076f8655647dfb317acf.zip
frameworks_base-3e3c3f80a90b156ff500076f8655647dfb317acf.tar.gz
frameworks_base-3e3c3f80a90b156ff500076f8655647dfb317acf.tar.bz2
Add support for CMAS warning notifications over CDMA.
Refactor SMS Cell Broadcast support to enable receiving CMAS warning notifications over CDMA. The CellBroadcastReceiver app must also be updated with the corresponding change. All cell broadcasts are now delivered as a Parcelable SmsCbMessage object in the "message" extra of the SMS_CB_RECEIVED_ACTION or SMS_EMERGENCY_CB_RECEIVED_ACTION, instead of as a GSM/UMTS "pdu" byte array. Existing functionality for ETWS and CMAS alerts over GSM/UMTS continues to be supported using the new radio-technology independent SmsCbMessage and related objects. Test cases are added to verify that valid and invalid broadcast data is handled appropriately. Unit testing discovered a bug in the BitwiseOutputStream utility class used by the added test cases. When the BitwiseOutputStream object must be expanded (in the private possExpand() method), the mEnd field is not updated to the new array size. This causes a new array to be allocated on every new write, and for all data beyond the original array allocation to be replaced with zeroes. Fixed by adding a line to possExpand() to update mEnd. Added a test case to BitwiseStreamsTest to verify the fix. Besides the test cases, BitwiseOutputStream is only used by BearerData in two places, both of which allocate a sufficient initial buffer. So the bug in BitwiseOutputStream is not critical to fix for normal operation, but should be fixed so that the test cases using it function correctly. Bug: 5856308 Change-Id: I201ecbf11607fd200aaae3cbb32561efabf65672
Diffstat (limited to 'telephony/java/android/telephony/cdma')
-rw-r--r--telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java210
1 files changed, 210 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java b/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java
new file mode 100644
index 0000000..f94efd8
--- /dev/null
+++ b/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.cdma;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * CDMA Service Category Program Data from SCPT teleservice SMS.
+ * The CellBroadcastReceiver app receives an Intent with action
+ * {@link android.provider.Telephony.Sms.Intents#SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION}
+ * containing an array of these objects to update its list of cell broadcast service categories
+ * to display.
+ *
+ * {@hide}
+ */
+public class CdmaSmsCbProgramData implements Parcelable {
+
+ /** Delete the specified service category from the list of enabled categories. */
+ public static final int OPERATION_DELETE_CATEGORY = 0;
+
+ /** Add the specified service category to the list of enabled categories. */
+ public static final int OPERATION_ADD_CATEGORY = 1;
+
+ /** Clear all service categories from the list of enabled categories. */
+ public static final int OPERATION_CLEAR_CATEGORIES = 2;
+
+ /** Alert option: no alert. */
+ public static final int ALERT_OPTION_NO_ALERT = 0;
+
+ /** Alert option: default alert. */
+ public static final int ALERT_OPTION_DEFAULT_ALERT = 1;
+
+ /** Alert option: vibrate alert once. */
+ public static final int ALERT_OPTION_VIBRATE_ONCE = 2;
+
+ /** Alert option: vibrate alert - repeat. */
+ public static final int ALERT_OPTION_VIBRATE_REPEAT = 3;
+
+ /** Alert option: visual alert once. */
+ public static final int ALERT_OPTION_VISUAL_ONCE = 4;
+
+ /** Alert option: visual alert - repeat. */
+ public static final int ALERT_OPTION_VISUAL_REPEAT = 5;
+
+ /** Alert option: low-priority alert once. */
+ public static final int ALERT_OPTION_LOW_PRIORITY_ONCE = 6;
+
+ /** Alert option: low-priority alert - repeat. */
+ public static final int ALERT_OPTION_LOW_PRIORITY_REPEAT = 7;
+
+ /** Alert option: medium-priority alert once. */
+ public static final int ALERT_OPTION_MED_PRIORITY_ONCE = 8;
+
+ /** Alert option: medium-priority alert - repeat. */
+ public static final int ALERT_OPTION_MED_PRIORITY_REPEAT = 9;
+
+ /** Alert option: high-priority alert once. */
+ public static final int ALERT_OPTION_HIGH_PRIORITY_ONCE = 10;
+
+ /** Alert option: high-priority alert - repeat. */
+ public static final int ALERT_OPTION_HIGH_PRIORITY_REPEAT = 11;
+
+ /** Service category operation (add/delete/clear). */
+ private final int mOperation;
+
+ /** Service category to modify. */
+ private final int mCategory;
+
+ /** Language used for service category name (ISO 639 two character code). */
+ private final String mLanguage;
+
+ /** Maximum number of messages to store for this service category. */
+ private final int mMaxMessages;
+
+ /** Service category alert option. */
+ private final int mAlertOption;
+
+ /** Name of service category. */
+ private final String mCategoryName;
+
+ /** Create a new CdmaSmsCbProgramData object with the specified values. */
+ public CdmaSmsCbProgramData(int operation, int category, String language, int maxMessages,
+ int alertOption, String categoryName) {
+ mOperation = operation;
+ mCategory = category;
+ mLanguage = language;
+ mMaxMessages = maxMessages;
+ mAlertOption = alertOption;
+ mCategoryName = categoryName;
+ }
+
+ /** Create a new CdmaSmsCbProgramData object from a Parcel. */
+ CdmaSmsCbProgramData(Parcel in) {
+ mOperation = in.readInt();
+ mCategory = in.readInt();
+ mLanguage = in.readString();
+ mMaxMessages = in.readInt();
+ mAlertOption = in.readInt();
+ mCategoryName = in.readString();
+ }
+
+ /**
+ * Flatten this object into a Parcel.
+ *
+ * @param dest The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written (ignored).
+ */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mOperation);
+ dest.writeInt(mCategory);
+ dest.writeString(mLanguage);
+ dest.writeInt(mMaxMessages);
+ dest.writeInt(mAlertOption);
+ dest.writeString(mCategoryName);
+ }
+
+ /**
+ * Returns the service category operation, e.g. {@link #OPERATION_ADD_CATEGORY}.
+ * @return one of the {@code OPERATION_*} values
+ */
+ public int getOperation() {
+ return mOperation;
+ }
+
+ /**
+ * Returns the CDMA service category to modify.
+ * @return a 16-bit CDMA service category value
+ */
+ public int getCategory() {
+ return mCategory;
+ }
+
+ /**
+ * Returns the ISO-639-1 language code for the service category name, or null if not present.
+ * @return a two-digit ISO-639-1 language code, e.g. "en" for English
+ */
+ public String getLanguageCode() {
+ return mLanguage;
+ }
+
+ /**
+ * Returns the maximum number of messages to store for this service category.
+ * @return the maximum number of messages to store for this service category
+ */
+ public int getMaxMessages() {
+ return mMaxMessages;
+ }
+
+ /**
+ * Returns the service category alert option, e.g. {@link #ALERT_OPTION_DEFAULT_ALERT}.
+ * @return one of the {@code ALERT_OPTION_*} values
+ */
+ public int getAlertOption() {
+ return mAlertOption;
+ }
+
+ /**
+ * Returns the service category name, in the language specified by {@link #getLanguageCode()}.
+ * @return an optional service category name
+ */
+ public String getCategoryName() {
+ return mCategoryName;
+ }
+
+ @Override
+ public String toString() {
+ return "CdmaSmsCbProgramData{operation=" + mOperation + ", category=" + mCategory
+ + ", language=" + mLanguage + ", max messages=" + mMaxMessages
+ + ", alert option=" + mAlertOption + ", category name=" + mCategoryName + '}';
+ }
+
+ /**
+ * Describe the kinds of special objects contained in the marshalled representation.
+ * @return a bitmask indicating this Parcelable contains no special objects
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Creator for unparcelling objects. */
+ public static final Parcelable.Creator<CdmaSmsCbProgramData>
+ CREATOR = new Parcelable.Creator<CdmaSmsCbProgramData>() {
+ @Override
+ public CdmaSmsCbProgramData createFromParcel(Parcel in) {
+ return new CdmaSmsCbProgramData(in);
+ }
+
+ @Override
+ public CdmaSmsCbProgramData[] newArray(int size) {
+ return new CdmaSmsCbProgramData[size];
+ }
+ };
+}