summaryrefslogtreecommitdiffstats
path: root/telephony/java/android
diff options
context:
space:
mode:
authorJake Hamby <jhamby@google.com>2011-06-02 19:52:23 -0700
committerJake Hamby <jhamby@google.com>2011-06-06 18:56:20 -0700
commit66040bbb087b04c4bbac8429f91bbff1029e1440 (patch)
tree81be72248bde2e89b3cf14e46b92161113567492 /telephony/java/android
parentd6ce6791f26fd0a7cf89ded2847011a4894013e1 (diff)
downloadframeworks_base-66040bbb087b04c4bbac8429f91bbff1029e1440.zip
frameworks_base-66040bbb087b04c4bbac8429f91bbff1029e1440.tar.gz
frameworks_base-66040bbb087b04c4bbac8429f91bbff1029e1440.tar.bz2
Fixes for SMS Cell Broadcast support.
Add support for ETWS primary notification messages. Add method for easy concatenation of GSM multi-part broadcasts. Add test cases for SmsCbHeader, SmsCbMessage and IntRangeManager. Change-Id: Ifc646a011e79ad6c7eace9afcf84b1216eb42b7a
Diffstat (limited to 'telephony/java/android')
-rw-r--r--telephony/java/android/telephony/SmsCbConstants.java27
-rw-r--r--telephony/java/android/telephony/SmsCbMessage.java119
2 files changed, 133 insertions, 13 deletions
diff --git a/telephony/java/android/telephony/SmsCbConstants.java b/telephony/java/android/telephony/SmsCbConstants.java
index 1ac9ae3..a1b4adf 100644
--- a/telephony/java/android/telephony/SmsCbConstants.java
+++ b/telephony/java/android/telephony/SmsCbConstants.java
@@ -22,18 +22,6 @@ package android.telephony;
* {@hide}
*/
public interface SmsCbConstants {
- /** Cell wide immediate geographical scope */
- public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE = 0;
-
- /** PLMN wide geographical scope */
- public static final int GEOGRAPHICAL_SCOPE_PLMN_WIDE = 1;
-
- /** Location / service area wide geographical scope */
- public static final int GEOGRAPHICAL_SCOPE_LA_WIDE = 2;
-
- /** Cell wide geographical scope */
- public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE = 3;
-
/** Start of PWS Message Identifier range (includes ETWS and CMAS). */
public static final int MESSAGE_ID_PWS_FIRST_IDENTIFIER = 0x1100;
@@ -111,4 +99,19 @@ public interface SmsCbConstants {
/** ETWS message code flag to activate the emergency user alert. */
public static final int MESSAGE_CODE_ETWS_EMERGENCY_USER_ALERT = 0x200;
+
+ /** ETWS warning type value for earthquake. */
+ public static final int ETWS_WARNING_TYPE_EARTHQUAKE = 0x00;
+
+ /** ETWS warning type value for tsunami. */
+ public static final int ETWS_WARNING_TYPE_TSUNAMI = 0x01;
+
+ /** ETWS warning type value for earthquake and tsunami. */
+ public static final int ETWS_WARNING_TYPE_EARTHQUAKE_AND_TSUNAMI = 0x02;
+
+ /** ETWS warning type value for test broadcast. */
+ public static final int ETWS_WARNING_TYPE_TEST = 0x03;
+
+ /** ETWS warning type value for other notifications. */
+ public static final int ETWS_WARNING_TYPE_OTHER = 0x04;
}
diff --git a/telephony/java/android/telephony/SmsCbMessage.java b/telephony/java/android/telephony/SmsCbMessage.java
index 6da48d6..383e0f9 100644
--- a/telephony/java/android/telephony/SmsCbMessage.java
+++ b/telephony/java/android/telephony/SmsCbMessage.java
@@ -16,9 +16,11 @@
package android.telephony;
+import android.text.format.Time;
import android.util.Log;
import com.android.internal.telephony.GsmAlphabet;
+import com.android.internal.telephony.IccUtils;
import com.android.internal.telephony.gsm.SmsCbHeader;
import java.io.UnsupportedEncodingException;
@@ -93,9 +95,26 @@ public class SmsCbMessage {
private String mBody;
+ /** Timestamp of ETWS primary notification with security. */
+ private long mPrimaryNotificationTimestamp;
+
+ /** 43 byte digital signature of ETWS primary notification with security. */
+ private byte[] mPrimaryNotificationDigitalSignature;
+
private SmsCbMessage(byte[] pdu) throws IllegalArgumentException {
mHeader = new SmsCbHeader(pdu);
- parseBody(pdu);
+ if (mHeader.format == SmsCbHeader.FORMAT_ETWS_PRIMARY) {
+ mBody = "ETWS";
+ // ETWS primary notification with security is 56 octets in length
+ if (pdu.length >= SmsCbHeader.PDU_LENGTH_ETWS) {
+ mPrimaryNotificationTimestamp = getTimestampMillis(pdu);
+ mPrimaryNotificationDigitalSignature = new byte[43];
+ // digital signature starts after 6 byte header and 7 byte timestamp
+ System.arraycopy(pdu, 13, mPrimaryNotificationDigitalSignature, 0, 43);
+ }
+ } else {
+ parseBody(pdu);
+ }
}
/**
@@ -157,6 +176,55 @@ public class SmsCbMessage {
}
/**
+ * Get the format of this message.
+ * @return {@link SmsCbHeader#FORMAT_GSM}, {@link SmsCbHeader#FORMAT_UMTS}, or
+ * {@link SmsCbHeader#FORMAT_ETWS_PRIMARY}
+ */
+ public int getMessageFormat() {
+ return mHeader.format;
+ }
+
+ /**
+ * For ETWS primary notifications, return the emergency user alert flag.
+ * @return true to notify terminal to activate emergency user alert; false otherwise
+ */
+ public boolean getEtwsEmergencyUserAlert() {
+ return mHeader.etwsEmergencyUserAlert;
+ }
+
+ /**
+ * For ETWS primary notifications, return the popup flag.
+ * @return true to notify terminal to activate display popup; false otherwise
+ */
+ public boolean getEtwsPopup() {
+ return mHeader.etwsPopup;
+ }
+
+ /**
+ * For ETWS primary notifications, return the warning type.
+ * @return a value such as {@link SmsCbConstants#ETWS_WARNING_TYPE_EARTHQUAKE}
+ */
+ public int getEtwsWarningType() {
+ return mHeader.etwsWarningType;
+ }
+
+ /**
+ * For ETWS primary notifications, return the Warning-Security-Information timestamp.
+ * @return a timestamp in System.currentTimeMillis() format.
+ */
+ public long getEtwsSecurityTimestamp() {
+ return mPrimaryNotificationTimestamp;
+ }
+
+ /**
+ * For ETWS primary notifications, return the 43 byte digital signature.
+ * @return a byte array containing a copy of the digital signature
+ */
+ public byte[] getEtwsSecuritySignature() {
+ return mPrimaryNotificationDigitalSignature.clone();
+ }
+
+ /**
* Parse and unpack the body text according to the encoding in the DCS.
* After completing successfully this method will have assigned the body
* text into mBody, and optionally the language code into mLanguage
@@ -334,6 +402,55 @@ public class SmsCbMessage {
return body;
}
+ /**
+ * Parses an ETWS primary notification timestamp and returns a currentTimeMillis()-style
+ * timestamp. Copied from com.android.internal.telephony.gsm.SmsMessage.
+ * @param pdu the ETWS primary notification PDU to decode
+ * @return the UTC timestamp from the Warning-Security-Information parameter
+ */
+ private long getTimestampMillis(byte[] pdu) {
+ // Timestamp starts after CB header, in pdu[6]
+ int year = IccUtils.gsmBcdByteToInt(pdu[6]);
+ int month = IccUtils.gsmBcdByteToInt(pdu[7]);
+ int day = IccUtils.gsmBcdByteToInt(pdu[8]);
+ int hour = IccUtils.gsmBcdByteToInt(pdu[9]);
+ int minute = IccUtils.gsmBcdByteToInt(pdu[10]);
+ int second = IccUtils.gsmBcdByteToInt(pdu[11]);
+
+ // For the timezone, the most significant bit of the
+ // least significant nibble is the sign byte
+ // (meaning the max range of this field is 79 quarter-hours,
+ // which is more than enough)
+
+ byte tzByte = pdu[12];
+
+ // Mask out sign bit.
+ int timezoneOffset = IccUtils.gsmBcdByteToInt((byte) (tzByte & (~0x08)));
+
+ timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset;
+
+ Time time = new Time(Time.TIMEZONE_UTC);
+
+ // It's 2006. Should I really support years < 2000?
+ time.year = year >= 90 ? year + 1900 : year + 2000;
+ time.month = month - 1;
+ time.monthDay = day;
+ time.hour = hour;
+ time.minute = minute;
+ time.second = second;
+
+ // Timezone offset is in quarter hours.
+ return time.toMillis(true) - (timezoneOffset * 15 * 60 * 1000);
+ }
+
+ /**
+ * Append text to the message body. This is used to concatenate multi-page GSM broadcasts.
+ * @param body the text to append to this message
+ */
+ public void appendToBody(String body) {
+ mBody = mBody + body;
+ }
+
@Override
public String toString() {
return "SmsCbMessage{" + mHeader.toString() + ", language=" + mLanguage +