Clean up hidden constants
Bug: 135956699
Test: atest CellBroadcastServiceTests, compile with system and verify
that GsmAlphabet and SmsHeader do not add more hidden API usages
Change-Id: I6e0b527d75987825ee70b6f7ac3b42331bc22571
diff --git a/Android.bp b/Android.bp
index 6253385..edfc160 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4,6 +4,7 @@
min_sdk_version: "29",
srcs: [
"src/**/*.java",
+ ":framework-annotations",
":framework-cellbroadcast-shared-srcs",
],
libs: ["telephony-common"],
@@ -48,4 +49,4 @@
"src/**/*.java",
":framework-cellbroadcast-shared-srcs",
],
-}
\ No newline at end of file
+}
diff --git a/src/com/android/cellbroadcastservice/BearerData.java b/src/com/android/cellbroadcastservice/BearerData.java
index 584cd15..b1324d7 100644
--- a/src/com/android/cellbroadcastservice/BearerData.java
+++ b/src/com/android/cellbroadcastservice/BearerData.java
@@ -16,13 +16,11 @@
package com.android.cellbroadcastservice;
-import android.content.res.Resources;
+import android.content.Context;
import android.telephony.SmsCbCmasInfo;
import android.telephony.cdma.CdmaSmsCbProgramData;
import android.util.Log;
-import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.SmsHeader;
import com.android.internal.util.BitwiseInputStream;
/**
@@ -36,22 +34,22 @@
* (See 3GPP2 C.S0015-B, v2.0, table 4.5-1)
* NOTE: Unneeded subparameter types are not included
*/
- private final static byte SUBPARAM_MESSAGE_IDENTIFIER = 0x00;
- private final static byte SUBPARAM_USER_DATA = 0x01;
- private final static byte SUBPARAM_PRIORITY_INDICATOR = 0x08;
- private final static byte SUBPARAM_LANGUAGE_INDICATOR = 0x0D;
+ private static final byte SUBPARAM_MESSAGE_IDENTIFIER = 0x00;
+ private static final byte SUBPARAM_USER_DATA = 0x01;
+ private static final byte SUBPARAM_PRIORITY_INDICATOR = 0x08;
+ private static final byte SUBPARAM_LANGUAGE_INDICATOR = 0x0D;
// All other values after this are reserved.
- private final static byte SUBPARAM_ID_LAST_DEFINED = 0x17;
+ private static final byte SUBPARAM_ID_LAST_DEFINED = 0x17;
/**
* Supported priority modes for CDMA SMS messages
* (See 3GPP2 C.S0015-B, v2.0, table 4.5.9-1)
*/
- public static final int PRIORITY_NORMAL = 0x0;
- public static final int PRIORITY_INTERACTIVE = 0x1;
- public static final int PRIORITY_URGENT = 0x2;
- public static final int PRIORITY_EMERGENCY = 0x3;
+ public static final int PRIORITY_NORMAL = 0x0;
+ public static final int PRIORITY_INTERACTIVE = 0x1;
+ public static final int PRIORITY_URGENT = 0x2;
+ public static final int PRIORITY_EMERGENCY = 0x3;
/**
* Language Indicator values. NOTE: the spec (3GPP2 C.S0015-B,
@@ -60,14 +58,14 @@
* It would seem reasonable to assume the values from C.R1001-F
* (table 9.2-1) are to be used instead.
*/
- public static final int LANGUAGE_UNKNOWN = 0x00;
- public static final int LANGUAGE_ENGLISH = 0x01;
- public static final int LANGUAGE_FRENCH = 0x02;
- public static final int LANGUAGE_SPANISH = 0x03;
+ public static final int LANGUAGE_UNKNOWN = 0x00;
+ public static final int LANGUAGE_ENGLISH = 0x01;
+ public static final int LANGUAGE_FRENCH = 0x02;
+ public static final int LANGUAGE_SPANISH = 0x03;
public static final int LANGUAGE_JAPANESE = 0x04;
- public static final int LANGUAGE_KOREAN = 0x05;
- public static final int LANGUAGE_CHINESE = 0x06;
- public static final int LANGUAGE_HEBREW = 0x07;
+ public static final int LANGUAGE_KOREAN = 0x05;
+ public static final int LANGUAGE_CHINESE = 0x06;
+ public static final int LANGUAGE_HEBREW = 0x07;
/**
* 16-bit value indicating the message ID, which increments modulo 65536.
@@ -105,6 +103,7 @@
/**
* CMAS warning notification information.
+ *
* @see #decodeCmasUserData(BearerData, int)
*/
public SmsCbCmasInfo cmasWarningInfo;
@@ -112,7 +111,8 @@
/**
* Construct an empty BearerData.
*/
- private BearerData() {}
+ private BearerData() {
+ }
private static class CodingException extends Exception {
public CodingException(String s) {
@@ -122,6 +122,7 @@
/**
* Returns the language indicator as a two-character ISO 639 string.
+ *
* @return a two character ISO 639 language code
*/
public String getLanguage() {
@@ -130,6 +131,7 @@
/**
* Converts a CDMA language indicator value to an ISO 639 two character language code.
+ *
* @param languageValue the CDMA language value to convert
* @return the two character ISO 639 language code for the specified value, or null if unknown
*/
@@ -186,7 +188,7 @@
bData.hasUserDataHeader = (inStream.read(1) == 1);
inStream.skip(3);
}
- if ((! decodeSuccess) || (paramBits > 0)) {
+ if ((!decodeSuccess) || (paramBits > 0)) {
Log.d(LOG_TAG, "MESSAGE_IDENTIFIER decode " +
(decodeSuccess ? "succeeded" : "failed") +
" (extra bits = " + paramBits + ")");
@@ -196,8 +198,7 @@
}
private static boolean decodeReserved(BitwiseInputStream inStream, int subparamId)
- throws BitwiseInputStream.AccessException, CodingException
- {
+ throws BitwiseInputStream.AccessException, CodingException {
boolean decodeSuccess = false;
int subparamLen = inStream.read(8); // SUBPARAM_LEN
int paramBits = subparamLen * 8;
@@ -216,8 +217,7 @@
}
private static boolean decodeUserData(BearerData bData, BitwiseInputStream inStream)
- throws BitwiseInputStream.AccessException
- {
+ throws BitwiseInputStream.AccessException {
int paramBits = inStream.read(8) * 8;
bData.userData = new UserData();
bData.userData.msgEncoding = inStream.read(5);
@@ -237,14 +237,12 @@
}
private static String decodeUtf8(byte[] data, int offset, int numFields)
- throws CodingException
- {
+ throws CodingException {
return decodeCharset(data, offset, numFields, 1, "UTF-8");
}
private static String decodeUtf16(byte[] data, int offset, int numFields)
- throws CodingException
- {
+ throws CodingException {
// Subtract header and possible padding byte (at end) from num fields.
int padding = offset % 2;
numFields -= (offset + padding) / 2;
@@ -252,8 +250,7 @@
}
private static String decodeCharset(byte[] data, int offset, int numFields, int width,
- String charset) throws CodingException
- {
+ String charset) throws CodingException {
if (numFields < 0 || (numFields * width + offset) > data.length) {
// Try to decode the max number of characters in payload
int padding = offset % width;
@@ -274,8 +271,7 @@
}
private static String decode7bitAscii(byte[] data, int offset, int numFields)
- throws CodingException
- {
+ throws CodingException {
try {
int offsetBits = offset * 8;
int offsetSeptets = (offsetBits + 6) / 7;
@@ -310,15 +306,14 @@
}
private static String decode7bitGsm(byte[] data, int offset, int numFields)
- throws CodingException
- {
+ throws CodingException {
// Start reading from the next 7-bit aligned boundary after offset.
int offsetBits = offset * 8;
int offsetSeptets = (offsetBits + 6) / 7;
numFields -= offsetSeptets;
int paddingBits = (offsetSeptets * 7) - offsetBits;
- String result = GsmAlphabet.gsm7BitPackedToString(data, offset, numFields, paddingBits,
- 0, 0);
+ String result = GsmAlphabet.gsm7BitPackedToString(data, offset, numFields,
+ paddingBits, 0, 0);
if (result == null) {
throw new CodingException("7bit GSM decoding failed");
}
@@ -326,20 +321,18 @@
}
private static String decodeLatin(byte[] data, int offset, int numFields)
- throws CodingException
- {
+ throws CodingException {
return decodeCharset(data, offset, numFields, 1, "ISO-8859-1");
}
private static String decodeShiftJis(byte[] data, int offset, int numFields)
- throws CodingException
- {
+ throws CodingException {
return decodeCharset(data, offset, numFields, 1, "Shift_JIS");
}
- private static String decodeGsmDcs(byte[] data, int offset, int numFields, int msgType)
- throws CodingException
- {
+ private static String decodeGsmDcs(byte[] data, int offset, int numFields,
+ int msgType)
+ throws CodingException {
if ((msgType & 0xC0) != 0) {
throw new CodingException("unsupported coding group ("
+ msgType + ")");
@@ -358,9 +351,8 @@
}
}
- private static void decodeUserDataPayload(UserData userData, boolean hasUserDataHeader)
- throws CodingException
- {
+ private static void decodeUserDataPayload(Context context, UserData userData,
+ boolean hasUserDataHeader) throws CodingException {
int offset = 0;
if (hasUserDataHeader) {
int udhLen = userData.payload[0] & 0x00FF;
@@ -374,7 +366,7 @@
/*
* Octet decoding depends on the carrier service.
*/
- boolean decodingtypeUTF8 = Resources.getSystem()
+ boolean decodingtypeUTF8 = context.getResources()
.getBoolean(R.bool.config_sms_utf8_support);
// Strip off any padding bytes, meaning any differences between the length of the
@@ -388,7 +380,8 @@
userData.payload = payload;
if (!decodingtypeUTF8) {
- // There are many devices in the market that send 8bit text sms (latin encoded) as
+ // There are many devices in the market that send 8bit text sms (latin
+ // encoded) as
// octet encoded.
userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
} else {
@@ -404,7 +397,8 @@
userData.payloadStr = decodeUtf16(userData.payload, offset, userData.numFields);
break;
case UserData.ENCODING_GSM_7BIT_ALPHABET:
- userData.payloadStr = decode7bitGsm(userData.payload, offset, userData.numFields);
+ userData.payloadStr = decode7bitGsm(userData.payload, offset,
+ userData.numFields);
break;
case UserData.ENCODING_LATIN:
userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
@@ -432,7 +426,7 @@
decodeSuccess = true;
bData.language = inStream.read(8);
}
- if ((! decodeSuccess) || (paramBits > 0)) {
+ if ((!decodeSuccess) || (paramBits > 0)) {
Log.d(LOG_TAG, "LANGUAGE_INDICATOR decode " +
(decodeSuccess ? "succeeded" : "failed") +
" (extra bits = " + paramBits + ")");
@@ -452,7 +446,7 @@
bData.priority = inStream.read(2);
inStream.skip(6);
}
- if ((! decodeSuccess) || (paramBits > 0)) {
+ if ((!decodeSuccess) || (paramBits > 0)) {
Log.d(LOG_TAG, "PRIORITY_INDICATOR decode " +
(decodeSuccess ? "succeeded" : "failed") +
" (extra bits = " + paramBits + ")");
@@ -489,7 +483,7 @@
*
* @param serviceCategory is the service category from the SMS envelope
*/
- private static void decodeCmasUserData(BearerData bData, int serviceCategory)
+ private static void decodeCmasUserData(Context context, BearerData bData, int serviceCategory)
throws BitwiseInputStream.AccessException, CodingException {
BitwiseInputStream inStream = new BitwiseInputStream(bData.userData.payload);
if (inStream.available() < 8) {
@@ -540,7 +534,7 @@
alertUserData.numFields = numFields;
alertUserData.payload = inStream.readByteArray(recordLen * 8 - 5);
- decodeUserDataPayload(alertUserData, false);
+ decodeUserDataPayload(context, alertUserData, false);
bData.userData = alertUserData;
break;
@@ -573,11 +567,11 @@
* Create BearerData object from serialized representation.
* (See 3GPP2 C.R1001-F, v1.0, section 4.5 for layout details)
*
- * @param smsData byte array of raw encoded SMS bearer data.
+ * @param smsData byte array of raw encoded SMS bearer data.
* @param serviceCategory the envelope service category (for CMAS alert handling)
* @return an instance of BearerData.
*/
- public static BearerData decode(byte[] smsData, int serviceCategory) {
+ public static BearerData decode(Context context, byte[] smsData, int serviceCategory) {
try {
BitwiseInputStream inStream = new BitwiseInputStream(smsData);
BearerData bData = new BearerData();
@@ -593,30 +587,30 @@
// reserved subparams are just skipped.
if ((foundSubparamMask & subparamIdBit) != 0 &&
(subparamId >= SUBPARAM_MESSAGE_IDENTIFIER &&
- subparamId <= SUBPARAM_ID_LAST_DEFINED)) {
+ subparamId <= SUBPARAM_ID_LAST_DEFINED)) {
throw new CodingException("illegal duplicate subparameter (" +
- subparamId + ")");
+ subparamId + ")");
}
boolean decodeSuccess;
switch (subparamId) {
- case SUBPARAM_MESSAGE_IDENTIFIER:
- decodeSuccess = decodeMessageId(bData, inStream);
- break;
- case SUBPARAM_USER_DATA:
- decodeSuccess = decodeUserData(bData, inStream);
- break;
- case SUBPARAM_LANGUAGE_INDICATOR:
- decodeSuccess = decodeLanguageIndicator(bData, inStream);
- break;
- case SUBPARAM_PRIORITY_INDICATOR:
- decodeSuccess = decodePriorityIndicator(bData, inStream);
- break;
- default:
- decodeSuccess = decodeReserved(inStream, subparamId);
+ case SUBPARAM_MESSAGE_IDENTIFIER:
+ decodeSuccess = decodeMessageId(bData, inStream);
+ break;
+ case SUBPARAM_USER_DATA:
+ decodeSuccess = decodeUserData(bData, inStream);
+ break;
+ case SUBPARAM_LANGUAGE_INDICATOR:
+ decodeSuccess = decodeLanguageIndicator(bData, inStream);
+ break;
+ case SUBPARAM_PRIORITY_INDICATOR:
+ decodeSuccess = decodePriorityIndicator(bData, inStream);
+ break;
+ default:
+ decodeSuccess = decodeReserved(inStream, subparamId);
}
if (decodeSuccess &&
(subparamId >= SUBPARAM_MESSAGE_IDENTIFIER &&
- subparamId <= SUBPARAM_ID_LAST_DEFINED)) {
+ subparamId <= SUBPARAM_ID_LAST_DEFINED)) {
foundSubparamMask |= subparamIdBit;
}
}
@@ -625,9 +619,9 @@
}
if (bData.userData != null) {
if (isCmasAlertCategory(serviceCategory)) {
- decodeCmasUserData(bData, serviceCategory);
+ decodeCmasUserData(context, bData, serviceCategory);
} else {
- decodeUserDataPayload(bData.userData, bData.hasUserDataHeader);
+ decodeUserDataPayload(context, bData.userData, bData.hasUserDataHeader);
}
}
return bData;
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index 2ac7f84..b3c9d4e 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -59,7 +59,6 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.telephony.metrics.TelephonyMetrics;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -253,12 +252,6 @@
*/
protected void handleBroadcastSms(SmsCbMessage message) {
int slotIndex = message.getSlotIndex();
- // Log Cellbroadcast msg received event
- TelephonyMetrics metrics = TelephonyMetrics.getInstance();
- metrics.writeNewCBSms(slotIndex, message.getMessageFormat(),
- message.getMessagePriority(), message.isCmasMessage(), message.isEtwsMessage(),
- message.getServiceCategory(), message.getSerialNumber(),
- System.currentTimeMillis());
// TODO: Database inserting can be time consuming, therefore this should be changed to
// asynchronous.
diff --git a/src/com/android/cellbroadcastservice/DefaultCellBroadcastService.java b/src/com/android/cellbroadcastservice/DefaultCellBroadcastService.java
index 7b03fef..fdf3b4a 100644
--- a/src/com/android/cellbroadcastservice/DefaultCellBroadcastService.java
+++ b/src/com/android/cellbroadcastservice/DefaultCellBroadcastService.java
@@ -101,7 +101,7 @@
*/
private SmsCbMessage parseBroadcastSms(int slotIndex, String plmn, byte[] bearerData,
int serviceCategory) {
- BearerData bData = BearerData.decode(bearerData, serviceCategory);
+ BearerData bData = BearerData.decode(getApplicationContext(), bearerData, serviceCategory);
if (bData == null) {
Log.w(TAG, "BearerData.decode() returned null");
return null;
diff --git a/src/com/android/cellbroadcastservice/GsmAlphabet.java b/src/com/android/cellbroadcastservice/GsmAlphabet.java
new file mode 100644
index 0000000..aecaf1b
--- /dev/null
+++ b/src/com/android/cellbroadcastservice/GsmAlphabet.java
@@ -0,0 +1,733 @@
+/*
+ * Copyright (C) 2006 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 com.android.cellbroadcastservice;
+
+import android.annotation.UnsupportedAppUsage;
+import android.util.Log;
+import android.util.SparseIntArray;
+
+/**
+ * This class implements the character set mapping between
+ * the GSM SMS 7-bit alphabet specified in TS 23.038 6.2.1
+ * and UTF-16
+ *
+ * {@hide}
+ */
+public class GsmAlphabet {
+ private static final String TAG = "GSM";
+
+ private GsmAlphabet() {
+ }
+
+ /**
+ * This escapes extended characters, and when present indicates that the
+ * following character should be looked up in the "extended" table.
+ *
+ * gsmToChar(GSM_EXTENDED_ESCAPE) returns 0xffff
+ */
+ public static final byte GSM_EXTENDED_ESCAPE = 0x1B;
+
+ /**
+ * User data header requires one octet for length. Count as one septet, because
+ * all combinations of header elements below will have at least one free bit
+ * when padding to the nearest septet boundary.
+ */
+ public static final int UDH_SEPTET_COST_LENGTH = 1;
+
+ /**
+ * Using a non-default language locking shift table OR single shift table
+ * requires a user data header of 3 octets, or 4 septets, plus UDH length.
+ */
+ public static final int UDH_SEPTET_COST_ONE_SHIFT_TABLE = 4;
+
+ /**
+ * Using a non-default language locking shift table AND single shift table
+ * requires a user data header of 6 octets, or 7 septets, plus UDH length.
+ */
+ public static final int UDH_SEPTET_COST_TWO_SHIFT_TABLES = 7;
+
+ /**
+ * Multi-part messages require a user data header of 5 octets, or 6 septets,
+ * plus UDH length.
+ */
+ public static final int UDH_SEPTET_COST_CONCATENATED_MESSAGE = 6;
+
+ /** Reverse mapping from Unicode characters to indexes into language tables. */
+ @UnsupportedAppUsage
+ private static SparseIntArray[] sCharsToGsmTables;
+
+ /** Reverse mapping from Unicode characters to indexes into language shift tables. */
+ @UnsupportedAppUsage
+ private static SparseIntArray[] sCharsToShiftTables;
+
+ /**
+ * GSM default 7 bit alphabet plus national language locking shift character tables.
+ * Comment lines above strings indicate the lower four bits of the table position.
+ */
+ @UnsupportedAppUsage
+ private static final String[] sLanguageTables = {
+ /* 3GPP TS 23.038 V9.1.1 section 6.2.1 - GSM 7 bit Default Alphabet
+ 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0....
+ .1 */
+ "@\u00a3$\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\n\u00d8\u00f8\r\u00c5\u00e5\u0394_"
+ // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.
+ // ....
+ + "\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u00c6\u00e6"
+ + "\u00df"
+ // F.....012.34.....56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789A
+ + "\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u00a1ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ // B.....C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C....
+ // .D.....
+ + "\u00c4\u00d6\u00d1\u00dc\u00a7\u00bfabcdefghijklmnopqrstuvwxyz\u00e4\u00f6"
+ + "\u00f1"
+ // E.....F.....
+ + "\u00fc\u00e0",
+
+ /* A.3.1 Turkish National Language Locking Shift Table
+ 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0....
+ .1 */
+ "@\u00a3$\u00a5\u20ac\u00e9\u00f9\u0131\u00f2\u00c7\n\u011e\u011f\r\u00c5\u00e5\u0394_"
+ // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.
+ // ....
+ + "\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u015e\u015f"
+ + "\u00df"
+ // F.....012.34.....56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789A
+ + "\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u0130ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ // B.....C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C....
+ // .D.....
+ + "\u00c4\u00d6\u00d1\u00dc\u00a7\u00e7abcdefghijklmnopqrstuvwxyz\u00e4\u00f6"
+ + "\u00f1"
+ // E.....F.....
+ + "\u00fc\u00e0",
+
+ /* A.3.2 Void (no locking shift table for Spanish) */
+ "",
+
+ /* A.3.3 Portuguese National Language Locking Shift Table
+ 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0....
+ .1 */
+ "@\u00a3$\u00a5\u00ea\u00e9\u00fa\u00ed\u00f3\u00e7\n\u00d4\u00f4\r\u00c1\u00e1\u0394_"
+ // 2.....3.....4.....5.....67.8.....9.....AB.....C.....D.....E.....F.....012
+ // .34.....
+ + "\u00aa\u00c7\u00c0\u221e^\\\u20ac\u00d3|\uffff\u00c2\u00e2\u00ca\u00c9 "
+ + "!\"#\u00ba"
+ // 56789ABCDEF0123456789ABCDEF0.....123456789ABCDEF0123456789AB.....C.....D..
+ // ...E.....
+ + "%&'()*+,-./0123456789:;<=>?\u00cdABCDEFGHIJKLMNOPQRSTUVWXYZ\u00c3\u00d5"
+ + "\u00da\u00dc"
+ // F.....0123456789ABCDEF0123456789AB.....C.....DE.....F.....
+ + "\u00a7~abcdefghijklmnopqrstuvwxyz\u00e3\u00f5`\u00fc\u00e0",
+
+ /* A.3.4 Bengali National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....0..... */
+ "\u0981\u0982\u0983\u0985\u0986\u0987\u0988\u0989\u098a\u098b\n\u098c \r \u098f\u0990"
+ // 123.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E....
+ // .F.....
+ + " \u0993\u0994\u0995\u0996\u0997\u0998\u0999\u099a\uffff\u099b\u099c\u099d"
+ + "\u099e"
+ // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF....
+ // .0123456789ABC
+ + " !\u099f\u09a0\u09a1\u09a2\u09a3\u09a4)(\u09a5\u09a6,\u09a7"
+ + ".\u09a80123456789:; "
+ // D.....E.....F0.....1.....2.....3.....4.....56.....789A.....B.....C.....D.....
+ + "\u09aa\u09ab?\u09ac\u09ad\u09ae\u09af\u09b0 \u09b2 "
+ + "\u09b6\u09b7\u09b8\u09b9"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD...
+ // ..E.....
+ + "\u09bc\u09bd\u09be\u09bf\u09c0\u09c1\u09c2\u09c3\u09c4 \u09c7\u09c8 "
+ + "\u09cb\u09cc"
+ // F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F.....
+ + "\u09cd\u09ceabcdefghijklmnopqrstuvwxyz\u09d7\u09dc\u09dd\u09f0\u09f1",
+
+ /* A.3.5 Gujarati National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.EF.....0
+ .....*/
+ "\u0a81\u0a82\u0a83\u0a85\u0a86\u0a87\u0a88\u0a89\u0a8a\u0a8b\n\u0a8c\u0a8d\r "
+ + "\u0a8f\u0a90"
+ // 1.....23.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E
+ // .....
+ + "\u0a91 \u0a93\u0a94\u0a95\u0a96\u0a97\u0a98\u0a99\u0a9a\uffff\u0a9b\u0a9c"
+ + "\u0a9d"
+ // F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF....
+ // .0123456789AB
+ + "\u0a9e !\u0a9f\u0aa0\u0aa1\u0aa2\u0aa3\u0aa4)(\u0aa5\u0aa6,\u0aa7"
+ + ".\u0aa80123456789:;"
+ // CD.....E.....F0.....1.....2.....3.....4.....56.....7.....89.....A.....B...
+ // ..C.....
+ + " \u0aaa\u0aab?\u0aac\u0aad\u0aae\u0aaf\u0ab0 \u0ab2\u0ab3 "
+ + "\u0ab5\u0ab6\u0ab7\u0ab8"
+ // D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89.....A
+ // .....
+ + "\u0ab9\u0abc\u0abd\u0abe\u0abf\u0ac0\u0ac1\u0ac2\u0ac3\u0ac4\u0ac5 "
+ + "\u0ac7\u0ac8"
+ // B.....CD.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D....
+ // .E.....
+ + "\u0ac9 \u0acb\u0acc\u0acd\u0ad0abcdefghijklmnopqrstuvwxyz\u0ae0\u0ae1"
+ + "\u0ae2\u0ae3"
+ // F.....
+ + "\u0af1",
+
+ /* A.3.6 Hindi National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.
+ ....*/
+ "\u0901\u0902\u0903\u0905\u0906\u0907\u0908\u0909\u090a\u090b\n\u090c\u090d\r\u090e"
+ + "\u090f"
+ // 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.
+ // ....D.....
+ + "\u0910\u0911\u0912\u0913\u0914\u0915\u0916\u0917\u0918\u0919\u091a\uffff"
+ + "\u091b\u091c"
+ // E.....F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.
+ // ....012345
+ + "\u091d\u091e !\u091f\u0920\u0921\u0922\u0923\u0924)(\u0925\u0926,\u0927"
+ + ".\u0928012345"
+ // 6789ABC.....D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8
+ // .....
+ + "6789:;\u0929\u092a\u092b?\u092c\u092d\u092e\u092f\u0930\u0931\u0932\u0933"
+ + "\u0934"
+ // 9.....A.....B.....C.....D.....E.....F.....0.....1.....2.....3.....4.....5.
+ // ....6.....
+ + "\u0935\u0936\u0937\u0938\u0939\u093c\u093d\u093e\u093f\u0940\u0941\u0942"
+ + "\u0943\u0944"
+ // 7.....8.....9.....A.....B.....C.....D.....E.....F.....0....
+ // .123456789ABCDEF012345678
+ + "\u0945\u0946\u0947\u0948\u0949\u094a\u094b\u094c\u094d"
+ + "\u0950abcdefghijklmnopqrstuvwx"
+ // 9AB.....C.....D.....E.....F.....
+ + "yz\u0972\u097b\u097c\u097e\u097f",
+
+ /* A.3.7 Kannada National Language Locking Shift Table
+ NOTE: TS 23.038 V9.1.1 shows code 0x24 as \u0caa, corrected to \u0ca1 (typo)
+ 01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0....
+ .1 */
+ " \u0c82\u0c83\u0c85\u0c86\u0c87\u0c88\u0c89\u0c8a\u0c8b\n\u0c8c \r\u0c8e\u0c8f\u0c90 "
+ // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.
+ // ....F.....
+ + "\u0c92\u0c93\u0c94\u0c95\u0c96\u0c97\u0c98\u0c99\u0c9a\uffff\u0c9b\u0c9c"
+ + "\u0c9d\u0c9e"
+ // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF....
+ // .0123456789ABC
+ + " !\u0c9f\u0ca0\u0ca1\u0ca2\u0ca3\u0ca4)(\u0ca5\u0ca6,\u0ca7"
+ + ".\u0ca80123456789:; "
+ // D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....89.....A....
+ // .B.....
+ + "\u0caa\u0cab?\u0cac\u0cad\u0cae\u0caf\u0cb0\u0cb1\u0cb2\u0cb3 "
+ + "\u0cb5\u0cb6\u0cb7"
+ // C.....D.....E.....F.....0.....1.....2.....3.....4.....5.....6.....78.....9
+ // .....
+ + "\u0cb8\u0cb9\u0cbc\u0cbd\u0cbe\u0cbf\u0cc0\u0cc1\u0cc2\u0cc3\u0cc4 "
+ + "\u0cc6\u0cc7"
+ // A.....BC.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C....
+ // .D.....
+ + "\u0cc8 \u0cca\u0ccb\u0ccc\u0ccd\u0cd5abcdefghijklmnopqrstuvwxyz\u0cd6"
+ + "\u0ce0\u0ce1"
+ // E.....F.....
+ + "\u0ce2\u0ce3",
+
+ /* A.3.8 Malayalam National Language Locking Shift Table
+ 01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0....
+ .1 */
+ " \u0d02\u0d03\u0d05\u0d06\u0d07\u0d08\u0d09\u0d0a\u0d0b\n\u0d0c \r\u0d0e\u0d0f\u0d10 "
+ // 2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.
+ // ....F.....
+ + "\u0d12\u0d13\u0d14\u0d15\u0d16\u0d17\u0d18\u0d19\u0d1a\uffff\u0d1b\u0d1c"
+ + "\u0d1d\u0d1e"
+ // 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF....
+ // .0123456789ABC
+ + " !\u0d1f\u0d20\u0d21\u0d22\u0d23\u0d24)(\u0d25\u0d26,\u0d27"
+ + ".\u0d280123456789:; "
+ // D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A
+ // .....
+ + "\u0d2a\u0d2b?\u0d2c\u0d2d\u0d2e\u0d2f\u0d30\u0d31\u0d32\u0d33\u0d34\u0d35"
+ + "\u0d36"
+ // B.....C.....D.....EF.....0.....1.....2.....3.....4.....5.....6.....78....
+ // .9.....
+ + "\u0d37\u0d38\u0d39 \u0d3d\u0d3e\u0d3f\u0d40\u0d41\u0d42\u0d43\u0d44 "
+ + "\u0d46\u0d47"
+ // A.....BC.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C....
+ // .D.....
+ + "\u0d48 \u0d4a\u0d4b\u0d4c\u0d4d\u0d57abcdefghijklmnopqrstuvwxyz\u0d60"
+ + "\u0d61\u0d62"
+ // E.....F.....
+ + "\u0d63\u0d79",
+
+ /* A.3.9 Oriya National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....0....
+ .12 */
+ "\u0b01\u0b02\u0b03\u0b05\u0b06\u0b07\u0b08\u0b09\u0b0a\u0b0b\n\u0b0c \r \u0b0f\u0b10 "
+ // 3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.
+ // ....01
+ + "\u0b13\u0b14\u0b15\u0b16\u0b17\u0b18\u0b19\u0b1a\uffff\u0b1b\u0b1c\u0b1d"
+ + "\u0b1e !"
+ // 2.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF....
+ // .0123456789ABCD.....
+ + "\u0b1f\u0b20\u0b21\u0b22\u0b23\u0b24)(\u0b25\u0b26,\u0b27"
+ + ".\u0b280123456789:; \u0b2a"
+ // E.....F0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C....
+ // .D.....
+ + "\u0b2b?\u0b2c\u0b2d\u0b2e\u0b2f\u0b30 \u0b32\u0b33 "
+ + "\u0b35\u0b36\u0b37\u0b38\u0b39"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD...
+ // ..E.....
+ + "\u0b3c\u0b3d\u0b3e\u0b3f\u0b40\u0b41\u0b42\u0b43\u0b44 \u0b47\u0b48 "
+ + "\u0b4b\u0b4c"
+ // F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F.....
+ + "\u0b4d\u0b56abcdefghijklmnopqrstuvwxyz\u0b57\u0b60\u0b61\u0b62\u0b63",
+
+ /* A.3.10 Punjabi National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.EF.....0.....123.....4.
+ ....*/
+ "\u0a01\u0a02\u0a03\u0a05\u0a06\u0a07\u0a08\u0a09\u0a0a \n \r \u0a0f\u0a10 "
+ + "\u0a13\u0a14"
+ // 5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....012....
+ // .3.....
+ + "\u0a15\u0a16\u0a17\u0a18\u0a19\u0a1a\uffff\u0a1b\u0a1c\u0a1d\u0a1e "
+ + "!\u0a1f\u0a20"
+ // 4.....5.....6.....7.....89A.....B.....CD.....EF.....0123456789ABCD.....E..
+ // ...F0.....
+ + "\u0a21\u0a22\u0a23\u0a24)(\u0a25\u0a26,\u0a27.\u0a280123456789:; "
+ + "\u0a2a\u0a2b?\u0a2c"
+ // 1.....2.....3.....4.....56.....7.....89.....A.....BC.....D.....E.....F0...
+ // ..1.....
+ + "\u0a2d\u0a2e\u0a2f\u0a30 \u0a32\u0a33 \u0a35\u0a36 \u0a38\u0a39\u0a3c "
+ + "\u0a3e\u0a3f"
+ // 2.....3.....4.....56789.....A.....BCD.....E.....F.....0....
+ // .123456789ABCDEF012345678
+ + "\u0a40\u0a41\u0a42 \u0a47\u0a48 "
+ + "\u0a4b\u0a4c\u0a4d\u0a51abcdefghijklmnopqrstuvwx"
+ // 9AB.....C.....D.....E.....F.....
+ + "yz\u0a70\u0a71\u0a72\u0a73\u0a74",
+
+ /* A.3.11 Tamil National Language Locking Shift Table
+ 01.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.E.....F.....0.....12.....3..
+ ... */
+ " \u0b82\u0b83\u0b85\u0b86\u0b87\u0b88\u0b89\u0b8a \n \r\u0b8e\u0b8f\u0b90 "
+ + "\u0b92\u0b93"
+ // 4.....5.....6789.....A.....B.....CD.....EF.....012.....3456.....7....
+ // .89ABCDEF.....
+ + "\u0b94\u0b95 \u0b99\u0b9a\uffff \u0b9c \u0b9e !\u0b9f \u0ba3\u0ba4)( "
+ + ", .\u0ba8"
+ // 0123456789ABC.....D.....EF012.....3.....4.....5.....6.....7.....8.....9...
+ // ..A.....
+ + "0123456789:;\u0ba9\u0baa ? "
+ + "\u0bae\u0baf\u0bb0\u0bb1\u0bb2\u0bb3\u0bb4\u0bb5\u0bb6"
+ // B.....C.....D.....EF0.....1.....2.....3.....4.....5678.....9.....A.....BC.
+ // ....D.....
+ + "\u0bb7\u0bb8\u0bb9 \u0bbe\u0bbf\u0bc0\u0bc1\u0bc2 \u0bc6\u0bc7\u0bc8 "
+ + "\u0bca\u0bcb"
+ // E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D.....E.....F.....
+ + "\u0bcc\u0bcd\u0bd0abcdefghijklmnopqrstuvwxyz\u0bd7\u0bf0\u0bf1\u0bf2\u0bf9",
+
+ /* A.3.12 Telugu National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....0
+ .....*/
+ "\u0c01\u0c02\u0c03\u0c05\u0c06\u0c07\u0c08\u0c09\u0c0a\u0c0b\n\u0c0c "
+ + "\r\u0c0e\u0c0f\u0c10"
+ // 12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E
+ // .....
+ + " \u0c12\u0c13\u0c14\u0c15\u0c16\u0c17\u0c18\u0c19\u0c1a\uffff\u0c1b\u0c1c"
+ + "\u0c1d"
+ // F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF....
+ // .0123456789AB
+ + "\u0c1e !\u0c1f\u0c20\u0c21\u0c22\u0c23\u0c24)(\u0c25\u0c26,\u0c27"
+ + ".\u0c280123456789:;"
+ // CD.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....89.....A....
+ // .B.....
+ + " \u0c2a\u0c2b?\u0c2c\u0c2d\u0c2e\u0c2f\u0c30\u0c31\u0c32\u0c33 "
+ + "\u0c35\u0c36\u0c37"
+ // C.....D.....EF.....0.....1.....2.....3.....4.....5.....6.....78.....9....
+ // .A.....B
+ + "\u0c38\u0c39 \u0c3d\u0c3e\u0c3f\u0c40\u0c41\u0c42\u0c43\u0c44 "
+ + "\u0c46\u0c47\u0c48 "
+ // C.....D.....E.....F.....0.....123456789ABCDEF0123456789AB.....C.....D....
+ // .E.....
+ + "\u0c4a\u0c4b\u0c4c\u0c4d\u0c55abcdefghijklmnopqrstuvwxyz\u0c56\u0c60\u0c61"
+ + "\u0c62"
+ // F.....
+ + "\u0c63",
+
+ /* A.3.13 Urdu National Language Locking Shift Table
+ 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.
+ ....*/
+ "\u0627\u0622\u0628\u067b\u0680\u067e\u06a6\u062a\u06c2\u067f\n\u0679\u067d\r\u067a"
+ + "\u067c"
+ // 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.
+ // ....D.....
+ + "\u062b\u062c\u0681\u0684\u0683\u0685\u0686\u0687\u062d\u062e\u062f\uffff"
+ + "\u068c\u0688"
+ // E.....F.....012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.
+ // ....012345
+ + "\u0689\u068a !\u068f\u068d\u0630\u0631\u0691\u0693)(\u0699\u0632,\u0696"
+ + ".\u0698012345"
+ // 6789ABC.....D.....E.....F0.....1.....2.....3.....4.....5.....6.....7.....8
+ // .....
+ + "6789:;\u069a\u0633\u0634?\u0635\u0636\u0637\u0638\u0639\u0641\u0642\u06a9"
+ + "\u06aa"
+ // 9.....A.....B.....C.....D.....E.....F.....0.....1.....2.....3.....4.....5.
+ // ....6.....
+ + "\u06ab\u06af\u06b3\u06b1\u0644\u0645\u0646\u06ba\u06bb\u06bc\u0648\u06c4"
+ + "\u06d5\u06c1"
+ // 7.....8.....9.....A.....B.....C.....D.....E.....F.....0....
+ // .123456789ABCDEF012345678
+ + "\u06be\u0621\u06cc\u06d0\u06d2\u064d\u0650\u064f\u0657"
+ + "\u0654abcdefghijklmnopqrstuvwx"
+ // 9AB.....C.....D.....E.....F.....
+ + "yz\u0655\u0651\u0653\u0656\u0670"
+ };
+
+ /**
+ * GSM default extension table plus national language single shift character tables.
+ */
+ @UnsupportedAppUsage
+ private static final String[] sLanguageShiftTables = new String[]{
+ /* 6.2.1.1 GSM 7 bit Default Alphabet Extension Table
+ 0123456789A.....BCDEF0123456789ABCDEF0123456789ABCDEF
+ .0123456789ABCDEF0123456789ABCDEF */
+ " \u000c ^ {} \\ [~] | "
+ // 0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
+ + " \u20ac ",
+
+ /* A.2.1 Turkish National Language Single Shift Table
+ 0123456789A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF01234567.....8 */
+ " \u000c ^ {} \\ [~] | \u011e "
+ // 9.....ABCDEF0123.....456789ABCDEF0123.....45.....67.....89.....ABCDEF0123.
+ // ....
+ + "\u0130 \u015e \u00e7 \u20ac \u011f \u0131 "
+ + "\u015f"
+ // 456789ABCDEF
+ + " ",
+
+ /* A.2.2 Spanish National Language Single Shift Table
+ 0123456789.....A.....BCDEF0123456789ABCDEF0123456789ABCDEF.0123456789ABCDEF01.....23 */
+ " \u00e7\u000c ^ {} \\ [~] |\u00c1 "
+ // 456789.....ABCDEF.....012345.....6789ABCDEF01.....2345.....6789.....ABCDEF
+ // .....012
+ + " \u00cd \u00d3 \u00da \u00e1 \u20ac \u00ed "
+ + "\u00f3 "
+ // 345.....6789ABCDEF
+ + " \u00fa ",
+
+ /* A.2.3 Portuguese National Language Single Shift Table
+ 012345.....6789.....A.....B.....C.....DE.....F.....012.....3.....45.....6.....7....
+ .8....*/
+ " \u00ea \u00e7\u000c\u00d4\u00f4 \u00c1\u00e1 "
+ + "\u03a6\u0393^\u03a9\u03a0\u03a8\u03a3"
+ // 9.....ABCDEF.....0123456789ABCDEF.0123456789ABCDEF01.....23456789.....ABCDE
+ + "\u0398 \u00ca {} \\ [~] |\u00c0 \u00cd "
+ // F.....012345.....6789AB.....C.....DEF01.....2345.....6789.....ABCDEF....
+ // .01234
+ + "\u00d3 \u00da \u00c3\u00d5 \u00c2 \u20ac \u00ed \u00f3 "
+ + " "
+ // 5.....6789AB.....C.....DEF.....
+ + "\u00fa \u00e3\u00f5 \u00e2",
+
+ /* A.2.4 Bengali National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u09e6\u09e7 \u09e8\u09e9"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....
+ + "\u09ea\u09eb\u09ec\u09ed\u09ee\u09ef\u09df\u09e0\u09e1\u09e2{}\u09e3\u09f2"
+ + "\u09f3"
+ // D.....E.....F.0.....1.....2.....3.....4.....56789ABCDEF0123456789ABCDEF
+ + "\u09f4\u09f5\\\u09f6\u09f7\u09f8\u09f9\u09fa [~] |ABCDEFGHIJKLMNO"
+ // 0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
+ + "PQRSTUVWXYZ \u20ac ",
+
+ /* A.2.5 Gujarati National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0ae6\u0ae7"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6789ABCDEF.0123456789ABCDEF
+ + "\u0ae8\u0ae9\u0aea\u0aeb\u0aec\u0aed\u0aee\u0aef {} \\ [~] "
+ // 0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
+ + "|ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac ",
+
+ /* A.2.6 Hindi National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0966\u0967"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....
+ + "\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f\u0951\u0952{}\u0953\u0954"
+ + "\u0958"
+ // D.....E.....F.0.....1.....2.....3.....4.....5.....6.....7.....8.....9....
+ // .A.....
+ + "\u0959\u095a\\\u095b\u095c\u095d\u095e\u095f\u0960\u0961\u0962\u0963\u0970"
+ + "\u0971"
+ // BCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
+ + " [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac ",
+
+ /* A.2.7 Kannada National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0ce6\u0ce7"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....BCDEF
+ // .01234567
+ + "\u0ce8\u0ce9\u0cea\u0ceb\u0cec\u0ced\u0cee\u0cef\u0cde\u0cf1{}\u0cf2 \\"
+ + " "
+ // 89ABCDEF0123456789ABCDEF0123456789ABCDEF012345.....6789ABCDEF0123456789ABCDEF
+ + " [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac "
+ + " ",
+
+ /* A.2.8 Malayalam National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0d66\u0d67"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....
+ + "\u0d68\u0d69\u0d6a\u0d6b\u0d6c\u0d6d\u0d6e\u0d6f\u0d70\u0d71{}\u0d72\u0d73"
+ + "\u0d74"
+ // D.....E.....F.0.....1.....2.....3.....4....
+ // .56789ABCDEF0123456789ABCDEF0123456789A
+ + "\u0d75\u0d7a\\\u0d7b\u0d7c\u0d7d\u0d7e\u0d7f [~] "
+ + "|ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ // BCDEF012345.....6789ABCDEF0123456789ABCDEF
+ + " \u20ac ",
+
+ /* A.2.9 Oriya National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0b66\u0b67"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....DE
+ + "\u0b68\u0b69\u0b6a\u0b6b\u0b6c\u0b6d\u0b6e\u0b6f\u0b5c\u0b5d{}\u0b5f\u0b70"
+ + "\u0b71 "
+ // F.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345....
+ // .6789ABCDEF0123456789A
+ + "\\ [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac "
+ + " "
+ // BCDEF
+ + " ",
+
+ /* A.2.10 Punjabi National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0a66\u0a67"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....
+ + "\u0a68\u0a69\u0a6a\u0a6b\u0a6c\u0a6d\u0a6e\u0a6f\u0a59\u0a5a{}\u0a5b\u0a5c"
+ + "\u0a5e"
+ // D.....EF.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345....
+ // .6789ABCDEF01
+ + "\u0a75 \\ [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac "
+ + " "
+ // 23456789ABCDEF
+ + " ",
+
+ /* A.2.11 Tamil National Language Single Shift Table
+ NOTE: TS 23.038 V9.1.1 shows code 0x24 as \u0bef, corrected to \u0bee (typo)
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0964\u0965 \u0be6\u0be7"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....
+ + "\u0be8\u0be9\u0bea\u0beb\u0bec\u0bed\u0bee\u0bef\u0bf3\u0bf4{}\u0bf5\u0bf6"
+ + "\u0bf7"
+ // D.....E.....F.0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345....
+ // .6789ABC
+ + "\u0bf8\u0bfa\\ [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac "
+ + " "
+ // DEF0123456789ABCDEF
+ + " ",
+
+ /* A.2.12 Telugu National Language Single Shift Table
+ NOTE: TS 23.038 V9.1.1 shows code 0x22-0x23 as \u06cc\u06cd, corrected to
+ \u0c6c\u0c6d
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789ABC.....D.....E.....F.
+ .... */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#* "
+ + "\u0c66\u0c67\u0c68\u0c69"
+ // 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D....
+ // .E.....F.
+ + "\u0c6a\u0c6b\u0c6c\u0c6d\u0c6e\u0c6f\u0c58\u0c59{}\u0c78\u0c79\u0c7a\u0c7b"
+ + "\u0c7c\\"
+ // 0.....1.....2.....3456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345....
+ // .6789ABCD
+ + "\u0c7d\u0c7e\u0c7f [~] |ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac"
+ + " "
+ // EF0123456789ABCDEF
+ + " ",
+
+ /* A.2.13 Urdu National Language Single Shift Table
+ 01.....23.....4.....5.6.....789A.....BCDEF0123.....45.....6789.....A.....BC.....D...
+ .. */
+ "@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+ -/<=>\u00a1^\u00a1_#*\u0600\u0601 \u06f0\u06f1"
+ // E.....F.....0.....1.....2.....3.....4.....5.....6.....7.....89A.....B....
+ // .C.....
+ + "\u06f2\u06f3\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9\u060c\u060d{}\u060e\u060f"
+ + "\u0610"
+ // D.....E.....F.0.....1.....2.....3.....4.....5.....6.....7.....8.....9....
+ // .A.....
+ + "\u0611\u0612\\\u0613\u0614\u061b\u061f\u0640\u0652\u0658\u066b\u066c\u0672"
+ + "\u0673"
+ // B.....CDEF.....0123456789ABCDEF0123456789ABCDEF012345....
+ // .6789ABCDEF0123456789ABCDEF
+ + "\u06cd[~]\u06d4|ABCDEFGHIJKLMNOPQRSTUVWXYZ \u20ac "
+ + " "
+ };
+
+ static {
+ int numTables = sLanguageTables.length;
+ int numShiftTables = sLanguageShiftTables.length;
+ if (numTables != numShiftTables) {
+ Log.e(TAG, "Error: language tables array length " + numTables
+ + " != shift tables array length " + numShiftTables);
+ }
+
+ sCharsToGsmTables = new SparseIntArray[numTables];
+ for (int i = 0; i < numTables; i++) {
+ String table = sLanguageTables[i];
+
+ int tableLen = table.length();
+ if (tableLen != 0 && tableLen != 128) {
+ Log.e(TAG, "Error: language tables index " + i + " length " + tableLen
+ + " (expected 128 or 0)");
+ }
+
+ SparseIntArray charToGsmTable = new SparseIntArray(tableLen);
+ sCharsToGsmTables[i] = charToGsmTable;
+ for (int j = 0; j < tableLen; j++) {
+ char c = table.charAt(j);
+ charToGsmTable.put(c, j);
+ }
+ }
+
+ sCharsToShiftTables = new SparseIntArray[numShiftTables];
+ for (int i = 0; i < numShiftTables; i++) {
+ String shiftTable = sLanguageShiftTables[i];
+
+ int shiftTableLen = shiftTable.length();
+ if (shiftTableLen != 0 && shiftTableLen != 128) {
+ Log.e(TAG, "Error: language shift tables index " + i + " length " + shiftTableLen
+ + " (expected 128 or 0)");
+ }
+
+ SparseIntArray charToShiftTable = new SparseIntArray(shiftTableLen);
+ sCharsToShiftTables[i] = charToShiftTable;
+ for (int j = 0; j < shiftTableLen; j++) {
+ char c = shiftTable.charAt(j);
+ if (c != ' ') {
+ charToShiftTable.put(c, j);
+ }
+ }
+ }
+ }
+
+ /**
+ * Convert a GSM alphabet 7 bit packed string (SMS string) into a
+ * {@link java.lang.String}.
+ *
+ * See TS 23.038 6.1.2.1 for SMS Character Packing
+ *
+ * @param pdu the raw data from the pdu
+ * @param offset the byte offset of
+ * @param lengthSeptets string length in septets, not bytes
+ * @return String representation or null on decoding exception
+ */
+ @UnsupportedAppUsage
+ public static String gsm7BitPackedToString(byte[] pdu, int offset,
+ int lengthSeptets) {
+ return gsm7BitPackedToString(pdu, offset, lengthSeptets, 0, 0, 0);
+ }
+
+ /**
+ * Convert a GSM alphabet 7 bit packed string (SMS string) into a
+ * {@link java.lang.String}.
+ *
+ * See TS 23.038 6.1.2.1 for SMS Character Packing
+ *
+ * @param pdu the raw data from the pdu
+ * @param offset the byte offset of
+ * @param lengthSeptets string length in septets, not bytes
+ * @param numPaddingBits the number of padding bits before the start of the
+ * string in the first byte
+ * @param languageTable the 7 bit language table, or 0 for the default GSM alphabet
+ * @param shiftTable the 7 bit single shift language table, or 0 for the default
+ * GSM extension table
+ * @return String representation or null on decoding exception
+ */
+ @UnsupportedAppUsage
+ public static String gsm7BitPackedToString(byte[] pdu, int offset,
+ int lengthSeptets, int numPaddingBits, int languageTable, int shiftTable) {
+ StringBuilder ret = new StringBuilder(lengthSeptets);
+
+ if (languageTable < 0 || languageTable > sLanguageTables.length) {
+ Log.w(TAG, "unknown language table " + languageTable + ", using default");
+ languageTable = 0;
+ }
+ if (shiftTable < 0 || shiftTable > sLanguageShiftTables.length) {
+ Log.w(TAG, "unknown single shift table " + shiftTable + ", using default");
+ shiftTable = 0;
+ }
+
+ try {
+ boolean prevCharWasEscape = false;
+ String languageTableToChar = sLanguageTables[languageTable];
+ String shiftTableToChar = sLanguageShiftTables[shiftTable];
+
+ if (languageTableToChar.isEmpty()) {
+ Log.w(TAG, "no language table for code " + languageTable + ", using default");
+ languageTableToChar = sLanguageTables[0];
+ }
+ if (shiftTableToChar.isEmpty()) {
+ Log.w(TAG, "no single shift table for code " + shiftTable + ", using default");
+ shiftTableToChar = sLanguageShiftTables[0];
+ }
+
+ for (int i = 0; i < lengthSeptets; i++) {
+ int bitOffset = (7 * i) + numPaddingBits;
+
+ int byteOffset = bitOffset / 8;
+ int shift = bitOffset % 8;
+ int gsmVal;
+
+ gsmVal = (0x7f & (pdu[offset + byteOffset] >> shift));
+
+ // if it crosses a byte boundary
+ if (shift > 1) {
+ // set msb bits to 0
+ gsmVal &= 0x7f >> (shift - 1);
+
+ gsmVal |= 0x7f & (pdu[offset + byteOffset + 1] << (8 - shift));
+ }
+
+ if (prevCharWasEscape) {
+ if (gsmVal == GSM_EXTENDED_ESCAPE) {
+ ret.append(' '); // display ' ' for reserved double escape sequence
+ } else {
+ char c = shiftTableToChar.charAt(gsmVal);
+ if (c == ' ') {
+ ret.append(languageTableToChar.charAt(gsmVal));
+ } else {
+ ret.append(c);
+ }
+ }
+ prevCharWasEscape = false;
+ } else if (gsmVal == GSM_EXTENDED_ESCAPE) {
+ prevCharWasEscape = true;
+ } else {
+ ret.append(languageTableToChar.charAt(gsmVal));
+ }
+ }
+ } catch (RuntimeException ex) {
+ Log.e(TAG, "Error GSM 7 bit packed: ", ex);
+ return null;
+ }
+
+ return ret.toString();
+ }
+}
diff --git a/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java b/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java
index 333b5ba..2f16555 100644
--- a/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java
@@ -16,8 +16,6 @@
package com.android.cellbroadcastservice;
-import static com.android.internal.telephony.gsm.SmsCbConstants.MESSAGE_ID_CMAS_GEO_FENCING_TRIGGER;
-
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
@@ -219,7 +217,7 @@
if (header == null) return false;
log("header=" + header);
- if (header.getServiceCategory() == MESSAGE_ID_CMAS_GEO_FENCING_TRIGGER) {
+ if (header.getServiceCategory() == SmsCbConstants.MESSAGE_ID_CMAS_GEO_FENCING_TRIGGER) {
GeoFencingTriggerMessage triggerMessage =
GsmSmsCbMessage.createGeoFencingTriggerMessage(pdu);
if (triggerMessage != null) {
diff --git a/src/com/android/cellbroadcastservice/GsmSmsCbMessage.java b/src/com/android/cellbroadcastservice/GsmSmsCbMessage.java
index b8b6f5a..d17c084 100644
--- a/src/com/android/cellbroadcastservice/GsmSmsCbMessage.java
+++ b/src/com/android/cellbroadcastservice/GsmSmsCbMessage.java
@@ -29,6 +29,7 @@
import android.telephony.CbGeoUtils.LatLng;
import android.telephony.SmsCbLocation;
import android.telephony.SmsCbMessage;
+import android.telephony.SmsMessage;
import android.util.Pair;
import android.util.Slog;
@@ -37,8 +38,6 @@
import com.android.cellbroadcastservice.GsmSmsCbMessage.GeoFencingTriggerMessage.CellBroadcastIdentity;
import com.android.cellbroadcastservice.SmsCbHeader.DataCodingScheme;
import com.android.internal.R;
-import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.SmsConstants;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@@ -288,7 +287,8 @@
* @param pdu the PDU to decode
* @return a pair of string containing the language and body of the message in order
*/
- private static Pair<String, String> parseUmtsBody(SmsCbHeader header, byte[] pdu) {
+ private static Pair<String, String> parseUmtsBody(SmsCbHeader header,
+ byte[] pdu) {
// Payload may contain multiple pages
int nrPages = pdu[SmsCbHeader.PDU_HEADER_LENGTH];
String language = header.getDataCodingSchemeStructedData().language;
@@ -327,7 +327,8 @@
* @param pdu the PDU to decode
* @return a pair of string containing the language and body of the message in order
*/
- private static Pair<String, String> parseGsmBody(SmsCbHeader header, byte[] pdu) {
+ private static Pair<String, String> parseGsmBody(SmsCbHeader header,
+ byte[] pdu) {
// Payload is one single page
int offset = SmsCbHeader.PDU_HEADER_LENGTH;
int length = pdu.length - offset;
@@ -343,13 +344,13 @@
* @param dcs data coding scheme
* @return a Pair of Strings containing the language and body of the message
*/
- private static Pair<String, String> unpackBody(byte[] pdu, int offset, int length,
- DataCodingScheme dcs) {
+ private static Pair<String, String> unpackBody(byte[] pdu, int offset,
+ int length, DataCodingScheme dcs) {
String body = null;
String language = dcs.language;
switch (dcs.encoding) {
- case SmsConstants.ENCODING_7BIT:
+ case SmsMessage.ENCODING_7BIT:
body = GsmAlphabet.gsm7BitPackedToString(pdu, offset, length * 8 / 7);
if (dcs.hasLanguageIndicator && body != null && body.length() > 2) {
@@ -360,7 +361,7 @@
}
break;
- case SmsConstants.ENCODING_16BIT:
+ case SmsMessage.ENCODING_16BIT:
if (dcs.hasLanguageIndicator && pdu.length >= offset + 2) {
// Language is two GSM characters.
// The actual body text is offset by 2 bytes.
diff --git a/src/com/android/cellbroadcastservice/SmsCbHeader.java b/src/com/android/cellbroadcastservice/SmsCbHeader.java
index 2a859fa..8dd8807 100644
--- a/src/com/android/cellbroadcastservice/SmsCbHeader.java
+++ b/src/com/android/cellbroadcastservice/SmsCbHeader.java
@@ -18,8 +18,7 @@
import android.telephony.SmsCbCmasInfo;
import android.telephony.SmsCbEtwsInfo;
-
-import com.android.internal.telephony.SmsConstants;
+import android.telephony.SmsMessage;
import dalvik.annotation.compat.UnsupportedAppUsage;
@@ -522,42 +521,42 @@
// section 5.
switch ((dataCodingScheme & 0xf0) >> 4) {
case 0x00:
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
language = LANGUAGE_CODES_GROUP_0[dataCodingScheme & 0x0f];
break;
case 0x01:
hasLanguageIndicator = true;
if ((dataCodingScheme & 0x0f) == 0x01) {
- encoding = SmsConstants.ENCODING_16BIT;
+ encoding = SmsMessage.ENCODING_16BIT;
} else {
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
}
break;
case 0x02:
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
language = LANGUAGE_CODES_GROUP_2[dataCodingScheme & 0x0f];
break;
case 0x03:
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
break;
case 0x04:
case 0x05:
switch ((dataCodingScheme & 0x0c) >> 2) {
case 0x01:
- encoding = SmsConstants.ENCODING_8BIT;
+ encoding = SmsMessage.ENCODING_8BIT;
break;
case 0x02:
- encoding = SmsConstants.ENCODING_16BIT;
+ encoding = SmsMessage.ENCODING_16BIT;
break;
case 0x00:
default:
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
break;
}
break;
@@ -574,15 +573,15 @@
case 0x0f:
if (((dataCodingScheme & 0x04) >> 2) == 0x01) {
- encoding = SmsConstants.ENCODING_8BIT;
+ encoding = SmsMessage.ENCODING_8BIT;
} else {
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
}
break;
default:
// Reserved values are to be treated as 7-bit
- encoding = SmsConstants.ENCODING_7BIT;
+ encoding = SmsMessage.ENCODING_7BIT;
break;
}
diff --git a/src/com/android/cellbroadcastservice/SmsHeader.java b/src/com/android/cellbroadcastservice/SmsHeader.java
new file mode 100644
index 0000000..2449f98
--- /dev/null
+++ b/src/com/android/cellbroadcastservice/SmsHeader.java
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2006 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 com.android.cellbroadcastservice;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+
+/**
+ * SMS user data header, as specified in TS 23.040 9.2.3.24.
+ */
+public class SmsHeader {
+
+ // TODO(cleanup): this data structure is generally referred to as
+ // the 'user data header' or UDH, and so the class name should
+ // change to reflect this...
+
+ /**
+ * SMS user data header information element identifiers.
+ * (see TS 23.040 9.2.3.24)
+ */
+ public static final int ELT_ID_CONCATENATED_8_BIT_REFERENCE = 0x00;
+ public static final int ELT_ID_SPECIAL_SMS_MESSAGE_INDICATION = 0x01;
+ public static final int ELT_ID_APPLICATION_PORT_ADDRESSING_8_BIT = 0x04;
+ public static final int ELT_ID_APPLICATION_PORT_ADDRESSING_16_BIT = 0x05;
+ public static final int ELT_ID_SMSC_CONTROL_PARAMS = 0x06;
+ public static final int ELT_ID_UDH_SOURCE_INDICATION = 0x07;
+ public static final int ELT_ID_CONCATENATED_16_BIT_REFERENCE = 0x08;
+ public static final int ELT_ID_WIRELESS_CTRL_MSG_PROTOCOL = 0x09;
+ public static final int ELT_ID_TEXT_FORMATTING = 0x0A;
+ public static final int ELT_ID_PREDEFINED_SOUND = 0x0B;
+ public static final int ELT_ID_USER_DEFINED_SOUND = 0x0C;
+ public static final int ELT_ID_PREDEFINED_ANIMATION = 0x0D;
+ public static final int ELT_ID_LARGE_ANIMATION = 0x0E;
+ public static final int ELT_ID_SMALL_ANIMATION = 0x0F;
+ public static final int ELT_ID_LARGE_PICTURE = 0x10;
+ public static final int ELT_ID_SMALL_PICTURE = 0x11;
+ public static final int ELT_ID_VARIABLE_PICTURE = 0x12;
+ public static final int ELT_ID_USER_PROMPT_INDICATOR = 0x13;
+ public static final int ELT_ID_EXTENDED_OBJECT = 0x14;
+ public static final int ELT_ID_REUSED_EXTENDED_OBJECT = 0x15;
+ public static final int ELT_ID_COMPRESSION_CONTROL = 0x16;
+ public static final int ELT_ID_OBJECT_DISTR_INDICATOR = 0x17;
+ public static final int ELT_ID_STANDARD_WVG_OBJECT = 0x18;
+ public static final int ELT_ID_CHARACTER_SIZE_WVG_OBJECT = 0x19;
+ public static final int ELT_ID_EXTENDED_OBJECT_DATA_REQUEST_CMD = 0x1A;
+ public static final int ELT_ID_RFC_822_EMAIL_HEADER = 0x20;
+ public static final int ELT_ID_HYPERLINK_FORMAT_ELEMENT = 0x21;
+ public static final int ELT_ID_REPLY_ADDRESS_ELEMENT = 0x22;
+ public static final int ELT_ID_ENHANCED_VOICE_MAIL_INFORMATION = 0x23;
+ public static final int ELT_ID_NATIONAL_LANGUAGE_SINGLE_SHIFT = 0x24;
+ public static final int ELT_ID_NATIONAL_LANGUAGE_LOCKING_SHIFT = 0x25;
+
+ public static final int PORT_WAP_PUSH = 2948;
+ public static final int PORT_WAP_WSP = 9200;
+
+ /** The maximum number of payload bytes per message */
+ public static final int MAX_USER_DATA_BYTES = 140;
+
+ /**
+ * Port addresses used in creating and parsing SmsHeader.
+ */
+ public static class PortAddrs {
+ public PortAddrs() {
+ }
+
+ public int destPort;
+ public int origPort;
+ public boolean areEightBits;
+ }
+
+ /**
+ * Concatenated reference used in creating and parsing SmsHeader.
+ */
+ public static class ConcatRef {
+ public ConcatRef() {
+ }
+
+ public int refNumber;
+ public int seqNumber;
+ public int msgCount;
+ public boolean isEightBits;
+ }
+
+ /**
+ * Special SMS message indicator, used in creating and parsing SmsHeader.
+ */
+ public static class SpecialSmsMsg {
+ public int msgIndType;
+ public int msgCount;
+ }
+
+ /**
+ * A header element that is not explicitly parsed, meaning not
+ * PortAddrs or ConcatRef or SpecialSmsMsg.
+ */
+ public static class MiscElt {
+ public int id;
+ public byte[] data;
+ }
+
+ public PortAddrs portAddrs;
+ public ConcatRef concatRef;
+ public ArrayList<SpecialSmsMsg> specialSmsMsgList = new ArrayList<SpecialSmsMsg>();
+ public ArrayList<MiscElt> miscEltList = new ArrayList<MiscElt>();
+
+ /** 7 bit national language locking shift table, or 0 for GSM default 7 bit alphabet. */
+ public int languageTable;
+
+ /** 7 bit national language single shift table, or 0 for GSM default 7 bit extension table. */
+ public int languageShiftTable;
+
+ public SmsHeader() {
+ }
+
+ /**
+ * Create structured SmsHeader object from serialized byte array representation.
+ * (see TS 23.040 9.2.3.24)
+ *
+ * @param data is user data header bytes
+ * @return SmsHeader object
+ */
+ public static SmsHeader fromByteArray(byte[] data) {
+ ByteArrayInputStream inStream = new ByteArrayInputStream(data);
+ SmsHeader smsHeader = new SmsHeader();
+ while (inStream.available() > 0) {
+ /**
+ * NOTE: as defined in the spec, ConcatRef and PortAddr
+ * fields should not reoccur, but if they do the last
+ * occurrence is to be used. Also, for ConcatRef
+ * elements, if the count is zero, sequence is zero, or
+ * sequence is larger than count, the entire element is to
+ * be ignored.
+ */
+ int id = inStream.read();
+ int length = inStream.read();
+ ConcatRef concatRef;
+ PortAddrs portAddrs;
+ switch (id) {
+ case ELT_ID_CONCATENATED_8_BIT_REFERENCE:
+ concatRef = new ConcatRef();
+ concatRef.refNumber = inStream.read();
+ concatRef.msgCount = inStream.read();
+ concatRef.seqNumber = inStream.read();
+ concatRef.isEightBits = true;
+ if (concatRef.msgCount != 0 && concatRef.seqNumber != 0
+ && concatRef.seqNumber <= concatRef.msgCount) {
+ smsHeader.concatRef = concatRef;
+ }
+ break;
+ case ELT_ID_CONCATENATED_16_BIT_REFERENCE:
+ concatRef = new ConcatRef();
+ concatRef.refNumber = (inStream.read() << 8) | inStream.read();
+ concatRef.msgCount = inStream.read();
+ concatRef.seqNumber = inStream.read();
+ concatRef.isEightBits = false;
+ if (concatRef.msgCount != 0 && concatRef.seqNumber != 0
+ && concatRef.seqNumber <= concatRef.msgCount) {
+ smsHeader.concatRef = concatRef;
+ }
+ break;
+ case ELT_ID_APPLICATION_PORT_ADDRESSING_8_BIT:
+ portAddrs = new PortAddrs();
+ portAddrs.destPort = inStream.read();
+ portAddrs.origPort = inStream.read();
+ portAddrs.areEightBits = true;
+ smsHeader.portAddrs = portAddrs;
+ break;
+ case ELT_ID_APPLICATION_PORT_ADDRESSING_16_BIT:
+ portAddrs = new PortAddrs();
+ portAddrs.destPort = (inStream.read() << 8) | inStream.read();
+ portAddrs.origPort = (inStream.read() << 8) | inStream.read();
+ portAddrs.areEightBits = false;
+ smsHeader.portAddrs = portAddrs;
+ break;
+ case ELT_ID_NATIONAL_LANGUAGE_SINGLE_SHIFT:
+ smsHeader.languageShiftTable = inStream.read();
+ break;
+ case ELT_ID_NATIONAL_LANGUAGE_LOCKING_SHIFT:
+ smsHeader.languageTable = inStream.read();
+ break;
+ case ELT_ID_SPECIAL_SMS_MESSAGE_INDICATION:
+ SpecialSmsMsg specialSmsMsg = new SpecialSmsMsg();
+ specialSmsMsg.msgIndType = inStream.read();
+ specialSmsMsg.msgCount = inStream.read();
+ smsHeader.specialSmsMsgList.add(specialSmsMsg);
+ break;
+ default:
+ MiscElt miscElt = new MiscElt();
+ miscElt.id = id;
+ miscElt.data = new byte[length];
+ inStream.read(miscElt.data, 0, length);
+ smsHeader.miscEltList.add(miscElt);
+ }
+ }
+ return smsHeader;
+ }
+
+ /**
+ * Create serialized byte array representation from structured SmsHeader object.
+ * (see TS 23.040 9.2.3.24)
+ *
+ * @return Byte array representing the SmsHeader
+ */
+ public static byte[] toByteArray(SmsHeader smsHeader) {
+ if ((smsHeader.portAddrs == null) && (smsHeader.concatRef == null)
+ && (smsHeader.specialSmsMsgList.isEmpty()) && (smsHeader.miscEltList.isEmpty()) && (
+ smsHeader.languageShiftTable == 0) && (smsHeader.languageTable == 0)) {
+ return null;
+ }
+
+ ByteArrayOutputStream outStream =
+ new ByteArrayOutputStream(MAX_USER_DATA_BYTES);
+ ConcatRef concatRef = smsHeader.concatRef;
+ if (concatRef != null) {
+ if (concatRef.isEightBits) {
+ outStream.write(ELT_ID_CONCATENATED_8_BIT_REFERENCE);
+ outStream.write(3);
+ outStream.write(concatRef.refNumber);
+ } else {
+ outStream.write(ELT_ID_CONCATENATED_16_BIT_REFERENCE);
+ outStream.write(4);
+ outStream.write(concatRef.refNumber >>> 8);
+ outStream.write(concatRef.refNumber & 0x00FF);
+ }
+ outStream.write(concatRef.msgCount);
+ outStream.write(concatRef.seqNumber);
+ }
+ PortAddrs portAddrs = smsHeader.portAddrs;
+ if (portAddrs != null) {
+ if (portAddrs.areEightBits) {
+ outStream.write(ELT_ID_APPLICATION_PORT_ADDRESSING_8_BIT);
+ outStream.write(2);
+ outStream.write(portAddrs.destPort);
+ outStream.write(portAddrs.origPort);
+ } else {
+ outStream.write(ELT_ID_APPLICATION_PORT_ADDRESSING_16_BIT);
+ outStream.write(4);
+ outStream.write(portAddrs.destPort >>> 8);
+ outStream.write(portAddrs.destPort & 0x00FF);
+ outStream.write(portAddrs.origPort >>> 8);
+ outStream.write(portAddrs.origPort & 0x00FF);
+ }
+ }
+ if (smsHeader.languageShiftTable != 0) {
+ outStream.write(ELT_ID_NATIONAL_LANGUAGE_SINGLE_SHIFT);
+ outStream.write(1);
+ outStream.write(smsHeader.languageShiftTable);
+ }
+ if (smsHeader.languageTable != 0) {
+ outStream.write(ELT_ID_NATIONAL_LANGUAGE_LOCKING_SHIFT);
+ outStream.write(1);
+ outStream.write(smsHeader.languageTable);
+ }
+ for (SpecialSmsMsg specialSmsMsg : smsHeader.specialSmsMsgList) {
+ outStream.write(ELT_ID_SPECIAL_SMS_MESSAGE_INDICATION);
+ outStream.write(2);
+ outStream.write(specialSmsMsg.msgIndType & 0xFF);
+ outStream.write(specialSmsMsg.msgCount & 0xFF);
+ }
+ for (MiscElt miscElt : smsHeader.miscEltList) {
+ outStream.write(miscElt.id);
+ outStream.write(miscElt.data.length);
+ outStream.write(miscElt.data, 0, miscElt.data.length);
+ }
+ return outStream.toByteArray();
+ }
+}
diff --git a/src/com/android/cellbroadcastservice/UserData.java b/src/com/android/cellbroadcastservice/UserData.java
index 8758d8d..7cbf320 100644
--- a/src/com/android/cellbroadcastservice/UserData.java
+++ b/src/com/android/cellbroadcastservice/UserData.java
@@ -18,7 +18,6 @@
import android.util.SparseIntArray;
-import com.android.internal.telephony.SmsHeader;
import com.android.internal.util.HexDump;
import dalvik.annotation.compat.UnsupportedAppUsage;