summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRika Brooks <rbrooks@codeaurora.org>2012-02-06 09:39:43 -0800
committerJake Hamby <jhamby@google.com>2012-10-29 16:42:53 -0700
commit44be3fc486c049bbfea331b0fc2cff0552326f4b (patch)
tree179a0608e444e8b009ee3a78ad115c44e47440bd
parent708cb897813b5239e1d732d08ee2d04f577d09f1 (diff)
downloadframeworks_opt_telephony-44be3fc486c049bbfea331b0fc2cff0552326f4b.zip
frameworks_opt_telephony-44be3fc486c049bbfea331b0fc2cff0552326f4b.tar.gz
frameworks_opt_telephony-44be3fc486c049bbfea331b0fc2cff0552326f4b.tar.bz2
Telephony: Distinguish GSM vs ETWS bc by message id
Per 3GPP TS 24.012 3.1 GSM CB can be less than 88 byes. Fix to distinguish GSM vs ETWS broadcast format by checking message id field rather than length of pdu. Bug: 7417676 Change-Id: I6aeedcd531a89ded7901db33d89ed45baaabbaa7
-rw-r--r--src/java/com/android/internal/telephony/gsm/SmsCbHeader.java75
1 files changed, 39 insertions, 36 deletions
diff --git a/src/java/com/android/internal/telephony/gsm/SmsCbHeader.java b/src/java/com/android/internal/telephony/gsm/SmsCbHeader.java
index 5692044..995f5b1 100644
--- a/src/java/com/android/internal/telephony/gsm/SmsCbHeader.java
+++ b/src/java/com/android/internal/telephony/gsm/SmsCbHeader.java
@@ -95,47 +95,50 @@ class SmsCbHeader {
throw new IllegalArgumentException("Illegal PDU");
}
- if (pdu.length <= PDU_LENGTH_ETWS) {
- format = FORMAT_ETWS_PRIMARY;
- geographicalScope = (pdu[0] & 0xc0) >> 6;
+ if (pdu.length <= PDU_LENGTH_GSM) {
+ // can be ETWS or GSM format.
+ // Per TS23.041 9.4.1.2 and 9.4.1.3.2, GSM and ETWS format both
+ // contain serial number which contains GS, Message Code, and Update Number
+ // per 9.4.1.2.1, and message identifier in same octets
+ geographicalScope = (pdu[0] & 0xc0) >>> 6;
serialNumber = ((pdu[0] & 0xff) << 8) | (pdu[1] & 0xff);
messageIdentifier = ((pdu[2] & 0xff) << 8) | (pdu[3] & 0xff);
- dataCodingScheme = -1;
- pageIndex = -1;
- nrOfPages = -1;
- boolean emergencyUserAlert = (pdu[4] & 0x1) != 0;
- boolean activatePopup = (pdu[5] & 0x80) != 0;
- int warningType = (pdu[4] & 0xfe) >> 1;
- byte[] warningSecurityInfo;
- // copy the Warning-Security-Information, if present
- if (pdu.length > PDU_HEADER_LENGTH) {
- warningSecurityInfo = Arrays.copyOfRange(pdu, 6, pdu.length);
+ if (isEtwsMessage() && pdu.length <= PDU_LENGTH_ETWS) {
+ format = FORMAT_ETWS_PRIMARY;
+ dataCodingScheme = -1;
+ pageIndex = -1;
+ nrOfPages = -1;
+ boolean emergencyUserAlert = (pdu[4] & 0x1) != 0;
+ boolean activatePopup = (pdu[5] & 0x80) != 0;
+ int warningType = (pdu[4] & 0xfe) >>> 1;
+ byte[] warningSecurityInfo;
+ // copy the Warning-Security-Information, if present
+ if (pdu.length > PDU_HEADER_LENGTH) {
+ warningSecurityInfo = Arrays.copyOfRange(pdu, 6, pdu.length);
+ } else {
+ warningSecurityInfo = null;
+ }
+ mEtwsInfo = new SmsCbEtwsInfo(warningType, emergencyUserAlert, activatePopup,
+ warningSecurityInfo);
+ mCmasInfo = null;
+ return; // skip the ETWS/CMAS initialization code for regular notifications
} else {
- warningSecurityInfo = null;
- }
- mEtwsInfo = new SmsCbEtwsInfo(warningType, emergencyUserAlert, activatePopup,
- warningSecurityInfo);
- mCmasInfo = null;
- return; // skip the ETWS/CMAS initialization code for regular notifications
- } else if (pdu.length <= PDU_LENGTH_GSM) {
- // GSM pdus are no more than 88 bytes
- format = FORMAT_GSM;
- geographicalScope = (pdu[0] & 0xc0) >> 6;
- serialNumber = ((pdu[0] & 0xff) << 8) | (pdu[1] & 0xff);
- messageIdentifier = ((pdu[2] & 0xff) << 8) | (pdu[3] & 0xff);
- dataCodingScheme = pdu[4] & 0xff;
+ // GSM pdus are no more than 88 bytes
+ format = FORMAT_GSM;
+ dataCodingScheme = pdu[4] & 0xff;
- // Check for invalid page parameter
- int pageIndex = (pdu[5] & 0xf0) >> 4;
- int nrOfPages = pdu[5] & 0x0f;
+ // Check for invalid page parameter
+ int pageIndex = (pdu[5] & 0xf0) >>> 4;
+ int nrOfPages = pdu[5] & 0x0f;
- if (pageIndex == 0 || nrOfPages == 0 || pageIndex > nrOfPages) {
- pageIndex = 1;
- nrOfPages = 1;
- }
+ if (pageIndex == 0 || nrOfPages == 0 || pageIndex > nrOfPages) {
+ pageIndex = 1;
+ nrOfPages = 1;
+ }
- this.pageIndex = pageIndex;
- this.nrOfPages = nrOfPages;
+ this.pageIndex = pageIndex;
+ this.nrOfPages = nrOfPages;
+ }
} else {
// UMTS pdus are always at least 90 bytes since the payload includes
// a number-of-pages octet and also one length octet per page
@@ -148,7 +151,7 @@ class SmsCbHeader {
}
messageIdentifier = ((pdu[1] & 0xff) << 8) | pdu[2] & 0xff;
- geographicalScope = (pdu[3] & 0xc0) >> 6;
+ geographicalScope = (pdu[3] & 0xc0) >>> 6;
serialNumber = ((pdu[3] & 0xff) << 8) | (pdu[4] & 0xff);
dataCodingScheme = pdu[5] & 0xff;