Messaging: Remove duplicate code
* mmslib contains basically the same code as android.support.v7.mms.pdu does, so align them code-wise and remove the mmslib duplicates * Since mmslib contains a few usages that are now not accessible anymore, make the classes or methods public where it complains Change-Id: I10b8716c0e45079e4795fda4489dc1a9535026f3
This commit is contained in:
@@ -44,7 +44,7 @@ public class AcknowledgeInd extends GenericPdu {
|
||||
*
|
||||
* @param headers Headers for this PDU.
|
||||
*/
|
||||
AcknowledgeInd(PduHeaders headers) {
|
||||
public AcknowledgeInd(PduHeaders headers) {
|
||||
super(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package android.support.v7.mms.pdu;
|
||||
|
||||
import androidx.collection.SimpleArrayMap;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CharacterSets {
|
||||
/**
|
||||
@@ -28,6 +30,252 @@ public class CharacterSets {
|
||||
* From wap-230-wsp-20010705-a.pdf
|
||||
* Any-charset = <Octet 128>
|
||||
* Equivalent to the special RFC2616 charset value "*"
|
||||
*
|
||||
* Link to all the charsets: http://www.iana.org/assignments/character-sets/character-sets.xhtml
|
||||
* Use Charset.availableCharsets() to see if a potential charset is supported in java:
|
||||
* private void dumpCharsets() {
|
||||
* logvv("dumpCharsets");
|
||||
* SortedMap<String, Charset> charsets = Charset.availableCharsets();
|
||||
* for (Entry<String, Charset> entry : charsets.entrySet()) {
|
||||
* String key = entry.getKey();
|
||||
* Charset value = entry.getValue();
|
||||
* logvv("charset key: " + key + " value: " + value);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* As of March 21, 2014, here is the list from dumpCharsets:
|
||||
* Adobe-Standard-Encoding value: java.nio.charset.CharsetICU[Adobe-Standard-Encoding]
|
||||
* Big5 value: java.nio.charset.CharsetICU[Big5]
|
||||
* Big5-HKSCS value: java.nio.charset.CharsetICU[Big5-HKSCS]
|
||||
* BOCU-1 value: java.nio.charset.CharsetICU[BOCU-1]
|
||||
* CESU-8 value: java.nio.charset.CharsetICU[CESU-8]
|
||||
* cp1363 value: java.nio.charset.CharsetICU[cp1363]
|
||||
* cp851 value: java.nio.charset.CharsetICU[cp851]
|
||||
* cp864 value: java.nio.charset.CharsetICU[cp864]
|
||||
* EUC-JP value: java.nio.charset.CharsetICU[EUC-JP]
|
||||
* EUC-KR value: java.nio.charset.CharsetICU[EUC-KR]
|
||||
* GB18030 value: java.nio.charset.CharsetICU[GB18030]
|
||||
* GBK value: java.nio.charset.CharsetICU[GBK]
|
||||
* hp-roman8 value: java.nio.charset.CharsetICU[hp-roman8]
|
||||
* HZ-GB-2312 value: java.nio.charset.CharsetICU[HZ-GB-2312]
|
||||
* IBM-Thai value: java.nio.charset.CharsetICU[IBM-Thai]
|
||||
* IBM00858 value: java.nio.charset.CharsetICU[IBM00858]
|
||||
* IBM01140 value: java.nio.charset.CharsetICU[IBM01140]
|
||||
* IBM01141 value: java.nio.charset.CharsetICU[IBM01141]
|
||||
* IBM01142 value: java.nio.charset.CharsetICU[IBM01142]
|
||||
* IBM01143 value: java.nio.charset.CharsetICU[IBM01143]
|
||||
* IBM01144 value: java.nio.charset.CharsetICU[IBM01144]
|
||||
* IBM01145 value: java.nio.charset.CharsetICU[IBM01145]
|
||||
* IBM01146 value: java.nio.charset.CharsetICU[IBM01146]
|
||||
* IBM01147 value: java.nio.charset.CharsetICU[IBM01147]
|
||||
* IBM01148 value: java.nio.charset.CharsetICU[IBM01148]
|
||||
* IBM01149 value: java.nio.charset.CharsetICU[IBM01149]
|
||||
* IBM037 value: java.nio.charset.CharsetICU[IBM037]
|
||||
* IBM1026 value: java.nio.charset.CharsetICU[IBM1026]
|
||||
* IBM1047 value: java.nio.charset.CharsetICU[IBM1047]
|
||||
* IBM273 value: java.nio.charset.CharsetICU[IBM273]
|
||||
* IBM277 value: java.nio.charset.CharsetICU[IBM277]
|
||||
* IBM278 value: java.nio.charset.CharsetICU[IBM278]
|
||||
* IBM280 value: java.nio.charset.CharsetICU[IBM280]
|
||||
* IBM284 value: java.nio.charset.CharsetICU[IBM284]
|
||||
* IBM285 value: java.nio.charset.CharsetICU[IBM285]
|
||||
* IBM290 value: java.nio.charset.CharsetICU[IBM290]
|
||||
* IBM297 value: java.nio.charset.CharsetICU[IBM297]
|
||||
* IBM420 value: java.nio.charset.CharsetICU[IBM420]
|
||||
* IBM424 value: java.nio.charset.CharsetICU[IBM424]
|
||||
* IBM437 value: java.nio.charset.CharsetICU[IBM437]
|
||||
* IBM500 value: java.nio.charset.CharsetICU[IBM500]
|
||||
* IBM775 value: java.nio.charset.CharsetICU[IBM775]
|
||||
* IBM850 value: java.nio.charset.CharsetICU[IBM850]
|
||||
* IBM852 value: java.nio.charset.CharsetICU[IBM852]
|
||||
* IBM855 value: java.nio.charset.CharsetICU[IBM855]
|
||||
* IBM857 value: java.nio.charset.CharsetICU[IBM857]
|
||||
* IBM860 value: java.nio.charset.CharsetICU[IBM860]
|
||||
* IBM861 value: java.nio.charset.CharsetICU[IBM861]
|
||||
* IBM862 value: java.nio.charset.CharsetICU[IBM862]
|
||||
* IBM863 value: java.nio.charset.CharsetICU[IBM863]
|
||||
* IBM865 value: java.nio.charset.CharsetICU[IBM865]
|
||||
* IBM866 value: java.nio.charset.CharsetICU[IBM866]
|
||||
* IBM868 value: java.nio.charset.CharsetICU[IBM868]
|
||||
* IBM869 value: java.nio.charset.CharsetICU[IBM869]
|
||||
* IBM870 value: java.nio.charset.CharsetICU[IBM870]
|
||||
* IBM871 value: java.nio.charset.CharsetICU[IBM871]
|
||||
* IBM918 value: java.nio.charset.CharsetICU[IBM918]
|
||||
* ISO-2022-CN value: java.nio.charset.CharsetICU[ISO-2022-CN]
|
||||
* ISO-2022-CN-EXT value: java.nio.charset.CharsetICU[ISO-2022-CN-EXT]
|
||||
* ISO-2022-JP value: java.nio.charset.CharsetICU[ISO-2022-JP]
|
||||
* ISO-2022-JP-1 value: java.nio.charset.CharsetICU[ISO-2022-JP-1]
|
||||
* ISO-2022-JP-2 value: java.nio.charset.CharsetICU[ISO-2022-JP-2]
|
||||
* ISO-2022-KR value: java.nio.charset.CharsetICU[ISO-2022-KR]
|
||||
* ISO-8859-1 value: java.nio.charset.CharsetICU[ISO-8859-1]
|
||||
* ISO-8859-10 value: java.nio.charset.CharsetICU[ISO-8859-10]
|
||||
* ISO-8859-13 value: java.nio.charset.CharsetICU[ISO-8859-13]
|
||||
* ISO-8859-14 value: java.nio.charset.CharsetICU[ISO-8859-14]
|
||||
* ISO-8859-15 value: java.nio.charset.CharsetICU[ISO-8859-15]
|
||||
* ISO-8859-2 value: java.nio.charset.CharsetICU[ISO-8859-2]
|
||||
* ISO-8859-3 value: java.nio.charset.CharsetICU[ISO-8859-3]
|
||||
* ISO-8859-4 value: java.nio.charset.CharsetICU[ISO-8859-4]
|
||||
* ISO-8859-5 value: java.nio.charset.CharsetICU[ISO-8859-5]
|
||||
* ISO-8859-6 value: java.nio.charset.CharsetICU[ISO-8859-6]
|
||||
* ISO-8859-7 value: java.nio.charset.CharsetICU[ISO-8859-7]
|
||||
* ISO-8859-8 value: java.nio.charset.CharsetICU[ISO-8859-8]
|
||||
* ISO-8859-9 value: java.nio.charset.CharsetICU[ISO-8859-9]
|
||||
* KOI8-R value: java.nio.charset.CharsetICU[KOI8-R]
|
||||
* KOI8-U value: java.nio.charset.CharsetICU[KOI8-U]
|
||||
* macintosh value: java.nio.charset.CharsetICU[macintosh]
|
||||
* SCSU value: java.nio.charset.CharsetICU[SCSU]
|
||||
* Shift_JIS value: java.nio.charset.CharsetICU[Shift_JIS]
|
||||
* TIS-620 value: java.nio.charset.CharsetICU[TIS-620]
|
||||
* US-ASCII value: java.nio.charset.CharsetICU[US-ASCII]
|
||||
* UTF-16 value: java.nio.charset.CharsetICU[UTF-16]
|
||||
* UTF-16BE value: java.nio.charset.CharsetICU[UTF-16BE]
|
||||
* UTF-16LE value: java.nio.charset.CharsetICU[UTF-16LE]
|
||||
* UTF-32 value: java.nio.charset.CharsetICU[UTF-32]
|
||||
* UTF-32BE value: java.nio.charset.CharsetICU[UTF-32BE]
|
||||
* UTF-32LE value: java.nio.charset.CharsetICU[UTF-32LE]
|
||||
* UTF-7 value: java.nio.charset.CharsetICU[UTF-7]
|
||||
* UTF-8 value: java.nio.charset.CharsetICU[UTF-8]
|
||||
* windows-1250 value: java.nio.charset.CharsetICU[windows-1250]
|
||||
* windows-1251 value: java.nio.charset.CharsetICU[windows-1251]
|
||||
* windows-1252 value: java.nio.charset.CharsetICU[windows-1252]
|
||||
* windows-1253 value: java.nio.charset.CharsetICU[windows-1253]
|
||||
* windows-1254 value: java.nio.charset.CharsetICU[windows-1254]
|
||||
* windows-1255 value: java.nio.charset.CharsetICU[windows-1255]
|
||||
* windows-1256 value: java.nio.charset.CharsetICU[windows-1256]
|
||||
* windows-1257 value: java.nio.charset.CharsetICU[windows-1257]
|
||||
* windows-1258 value: java.nio.charset.CharsetICU[windows-1258]
|
||||
* x-compound-text value: java.nio.charset.CharsetICU[x-compound-text]
|
||||
* x-ebcdic-xml-us value: java.nio.charset.CharsetICU[x-ebcdic-xml-us]
|
||||
* x-gsm-03.38-2000 value: java.nio.charset.CharsetICU[x-gsm-03.38-2000]
|
||||
* x-ibm-1047-s390 value: java.nio.charset.CharsetICU[x-ibm-1047-s390]
|
||||
* x-ibm-1125_P100-1997 value: java.nio.charset.CharsetICU[x-ibm-1125_P100-1997]
|
||||
* x-ibm-1129_P100-1997 value: java.nio.charset.CharsetICU[x-ibm-1129_P100-1997]
|
||||
* x-ibm-1130_P100-1997 value: java.nio.charset.CharsetICU[x-ibm-1130_P100-1997]
|
||||
* x-ibm-1131_P100-1997 value: java.nio.charset.CharsetICU[x-ibm-1131_P100-1997]
|
||||
* x-ibm-1132_P100-1998 value: java.nio.charset.CharsetICU[x-ibm-1132_P100-1998]
|
||||
* x-ibm-1133_P100-1997 value: java.nio.charset.CharsetICU[x-ibm-1133_P100-1997]
|
||||
* x-ibm-1137_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1137_P100-1999]
|
||||
* x-ibm-1140-s390 value: java.nio.charset.CharsetICU[x-ibm-1140-s390]
|
||||
* x-ibm-1141-s390 value: java.nio.charset.CharsetICU[x-ibm-1141-s390]
|
||||
* x-ibm-1142-s390 value: java.nio.charset.CharsetICU[x-ibm-1142-s390]
|
||||
* x-ibm-1143-s390 value: java.nio.charset.CharsetICU[x-ibm-1143-s390]
|
||||
* x-ibm-1144-s390 value: java.nio.charset.CharsetICU[x-ibm-1144-s390]
|
||||
* x-ibm-1145-s390 value: java.nio.charset.CharsetICU[x-ibm-1145-s390]
|
||||
* x-ibm-1146-s390 value: java.nio.charset.CharsetICU[x-ibm-1146-s390]
|
||||
* x-ibm-1147-s390 value: java.nio.charset.CharsetICU[x-ibm-1147-s390]
|
||||
* x-ibm-1148-s390 value: java.nio.charset.CharsetICU[x-ibm-1148-s390]
|
||||
* x-ibm-1149-s390 value: java.nio.charset.CharsetICU[x-ibm-1149-s390]
|
||||
* x-ibm-1153-s390 value: java.nio.charset.CharsetICU[x-ibm-1153-s390]
|
||||
* x-ibm-1154_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1154_P100-1999]
|
||||
* x-ibm-1155_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1155_P100-1999]
|
||||
* x-ibm-1156_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1156_P100-1999]
|
||||
* x-ibm-1157_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1157_P100-1999]
|
||||
* x-ibm-1158_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1158_P100-1999]
|
||||
* x-ibm-1160_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1160_P100-1999]
|
||||
* x-ibm-1162_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1162_P100-1999]
|
||||
* x-ibm-1164_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-1164_P100-1999]
|
||||
* x-ibm-1250_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-1250_P100-1995]
|
||||
* x-ibm-1251_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-1251_P100-1995]
|
||||
* x-ibm-1252_P100-2000 value: java.nio.charset.CharsetICU[x-ibm-1252_P100-2000]
|
||||
* x-ibm-1253_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-1253_P100-1995]
|
||||
* x-ibm-1254_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-1254_P100-1995]
|
||||
* x-ibm-1255_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-1255_P100-1995]
|
||||
* x-ibm-1256_P110-1997 value: java.nio.charset.CharsetICU[x-ibm-1256_P110-1997]
|
||||
* x-ibm-1257_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-1257_P100-1995]
|
||||
* x-ibm-1258_P100-1997 value: java.nio.charset.CharsetICU[x-ibm-1258_P100-1997]
|
||||
* x-ibm-12712-s390 value: java.nio.charset.CharsetICU[x-ibm-12712-s390]
|
||||
* x-ibm-12712_P100-1998 value: java.nio.charset.CharsetICU[x-ibm-12712_P100-1998]
|
||||
* x-ibm-1373_P100-2002 value: java.nio.charset.CharsetICU[x-ibm-1373_P100-2002]
|
||||
* x-ibm-1383_P110-1999 value: java.nio.charset.CharsetICU[x-ibm-1383_P110-1999]
|
||||
* x-ibm-1386_P100-2001 value: java.nio.charset.CharsetICU[x-ibm-1386_P100-2001]
|
||||
* x-ibm-16684_P110-2003 value: java.nio.charset.CharsetICU[x-ibm-16684_P110-2003]
|
||||
* x-ibm-16804-s390 value: java.nio.charset.CharsetICU[x-ibm-16804-s390]
|
||||
* x-ibm-16804_X110-1999 value: java.nio.charset.CharsetICU[x-ibm-16804_X110-1999]
|
||||
* x-ibm-25546 value: java.nio.charset.CharsetICU[x-ibm-25546]
|
||||
* x-ibm-33722_P12A_P12A-2009_U2 value:
|
||||
* java.nio.charset.CharsetICU[x-ibm-33722_P12A_P12A-2009_U2]
|
||||
* x-ibm-37-s390 value: java.nio.charset.CharsetICU[x-ibm-37-s390]
|
||||
* x-ibm-4517_P100-2005 value: java.nio.charset.CharsetICU[x-ibm-4517_P100-2005]
|
||||
* x-ibm-4899_P100-1998 value: java.nio.charset.CharsetICU[x-ibm-4899_P100-1998]
|
||||
* x-ibm-4909_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-4909_P100-1999]
|
||||
* x-ibm-4971_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-4971_P100-1999]
|
||||
* x-ibm-5123_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-5123_P100-1999]
|
||||
* x-ibm-5351_P100-1998 value: java.nio.charset.CharsetICU[x-ibm-5351_P100-1998]
|
||||
* x-ibm-5352_P100-1998 value: java.nio.charset.CharsetICU[x-ibm-5352_P100-1998]
|
||||
* x-ibm-5353_P100-1998 value: java.nio.charset.CharsetICU[x-ibm-5353_P100-1998]
|
||||
* x-ibm-5478_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-5478_P100-1995]
|
||||
* x-ibm-803_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-803_P100-1999]
|
||||
* x-ibm-813_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-813_P100-1995]
|
||||
* x-ibm-8482_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-8482_P100-1999]
|
||||
* x-ibm-901_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-901_P100-1999]
|
||||
* x-ibm-902_P100-1999 value: java.nio.charset.CharsetICU[x-ibm-902_P100-1999]
|
||||
* x-ibm-9067_X100-2005 value: java.nio.charset.CharsetICU[x-ibm-9067_X100-2005]
|
||||
* x-ibm-916_P100-1995 value: java.nio.charset.CharsetICU[x-ibm-916_P100-1995]
|
||||
* x-IBM1006 value: java.nio.charset.CharsetICU[x-IBM1006]
|
||||
* x-IBM1025 value: java.nio.charset.CharsetICU[x-IBM1025]
|
||||
* x-IBM1097 value: java.nio.charset.CharsetICU[x-IBM1097]
|
||||
* x-IBM1098 value: java.nio.charset.CharsetICU[x-IBM1098]
|
||||
* x-IBM1112 value: java.nio.charset.CharsetICU[x-IBM1112]
|
||||
* x-IBM1122 value: java.nio.charset.CharsetICU[x-IBM1122]
|
||||
* x-IBM1123 value: java.nio.charset.CharsetICU[x-IBM1123]
|
||||
* x-IBM1124 value: java.nio.charset.CharsetICU[x-IBM1124]
|
||||
* x-IBM1153 value: java.nio.charset.CharsetICU[x-IBM1153]
|
||||
* x-IBM1363 value: java.nio.charset.CharsetICU[x-IBM1363]
|
||||
* x-IBM1364 value: java.nio.charset.CharsetICU[x-IBM1364]
|
||||
* x-IBM1371 value: java.nio.charset.CharsetICU[x-IBM1371]
|
||||
* x-IBM1388 value: java.nio.charset.CharsetICU[x-IBM1388]
|
||||
* x-IBM1390 value: java.nio.charset.CharsetICU[x-IBM1390]
|
||||
* x-IBM1399 value: java.nio.charset.CharsetICU[x-IBM1399]
|
||||
* x-IBM33722 value: java.nio.charset.CharsetICU[x-IBM33722]
|
||||
* x-IBM720 value: java.nio.charset.CharsetICU[x-IBM720]
|
||||
* x-IBM737 value: java.nio.charset.CharsetICU[x-IBM737]
|
||||
* x-IBM856 value: java.nio.charset.CharsetICU[x-IBM856]
|
||||
* x-IBM867 value: java.nio.charset.CharsetICU[x-IBM867]
|
||||
* x-IBM875 value: java.nio.charset.CharsetICU[x-IBM875]
|
||||
* x-IBM922 value: java.nio.charset.CharsetICU[x-IBM922]
|
||||
* x-IBM930 value: java.nio.charset.CharsetICU[x-IBM930]
|
||||
* x-IBM933 value: java.nio.charset.CharsetICU[x-IBM933]
|
||||
* x-IBM935 value: java.nio.charset.CharsetICU[x-IBM935]
|
||||
* x-IBM937 value: java.nio.charset.CharsetICU[x-IBM937]
|
||||
* x-IBM939 value: java.nio.charset.CharsetICU[x-IBM939]
|
||||
* x-IBM942 value: java.nio.charset.CharsetICU[x-IBM942]
|
||||
* x-IBM943 value: java.nio.charset.CharsetICU[x-IBM943]
|
||||
* x-IBM949 value: java.nio.charset.CharsetICU[x-IBM949]
|
||||
* x-IBM949C value: java.nio.charset.CharsetICU[x-IBM949C]
|
||||
* x-IBM950 value: java.nio.charset.CharsetICU[x-IBM950]
|
||||
* x-IBM954 value: java.nio.charset.CharsetICU[x-IBM954]
|
||||
* x-IBM964 value: java.nio.charset.CharsetICU[x-IBM964]
|
||||
* x-IBM970 value: java.nio.charset.CharsetICU[x-IBM970]
|
||||
* x-IBM971 value: java.nio.charset.CharsetICU[x-IBM971]
|
||||
* x-IMAP-mailbox-name value: java.nio.charset.CharsetICU[x-IMAP-mailbox-name]
|
||||
* x-iscii-be value: java.nio.charset.CharsetICU[x-iscii-be]
|
||||
* x-iscii-gu value: java.nio.charset.CharsetICU[x-iscii-gu]
|
||||
* x-iscii-ka value: java.nio.charset.CharsetICU[x-iscii-ka]
|
||||
* x-iscii-ma value: java.nio.charset.CharsetICU[x-iscii-ma]
|
||||
* x-iscii-or value: java.nio.charset.CharsetICU[x-iscii-or]
|
||||
* x-iscii-pa value: java.nio.charset.CharsetICU[x-iscii-pa]
|
||||
* x-iscii-ta value: java.nio.charset.CharsetICU[x-iscii-ta]
|
||||
* x-iscii-te value: java.nio.charset.CharsetICU[x-iscii-te]
|
||||
* x-ISCII91 value: java.nio.charset.CharsetICU[x-ISCII91]
|
||||
* x-ISO-2022-CN-CNS value: java.nio.charset.CharsetICU[x-ISO-2022-CN-CNS]
|
||||
* x-iso-8859-11 value: java.nio.charset.CharsetICU[x-iso-8859-11]
|
||||
* x-JavaUnicode value: java.nio.charset.CharsetICU[x-JavaUnicode]
|
||||
* x-JavaUnicode2 value: java.nio.charset.CharsetICU[x-JavaUnicode2]
|
||||
* x-JIS7 value: java.nio.charset.CharsetICU[x-JIS7]
|
||||
* x-JIS8 value: java.nio.charset.CharsetICU[x-JIS8]
|
||||
* x-LMBCS-1 value: java.nio.charset.CharsetICU[x-LMBCS-1]
|
||||
* x-mac-centraleurroman value: java.nio.charset.CharsetICU[x-mac-centraleurroman]
|
||||
* x-mac-cyrillic value: java.nio.charset.CharsetICU[x-mac-cyrillic]
|
||||
* x-mac-greek value: java.nio.charset.CharsetICU[x-mac-greek]
|
||||
* x-mac-turkish value: java.nio.charset.CharsetICU[x-mac-turkish]
|
||||
* x-MS950-HKSCS value: java.nio.charset.CharsetICU[x-MS950-HKSCS]
|
||||
* x-UnicodeBig value: java.nio.charset.CharsetICU[x-UnicodeBig]
|
||||
* x-UTF-16LE-BOM value: java.nio.charset.CharsetICU[x-UTF-16LE-BOM]
|
||||
* x-UTF16_OppositeEndian value: java.nio.charset.CharsetICU[x-UTF16_OppositeEndian]
|
||||
* x-UTF16_PlatformEndian value: java.nio.charset.CharsetICU[x-UTF16_PlatformEndian]
|
||||
* x-UTF32_OppositeEndian value: java.nio.charset.CharsetICU[x-UTF32_OppositeEndian]
|
||||
* x-UTF32_PlatformEndian value: java.nio.charset.CharsetICU[x-UTF32_PlatformEndian]
|
||||
*
|
||||
*/
|
||||
public static final int ANY_CHARSET = 0x00;
|
||||
public static final int US_ASCII = 0x03;
|
||||
@@ -41,10 +289,18 @@ public class CharacterSets {
|
||||
public static final int ISO_8859_8 = 0x0B;
|
||||
public static final int ISO_8859_9 = 0x0C;
|
||||
public static final int SHIFT_JIS = 0x11;
|
||||
public static final int EUC_JP = 0x12;
|
||||
public static final int EUC_KR = 0x26;
|
||||
public static final int ISO_2022_JP = 0x27;
|
||||
public static final int ISO_2022_JP_2 = 0x28;
|
||||
public static final int UTF_8 = 0x6A;
|
||||
public static final int GBK = 0x71;
|
||||
public static final int GB18030 = 0x72;
|
||||
public static final int GB2312 = 0x07E9;
|
||||
public static final int BIG5 = 0x07EA;
|
||||
public static final int UCS2 = 0x03E8;
|
||||
public static final int UTF_16 = 0x03F7;
|
||||
public static final int HZ_GB_2312 = 0x0825;
|
||||
|
||||
/**
|
||||
* If the encoding of given data is unsupported, use UTF_8 to decode it.
|
||||
@@ -55,22 +311,30 @@ public class CharacterSets {
|
||||
* Array of MIB enum numbers.
|
||||
*/
|
||||
private static final int[] MIBENUM_NUMBERS = {
|
||||
ANY_CHARSET,
|
||||
US_ASCII,
|
||||
ISO_8859_1,
|
||||
ISO_8859_2,
|
||||
ISO_8859_3,
|
||||
ISO_8859_4,
|
||||
ISO_8859_5,
|
||||
ISO_8859_6,
|
||||
ISO_8859_7,
|
||||
ISO_8859_8,
|
||||
ISO_8859_9,
|
||||
SHIFT_JIS,
|
||||
UTF_8,
|
||||
BIG5,
|
||||
UCS2,
|
||||
UTF_16,
|
||||
ANY_CHARSET,
|
||||
US_ASCII,
|
||||
ISO_8859_1,
|
||||
ISO_8859_2,
|
||||
ISO_8859_3,
|
||||
ISO_8859_4,
|
||||
ISO_8859_5,
|
||||
ISO_8859_6,
|
||||
ISO_8859_7,
|
||||
ISO_8859_8,
|
||||
ISO_8859_9,
|
||||
SHIFT_JIS,
|
||||
EUC_JP,
|
||||
EUC_KR,
|
||||
ISO_2022_JP,
|
||||
ISO_2022_JP_2,
|
||||
UTF_8,
|
||||
GBK,
|
||||
GB18030,
|
||||
GB2312,
|
||||
BIG5,
|
||||
UCS2,
|
||||
UTF_16,
|
||||
HZ_GB_2312,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,10 +352,18 @@ public class CharacterSets {
|
||||
public static final String MIMENAME_ISO_8859_8 = "iso-8859-8";
|
||||
public static final String MIMENAME_ISO_8859_9 = "iso-8859-9";
|
||||
public static final String MIMENAME_SHIFT_JIS = "shift_JIS";
|
||||
public static final String MIMENAME_EUC_JP = "euc-jp";
|
||||
public static final String MIMENAME_EUC_KR = "euc-kr";
|
||||
public static final String MIMENAME_ISO_2022_JP = "iso-2022-jp";
|
||||
public static final String MIMENAME_ISO_2022_JP_2 = "iso-2022-jp-2";
|
||||
public static final String MIMENAME_UTF_8 = "utf-8";
|
||||
public static final String MIMENAME_GBK = "gbk";
|
||||
public static final String MIMENAME_GB18030 = "gb18030";
|
||||
public static final String MIMENAME_GB2312 = "gb2312";
|
||||
public static final String MIMENAME_BIG5 = "big5";
|
||||
public static final String MIMENAME_UCS2 = "iso-10646-ucs-2";
|
||||
public static final String MIMENAME_UTF_16 = "utf-16";
|
||||
public static final String MIMENAME_HZ_GB_2312 = "hz-gb-2312";
|
||||
|
||||
public static final String DEFAULT_CHARSET_NAME = MIMENAME_UTF_8;
|
||||
|
||||
@@ -99,34 +371,43 @@ public class CharacterSets {
|
||||
* Array of the names of character sets.
|
||||
*/
|
||||
private static final String[] MIME_NAMES = {
|
||||
MIMENAME_ANY_CHARSET,
|
||||
MIMENAME_US_ASCII,
|
||||
MIMENAME_ISO_8859_1,
|
||||
MIMENAME_ISO_8859_2,
|
||||
MIMENAME_ISO_8859_3,
|
||||
MIMENAME_ISO_8859_4,
|
||||
MIMENAME_ISO_8859_5,
|
||||
MIMENAME_ISO_8859_6,
|
||||
MIMENAME_ISO_8859_7,
|
||||
MIMENAME_ISO_8859_8,
|
||||
MIMENAME_ISO_8859_9,
|
||||
MIMENAME_SHIFT_JIS,
|
||||
MIMENAME_UTF_8,
|
||||
MIMENAME_BIG5,
|
||||
MIMENAME_UCS2,
|
||||
MIMENAME_UTF_16,
|
||||
MIMENAME_ANY_CHARSET,
|
||||
MIMENAME_US_ASCII,
|
||||
MIMENAME_ISO_8859_1,
|
||||
MIMENAME_ISO_8859_2,
|
||||
MIMENAME_ISO_8859_3,
|
||||
MIMENAME_ISO_8859_4,
|
||||
MIMENAME_ISO_8859_5,
|
||||
MIMENAME_ISO_8859_6,
|
||||
MIMENAME_ISO_8859_7,
|
||||
MIMENAME_ISO_8859_8,
|
||||
MIMENAME_ISO_8859_9,
|
||||
MIMENAME_SHIFT_JIS,
|
||||
MIMENAME_EUC_JP,
|
||||
MIMENAME_EUC_KR,
|
||||
MIMENAME_ISO_2022_JP,
|
||||
MIMENAME_ISO_2022_JP_2,
|
||||
MIMENAME_UTF_8,
|
||||
MIMENAME_GBK,
|
||||
MIMENAME_GB18030,
|
||||
MIMENAME_GB2312,
|
||||
MIMENAME_BIG5,
|
||||
MIMENAME_UCS2,
|
||||
MIMENAME_UTF_16,
|
||||
MIMENAME_HZ_GB_2312,
|
||||
};
|
||||
|
||||
private static final HashMap<Integer, String> MIBENUM_TO_NAME_MAP;
|
||||
private static final HashMap<String, Integer> NAME_TO_MIBENUM_MAP;
|
||||
private static final SparseArray<String> MIBENUM_TO_NAME_MAP;
|
||||
|
||||
private static final SimpleArrayMap<String, Integer> NAME_TO_MIBENUM_MAP;
|
||||
|
||||
static {
|
||||
// Create the HashMaps.
|
||||
MIBENUM_TO_NAME_MAP = new HashMap<>();
|
||||
NAME_TO_MIBENUM_MAP = new HashMap<>();
|
||||
MIBENUM_TO_NAME_MAP = new SparseArray<>();
|
||||
NAME_TO_MIBENUM_MAP = new SimpleArrayMap<>();
|
||||
assert(MIBENUM_NUMBERS.length == MIME_NAMES.length);
|
||||
int count = MIBENUM_NUMBERS.length - 1;
|
||||
for(int i = 0; i <= count; i++) {
|
||||
final int count = MIBENUM_NUMBERS.length - 1;
|
||||
for (int i = 0; i <= count; i++) {
|
||||
MIBENUM_TO_NAME_MAP.put(MIBENUM_NUMBERS[i], MIME_NAMES[i]);
|
||||
NAME_TO_MIBENUM_MAP.put(MIME_NAMES[i], MIBENUM_NUMBERS[i]);
|
||||
}
|
||||
|
||||
@@ -18,16 +18,29 @@
|
||||
|
||||
package android.support.v7.mms.pdu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
public class ContentType {
|
||||
public final class ContentType {
|
||||
public static final String THREE_GPP_EXTENSION = "3gp";
|
||||
public static final String VIDEO_MP4_EXTENSION = "mp4";
|
||||
// Default extension used when we don't know one.
|
||||
public static final String DEFAULT_EXTENSION = "dat";
|
||||
|
||||
public static final int TYPE_IMAGE = 0;
|
||||
public static final int TYPE_VIDEO = 1;
|
||||
public static final int TYPE_AUDIO = 2;
|
||||
public static final int TYPE_VCARD = 3;
|
||||
public static final int TYPE_OTHER = 4;
|
||||
|
||||
public static final String ANY_TYPE = "*/*";
|
||||
public static final String MMS_MESSAGE = "application/vnd.wap.mms-message";
|
||||
// The phony content type for generic PDUs (e.g. ReadOrig.ind,
|
||||
// Notification.ind, Delivery.ind).
|
||||
public static final String MMS_GENERIC = "application/vnd.wap.mms-generic";
|
||||
public static final String MULTIPART_MIXED = "application/vnd.wap.multipart.mixed";
|
||||
public static final String MULTIPART_RELATED = "application/vnd.wap.multipart.related";
|
||||
public static final String MULTIPART_ALTERNATIVE = "application/vnd.wap.multipart.alternative";
|
||||
public static final String MMS_MULTIPART_MIXED = "application/vnd.wap.multipart.mixed";
|
||||
public static final String MMS_MULTIPART_RELATED = "application/vnd.wap.multipart.related";
|
||||
public static final String MMS_MULTIPART_ALTERNATIVE =
|
||||
"application/vnd.wap.multipart.alternative";
|
||||
|
||||
public static final String TEXT_PLAIN = "text/plain";
|
||||
public static final String TEXT_HTML = "text/html";
|
||||
@@ -36,6 +49,7 @@ public class ContentType {
|
||||
public static final String TEXT_X_VCALENDAR = "text/x-vCalendar";
|
||||
public static final String TEXT_X_VCARD = "text/x-vCard";
|
||||
|
||||
public static final String IMAGE_PREFIX = "image/";
|
||||
public static final String IMAGE_UNSPECIFIED = "image/*";
|
||||
public static final String IMAGE_JPEG = "image/jpeg";
|
||||
public static final String IMAGE_JPG = "image/jpg";
|
||||
@@ -44,192 +58,114 @@ public class ContentType {
|
||||
public static final String IMAGE_PNG = "image/png";
|
||||
public static final String IMAGE_X_MS_BMP = "image/x-ms-bmp";
|
||||
|
||||
public static final String AUDIO_UNSPECIFIED = "audio/*";
|
||||
public static final String AUDIO_AAC = "audio/aac";
|
||||
public static final String AUDIO_AMR = "audio/amr";
|
||||
public static final String AUDIO_IMELODY = "audio/imelody";
|
||||
public static final String AUDIO_MID = "audio/mid";
|
||||
public static final String AUDIO_MIDI = "audio/midi";
|
||||
public static final String AUDIO_MP3 = "audio/mp3";
|
||||
public static final String AUDIO_MPEG3 = "audio/mpeg3";
|
||||
public static final String AUDIO_MPEG = "audio/mpeg";
|
||||
public static final String AUDIO_MPG = "audio/mpg";
|
||||
public static final String AUDIO_MP4 = "audio/mp4";
|
||||
public static final String AUDIO_X_MID = "audio/x-mid";
|
||||
public static final String AUDIO_X_MIDI = "audio/x-midi";
|
||||
public static final String AUDIO_X_MP3 = "audio/x-mp3";
|
||||
public static final String AUDIO_X_MPEG3 = "audio/x-mpeg3";
|
||||
public static final String AUDIO_X_MPEG = "audio/x-mpeg";
|
||||
public static final String AUDIO_X_MPG = "audio/x-mpg";
|
||||
public static final String AUDIO_3GPP = "audio/3gpp";
|
||||
public static final String AUDIO_X_WAV = "audio/x-wav";
|
||||
public static final String AUDIO_OGG = "application/ogg";
|
||||
|
||||
public static final String VIDEO_UNSPECIFIED = "video/*";
|
||||
public static final String VIDEO_3GP = "video/3gp";
|
||||
public static final String VIDEO_3GPP = "video/3gpp";
|
||||
public static final String VIDEO_3G2 = "video/3gpp2";
|
||||
public static final String VIDEO_H263 = "video/h263";
|
||||
public static final String VIDEO_M4V = "video/m4v";
|
||||
public static final String VIDEO_MP4 = "video/mp4";
|
||||
public static final String VIDEO_MPEG = "video/mpeg";
|
||||
public static final String VIDEO_MPEG4 = "video/mpeg4";
|
||||
public static final String VIDEO_WEBM = "video/webm";
|
||||
|
||||
public static final String APP_SMIL = "application/smil";
|
||||
public static final String APP_WAP_XHTML = "application/vnd.wap.xhtml+xml";
|
||||
public static final String APP_XHTML = "application/xhtml+xml";
|
||||
|
||||
public static final String APP_DRM_CONTENT = "application/vnd.oma.drm.content";
|
||||
public static final String APP_DRM_MESSAGE = "application/vnd.oma.drm.message";
|
||||
|
||||
private static final ArrayList<String> sSupportedContentTypes = new ArrayList<>();
|
||||
private static final ArrayList<String> sSupportedImageTypes = new ArrayList<>();
|
||||
private static final ArrayList<String> sSupportedAudioTypes = new ArrayList<>();
|
||||
private static final ArrayList<String> sSupportedVideoTypes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
sSupportedContentTypes.add(TEXT_PLAIN);
|
||||
sSupportedContentTypes.add(TEXT_HTML);
|
||||
sSupportedContentTypes.add(TEXT_VCALENDAR);
|
||||
sSupportedContentTypes.add(TEXT_VCARD);
|
||||
sSupportedContentTypes.add(TEXT_X_VCALENDAR);
|
||||
sSupportedContentTypes.add(TEXT_X_VCARD);
|
||||
|
||||
sSupportedContentTypes.add(IMAGE_JPEG);
|
||||
sSupportedContentTypes.add(IMAGE_GIF);
|
||||
sSupportedContentTypes.add(IMAGE_WBMP);
|
||||
sSupportedContentTypes.add(IMAGE_PNG);
|
||||
sSupportedContentTypes.add(IMAGE_JPG);
|
||||
sSupportedContentTypes.add(IMAGE_X_MS_BMP);
|
||||
//supportedContentTypes.add(IMAGE_SVG); not yet supported.
|
||||
|
||||
sSupportedContentTypes.add(AUDIO_AAC);
|
||||
sSupportedContentTypes.add(AUDIO_AMR);
|
||||
sSupportedContentTypes.add(AUDIO_IMELODY);
|
||||
sSupportedContentTypes.add(AUDIO_MID);
|
||||
sSupportedContentTypes.add(AUDIO_MIDI);
|
||||
sSupportedContentTypes.add(AUDIO_MP3);
|
||||
sSupportedContentTypes.add(AUDIO_MP4);
|
||||
sSupportedContentTypes.add(AUDIO_MPEG3);
|
||||
sSupportedContentTypes.add(AUDIO_MPEG);
|
||||
sSupportedContentTypes.add(AUDIO_MPG);
|
||||
sSupportedContentTypes.add(AUDIO_X_MID);
|
||||
sSupportedContentTypes.add(AUDIO_X_MIDI);
|
||||
sSupportedContentTypes.add(AUDIO_X_MP3);
|
||||
sSupportedContentTypes.add(AUDIO_X_MPEG3);
|
||||
sSupportedContentTypes.add(AUDIO_X_MPEG);
|
||||
sSupportedContentTypes.add(AUDIO_X_MPG);
|
||||
sSupportedContentTypes.add(AUDIO_X_WAV);
|
||||
sSupportedContentTypes.add(AUDIO_3GPP);
|
||||
sSupportedContentTypes.add(AUDIO_OGG);
|
||||
|
||||
sSupportedContentTypes.add(VIDEO_3GPP);
|
||||
sSupportedContentTypes.add(VIDEO_3G2);
|
||||
sSupportedContentTypes.add(VIDEO_H263);
|
||||
sSupportedContentTypes.add(VIDEO_MP4);
|
||||
|
||||
sSupportedContentTypes.add(APP_SMIL);
|
||||
sSupportedContentTypes.add(APP_WAP_XHTML);
|
||||
sSupportedContentTypes.add(APP_XHTML);
|
||||
|
||||
sSupportedContentTypes.add(APP_DRM_CONTENT);
|
||||
sSupportedContentTypes.add(APP_DRM_MESSAGE);
|
||||
|
||||
// add supported image types
|
||||
sSupportedImageTypes.add(IMAGE_JPEG);
|
||||
sSupportedImageTypes.add(IMAGE_GIF);
|
||||
sSupportedImageTypes.add(IMAGE_WBMP);
|
||||
sSupportedImageTypes.add(IMAGE_PNG);
|
||||
sSupportedImageTypes.add(IMAGE_JPG);
|
||||
sSupportedImageTypes.add(IMAGE_X_MS_BMP);
|
||||
|
||||
// add supported audio types
|
||||
sSupportedAudioTypes.add(AUDIO_AAC);
|
||||
sSupportedAudioTypes.add(AUDIO_AMR);
|
||||
sSupportedAudioTypes.add(AUDIO_IMELODY);
|
||||
sSupportedAudioTypes.add(AUDIO_MID);
|
||||
sSupportedAudioTypes.add(AUDIO_MIDI);
|
||||
sSupportedAudioTypes.add(AUDIO_MP3);
|
||||
sSupportedAudioTypes.add(AUDIO_MPEG3);
|
||||
sSupportedAudioTypes.add(AUDIO_MPEG);
|
||||
sSupportedAudioTypes.add(AUDIO_MPG);
|
||||
sSupportedAudioTypes.add(AUDIO_MP4);
|
||||
sSupportedAudioTypes.add(AUDIO_X_MID);
|
||||
sSupportedAudioTypes.add(AUDIO_X_MIDI);
|
||||
sSupportedAudioTypes.add(AUDIO_X_MP3);
|
||||
sSupportedAudioTypes.add(AUDIO_X_MPEG3);
|
||||
sSupportedAudioTypes.add(AUDIO_X_MPEG);
|
||||
sSupportedAudioTypes.add(AUDIO_X_MPG);
|
||||
sSupportedAudioTypes.add(AUDIO_X_WAV);
|
||||
sSupportedAudioTypes.add(AUDIO_3GPP);
|
||||
sSupportedAudioTypes.add(AUDIO_OGG);
|
||||
|
||||
// add supported video types
|
||||
sSupportedVideoTypes.add(VIDEO_3GPP);
|
||||
sSupportedVideoTypes.add(VIDEO_3G2);
|
||||
sSupportedVideoTypes.add(VIDEO_H263);
|
||||
sSupportedVideoTypes.add(VIDEO_MP4);
|
||||
}
|
||||
|
||||
// This class should never be instantiated.
|
||||
private ContentType() {
|
||||
}
|
||||
|
||||
public static boolean isSupportedType(String contentType) {
|
||||
return (null != contentType) && sSupportedContentTypes.contains(contentType);
|
||||
public static boolean isTextType(final String contentType) {
|
||||
return TEXT_PLAIN.equals(contentType)
|
||||
|| TEXT_HTML.equals(contentType)
|
||||
|| APP_WAP_XHTML.equals(contentType);
|
||||
}
|
||||
|
||||
public static boolean isSupportedImageType(String contentType) {
|
||||
return isImageType(contentType) && isSupportedType(contentType);
|
||||
public static boolean isMediaType(final String contentType) {
|
||||
return isImageType(contentType)
|
||||
|| isVideoType(contentType)
|
||||
|| isAudioType(contentType)
|
||||
|| isVCardType(contentType);
|
||||
}
|
||||
|
||||
public static boolean isSupportedAudioType(String contentType) {
|
||||
return isAudioType(contentType) && isSupportedType(contentType);
|
||||
public static boolean isImageType(final String contentType) {
|
||||
return (null != contentType) && contentType.startsWith(IMAGE_PREFIX);
|
||||
}
|
||||
|
||||
public static boolean isSupportedVideoType(String contentType) {
|
||||
return isVideoType(contentType) && isSupportedType(contentType);
|
||||
public static boolean isAudioType(final String contentType) {
|
||||
return (null != contentType) &&
|
||||
(contentType.startsWith("audio/") || contentType.equalsIgnoreCase(AUDIO_OGG));
|
||||
}
|
||||
|
||||
public static boolean isTextType(String contentType) {
|
||||
return (null != contentType) && contentType.startsWith("text/");
|
||||
}
|
||||
|
||||
public static boolean isImageType(String contentType) {
|
||||
return (null != contentType) && contentType.startsWith("image/");
|
||||
}
|
||||
|
||||
public static boolean isAudioType(String contentType) {
|
||||
return (null != contentType) && contentType.startsWith("audio/");
|
||||
}
|
||||
|
||||
public static boolean isVideoType(String contentType) {
|
||||
public static boolean isVideoType(final String contentType) {
|
||||
return (null != contentType) && contentType.startsWith("video/");
|
||||
}
|
||||
|
||||
public static boolean isDrmType(String contentType) {
|
||||
public static boolean isVCardType(final String contentType) {
|
||||
return (null != contentType)
|
||||
&& (contentType.equals(APP_DRM_CONTENT)
|
||||
|| contentType.equals(APP_DRM_MESSAGE));
|
||||
&& (contentType.equalsIgnoreCase(TEXT_X_VCARD)
|
||||
|| contentType.equalsIgnoreCase(TEXT_VCARD));
|
||||
}
|
||||
|
||||
public static boolean isUnspecified(String contentType) {
|
||||
return (null != contentType) && contentType.endsWith("*");
|
||||
/**
|
||||
* If the content type is a type which can be displayed in the conversation list as a preview.
|
||||
*/
|
||||
public static boolean isConversationListPreviewableType(final String contentType) {
|
||||
return ContentType.isAudioType(contentType) || ContentType.isVideoType(contentType) ||
|
||||
ContentType.isImageType(contentType) || ContentType.isVCardType(contentType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<String> getImageTypes() {
|
||||
return (ArrayList<String>) sSupportedImageTypes.clone();
|
||||
/**
|
||||
* Given a filename, look at the extension and try and determine the mime type.
|
||||
*
|
||||
* @param fileName a filename to determine the type from, such as img1231.jpg
|
||||
* @param contentTypeDefault type to use when the content type can't be determined from the file
|
||||
* extension. It can be null or a type such as ContentType.IMAGE_UNSPECIFIED
|
||||
* @return Content type of the extension.
|
||||
*/
|
||||
public static String getContentTypeFromExtension(final String fileName,
|
||||
final String contentTypeDefault) {
|
||||
final MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
|
||||
final String extension = MimeTypeMap.getFileExtensionFromUrl(fileName);
|
||||
String contentType = mimeTypeMap.getMimeTypeFromExtension(extension);
|
||||
if (contentType == null) {
|
||||
contentType = contentTypeDefault;
|
||||
}
|
||||
return contentType;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<String> getAudioTypes() {
|
||||
return (ArrayList<String>) sSupportedAudioTypes.clone();
|
||||
public static String getExtensionFromMimeType(final String mimeType) {
|
||||
final MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
|
||||
final String extension = mimeTypeMap.getExtensionFromMimeType(mimeType);
|
||||
return extension;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<String> getVideoTypes() {
|
||||
return (ArrayList<String>) sSupportedVideoTypes.clone();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<String> getSupportedTypes() {
|
||||
return (ArrayList<String>) sSupportedContentTypes.clone();
|
||||
/**
|
||||
* Get the common file extension for a given content type
|
||||
* @param contentType The content type
|
||||
* @return The extension without the .
|
||||
*/
|
||||
public static String getExtension(final String contentType) {
|
||||
if (VIDEO_MP4.equals(contentType)) {
|
||||
return VIDEO_MP4_EXTENSION;
|
||||
} else if (VIDEO_3GPP.equals(contentType)) {
|
||||
return THREE_GPP_EXTENSION;
|
||||
} else {
|
||||
return DEFAULT_EXTENSION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DeliveryInd extends GenericPdu {
|
||||
*
|
||||
* @param headers Headers for this PDU.
|
||||
*/
|
||||
DeliveryInd(PduHeaders headers) {
|
||||
public DeliveryInd(PduHeaders headers) {
|
||||
super(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,11 +74,25 @@ public class EncodedStringValue implements Cloneable {
|
||||
}
|
||||
|
||||
public EncodedStringValue(String data) {
|
||||
this(CharacterSets.DEFAULT_CHARSET, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param data The text in Java String
|
||||
* @throws NullPointerException if Text-string value is null.
|
||||
*/
|
||||
public EncodedStringValue(int charset, String data) {
|
||||
if (null == data) {
|
||||
throw new NullPointerException("EncodedStringValue: Text-string is null");
|
||||
}
|
||||
mCharacterSet = charset;
|
||||
try {
|
||||
mData = data.getBytes(CharacterSets.DEFAULT_CHARSET_NAME);
|
||||
mCharacterSet = CharacterSets.DEFAULT_CHARSET;
|
||||
mData = data.getBytes(CharacterSets.getMimeName(charset));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(TAG, "Default encoding must be supported.", e);
|
||||
Log.e(TAG, "Input encoding " + charset + " must be supported.", e);
|
||||
mData = data.getBytes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GenericPdu {
|
||||
*
|
||||
* @return A PduHeaders of this PDU.
|
||||
*/
|
||||
PduHeaders getPduHeaders() {
|
||||
public PduHeaders getPduHeaders() {
|
||||
return mPduHeaders;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class GenericPdu {
|
||||
* @return the value
|
||||
*/
|
||||
public EncodedStringValue getFrom() {
|
||||
return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
|
||||
return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,4 +146,13 @@ public class MultimediaMessagePdu extends GenericPdu{
|
||||
public void setDate(long value) {
|
||||
mPduHeaders.setLongInteger(value, PduHeaders.DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message size
|
||||
*
|
||||
* @return the size of the message
|
||||
*/
|
||||
public long getMessageSize() {
|
||||
return mPduHeaders.getLongInteger(PduHeaders.MESSAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class NotificationInd extends GenericPdu {
|
||||
*
|
||||
* @param headers Headers for this PDU.
|
||||
*/
|
||||
NotificationInd(PduHeaders headers) {
|
||||
public NotificationInd(PduHeaders headers) {
|
||||
super(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NotifyRespInd extends GenericPdu {
|
||||
*
|
||||
* @param headers Headers for this PDU.
|
||||
*/
|
||||
NotifyRespInd(PduHeaders headers) {
|
||||
public NotifyRespInd(PduHeaders headers) {
|
||||
super(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,57 +18,16 @@
|
||||
|
||||
package android.support.v7.mms.pdu;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
public class PduBody {
|
||||
private Vector<PduPart> mParts = null;
|
||||
|
||||
private Map<String, PduPart> mPartMapByContentId = null;
|
||||
private Map<String, PduPart> mPartMapByContentLocation = null;
|
||||
private Map<String, PduPart> mPartMapByName = null;
|
||||
private Map<String, PduPart> mPartMapByFileName = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public PduBody() {
|
||||
mParts = new Vector<>();
|
||||
|
||||
mPartMapByContentId = new HashMap<>();
|
||||
mPartMapByContentLocation = new HashMap<>();
|
||||
mPartMapByName = new HashMap<>();
|
||||
mPartMapByFileName = new HashMap<>();
|
||||
}
|
||||
|
||||
private void putPartToMaps(PduPart part) {
|
||||
// Put part to mPartMapByContentId.
|
||||
byte[] contentId = part.getContentId();
|
||||
if(null != contentId) {
|
||||
mPartMapByContentId.put(new String(contentId), part);
|
||||
}
|
||||
|
||||
// Put part to mPartMapByContentLocation.
|
||||
byte[] contentLocation = part.getContentLocation();
|
||||
if(null != contentLocation) {
|
||||
String clc = new String(contentLocation);
|
||||
mPartMapByContentLocation.put(clc, part);
|
||||
}
|
||||
|
||||
// Put part to mPartMapByName.
|
||||
byte[] name = part.getName();
|
||||
if(null != name) {
|
||||
String clc = new String(name);
|
||||
mPartMapByName.put(clc, part);
|
||||
}
|
||||
|
||||
// Put part to mPartMapByFileName.
|
||||
byte[] fileName = part.getFilename();
|
||||
if(null != fileName) {
|
||||
String clc = new String(fileName);
|
||||
mPartMapByFileName.put(clc, part);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +42,6 @@ public class PduBody {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
putPartToMaps(part);
|
||||
return mParts.add(part);
|
||||
}
|
||||
|
||||
@@ -99,20 +57,9 @@ public class PduBody {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
putPartToMaps(part);
|
||||
mParts.add(index, part);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the part at the specified position.
|
||||
*
|
||||
* @param index index of the part to return
|
||||
* @return part at the specified index
|
||||
*/
|
||||
public PduPart removePart(int index) {
|
||||
return mParts.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all of the parts.
|
||||
*/
|
||||
@@ -130,16 +77,6 @@ public class PduBody {
|
||||
return mParts.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of the specified part.
|
||||
*
|
||||
* @param part the part object
|
||||
* @return index the index of the first occurrence of the part in this body
|
||||
*/
|
||||
public int getPartIndex(PduPart part) {
|
||||
return mParts.indexOf(part);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of parts.
|
||||
*
|
||||
@@ -148,45 +85,4 @@ public class PduBody {
|
||||
public int getPartsNum() {
|
||||
return mParts.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pdu part by content id.
|
||||
*
|
||||
* @param cid the value of content id.
|
||||
* @return the pdu part.
|
||||
*/
|
||||
public PduPart getPartByContentId(String cid) {
|
||||
return mPartMapByContentId.get(cid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pdu part by Content-Location. Content-Location of part is
|
||||
* the same as filename and name(param of content-type).
|
||||
*
|
||||
* @param contentLocation the content location.
|
||||
* @return the pdu part.
|
||||
*/
|
||||
public PduPart getPartByContentLocation(String contentLocation) {
|
||||
return mPartMapByContentLocation.get(contentLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pdu part by name.
|
||||
*
|
||||
* @param name the value of filename.
|
||||
* @return the pdu part.
|
||||
*/
|
||||
public PduPart getPartByName(String name) {
|
||||
return mPartMapByName.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pdu part by filename.
|
||||
*
|
||||
* @param filename the value of filename.
|
||||
* @return the pdu part.
|
||||
*/
|
||||
public PduPart getPartByFileName(String filename) {
|
||||
return mPartMapByFileName.get(filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PduContentTypes {
|
||||
* All content types. From:
|
||||
* http://www.openmobilealliance.org/tech/omna/omna-wsp-content-type.htm
|
||||
*/
|
||||
static final String[] contentTypes = {
|
||||
public static final String[] contentTypes = {
|
||||
"*/*", /* 0x00 */
|
||||
"text/*", /* 0x01 */
|
||||
"text/html", /* 0x02 */
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package android.support.v7.mms.pdu;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
|
||||
public class PduHeaders {
|
||||
/**
|
||||
@@ -321,13 +323,13 @@ public class PduHeaders {
|
||||
/**
|
||||
* The map contains the value of all headers.
|
||||
*/
|
||||
private HashMap<Integer, Object> mHeaderMap = null;
|
||||
private SparseArray<Object> mHeaderMap = null;
|
||||
|
||||
/**
|
||||
* Constructor of PduHeaders.
|
||||
*/
|
||||
public PduHeaders() {
|
||||
mHeaderMap = new HashMap<>();
|
||||
mHeaderMap = new SparseArray<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,10 +337,10 @@ public class PduHeaders {
|
||||
*
|
||||
* @param field the field
|
||||
* @return the octet value of the pdu header
|
||||
* with specified header field. Return 0 if
|
||||
* the value is not set.
|
||||
* with specified header field. Return 0 if
|
||||
* the value is not set.
|
||||
*/
|
||||
protected int getOctet(int field) {
|
||||
public int getOctet(int field) {
|
||||
Integer octet = (Integer) mHeaderMap.get(field);
|
||||
if (null == octet) {
|
||||
return 0;
|
||||
@@ -354,8 +356,8 @@ public class PduHeaders {
|
||||
* @param field the field
|
||||
* @throws InvalidHeaderValueException if the value is invalid.
|
||||
*/
|
||||
protected void setOctet(int value, int field)
|
||||
throws InvalidHeaderValueException{
|
||||
public void setOctet(int value, int field)
|
||||
throws InvalidHeaderValueException {
|
||||
/**
|
||||
* Check whether this field can be set for specific
|
||||
* header and check validity of the field.
|
||||
@@ -498,7 +500,7 @@ public class PduHeaders {
|
||||
* @return the TextString value of the pdu header
|
||||
* with specified header field
|
||||
*/
|
||||
protected byte[] getTextString(int field) {
|
||||
public byte[] getTextString(int field) {
|
||||
return (byte[]) mHeaderMap.get(field);
|
||||
}
|
||||
|
||||
@@ -509,7 +511,7 @@ public class PduHeaders {
|
||||
* @param field the field
|
||||
* @throws NullPointerException if the value is null.
|
||||
*/
|
||||
protected void setTextString(byte[] value, int field) {
|
||||
public void setTextString(byte[] value, int field) {
|
||||
/**
|
||||
* Check whether this field can be set for specific
|
||||
* header and check validity of the field.
|
||||
@@ -545,7 +547,7 @@ public class PduHeaders {
|
||||
* @return the EncodedStringValue value of the pdu header
|
||||
* with specified header field
|
||||
*/
|
||||
protected EncodedStringValue getEncodedStringValue(int field) {
|
||||
public EncodedStringValue getEncodedStringValue(int field) {
|
||||
return (EncodedStringValue) mHeaderMap.get(field);
|
||||
}
|
||||
|
||||
@@ -556,7 +558,7 @@ public class PduHeaders {
|
||||
* @return the EncodeStringValue array of the pdu header
|
||||
* with specified header field
|
||||
*/
|
||||
protected EncodedStringValue[] getEncodedStringValues(int field) {
|
||||
public EncodedStringValue[] getEncodedStringValues(int field) {
|
||||
ArrayList<EncodedStringValue> list =
|
||||
(ArrayList<EncodedStringValue>) mHeaderMap.get(field);
|
||||
if (null == list) {
|
||||
@@ -573,7 +575,7 @@ public class PduHeaders {
|
||||
* @param field the field
|
||||
* @throws NullPointerException if the value is null.
|
||||
*/
|
||||
protected void setEncodedStringValue(EncodedStringValue value, int field) {
|
||||
public void setEncodedStringValue(EncodedStringValue value, int field) {
|
||||
/**
|
||||
* Check whether this field can be set for specific
|
||||
* header and check validity of the field.
|
||||
@@ -628,9 +630,7 @@ public class PduHeaders {
|
||||
}
|
||||
|
||||
ArrayList<EncodedStringValue> list = new ArrayList<>();
|
||||
for (EncodedStringValue encodedStringValue : value) {
|
||||
list.add(encodedStringValue);
|
||||
}
|
||||
Collections.addAll(list, value);
|
||||
mHeaderMap.put(field, list);
|
||||
}
|
||||
|
||||
@@ -641,8 +641,7 @@ public class PduHeaders {
|
||||
* @param field the field
|
||||
* @throws NullPointerException if the value is null.
|
||||
*/
|
||||
protected void appendEncodedStringValue(EncodedStringValue value,
|
||||
int field) {
|
||||
public void appendEncodedStringValue(EncodedStringValue value, int field) {
|
||||
if (null == value) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
@@ -673,7 +672,7 @@ public class PduHeaders {
|
||||
* with specified header field. if return -1, the
|
||||
* field is not existed in pdu header.
|
||||
*/
|
||||
protected long getLongInteger(int field) {
|
||||
public long getLongInteger(int field) {
|
||||
Long longInteger = (Long) mHeaderMap.get(field);
|
||||
if (null == longInteger) {
|
||||
return -1;
|
||||
@@ -688,7 +687,7 @@ public class PduHeaders {
|
||||
* @param value the value
|
||||
* @param field the field
|
||||
*/
|
||||
protected void setLongInteger(long value, int field) {
|
||||
public void setLongInteger(long value, int field) {
|
||||
/**
|
||||
* Check whether this field can be set for specific
|
||||
* header and check validity of the field.
|
||||
@@ -711,4 +710,8 @@ public class PduHeaders {
|
||||
}
|
||||
mHeaderMap.put(field, value);
|
||||
}
|
||||
|
||||
public boolean hasHeader(int field) {
|
||||
return mHeaderMap.get(field, null) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,36 +19,55 @@
|
||||
package android.support.v7.mms.pdu;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PduParser {
|
||||
/**
|
||||
* The next are WAP values defined in WSP specification.
|
||||
* The log tag.
|
||||
*/
|
||||
private static final String LOG_TAG = "PduParser";
|
||||
|
||||
private static final boolean LOCAL_LOGV = false;
|
||||
|
||||
/**
|
||||
* The next are WAP values defined in WSP specification.
|
||||
*/
|
||||
private static final int QUOTE = 127;
|
||||
|
||||
private static final int LENGTH_QUOTE = 31;
|
||||
|
||||
private static final int TEXT_MIN = 32;
|
||||
|
||||
private static final int TEXT_MAX = 127;
|
||||
|
||||
private static final int SHORT_INTEGER_MAX = 127;
|
||||
|
||||
private static final int SHORT_LENGTH_MAX = 30;
|
||||
|
||||
private static final int LONG_INTEGER_LENGTH_MAX = 8;
|
||||
|
||||
private static final int QUOTED_STRING_FLAG = 34;
|
||||
|
||||
private static final int END_STRING_FLAG = 0x00;
|
||||
|
||||
//The next two are used by the interface "parseWapString" to
|
||||
//distinguish Text-String and Quoted-String.
|
||||
private static final int TYPE_TEXT_STRING = 0;
|
||||
|
||||
private static final int TYPE_QUOTED_STRING = 1;
|
||||
|
||||
private static final int TYPE_TOKEN_STRING = 2;
|
||||
|
||||
/**
|
||||
* Specify the part position.
|
||||
*/
|
||||
private static final int THE_FIRST_PART = 0;
|
||||
|
||||
private static final int THE_LAST_PART = 1;
|
||||
|
||||
/**
|
||||
@@ -76,13 +95,6 @@ public class PduParser {
|
||||
*/
|
||||
private static byte[] mStartParam = null;
|
||||
|
||||
/**
|
||||
* The log tag.
|
||||
*/
|
||||
private static final String LOG_TAG = "PduParser";
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean LOCAL_LOGV = false;
|
||||
|
||||
/**
|
||||
* Whether to parse content-disposition part header
|
||||
*/
|
||||
@@ -125,9 +137,16 @@ public class PduParser {
|
||||
log("check mandatory headers failed!");
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* Get retrieve status. If the header is not there, assuming it is OK status.
|
||||
* Some carriers may choose to not send this header.
|
||||
*/
|
||||
int retrieveStatus = mHeaders.hasHeader(PduHeaders.RETRIEVE_STATUS) ?
|
||||
mHeaders.getOctet(PduHeaders.RETRIEVE_STATUS) : PduHeaders.RETRIEVE_STATUS_OK;
|
||||
|
||||
if ((PduHeaders.MESSAGE_TYPE_SEND_REQ == messageType) ||
|
||||
(PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF == messageType)) {
|
||||
(PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF == messageType &&
|
||||
retrieveStatus == PduHeaders.RETRIEVE_STATUS_OK)) {
|
||||
/* need to parse the parts */
|
||||
mBody = parseParts(mPduDataStream);
|
||||
if (null == mBody) {
|
||||
@@ -169,26 +188,22 @@ public class PduParser {
|
||||
}
|
||||
RetrieveConf retrieveConf =
|
||||
new RetrieveConf(mHeaders, mBody);
|
||||
|
||||
if (retrieveStatus != PduHeaders.RETRIEVE_STATUS_OK) {
|
||||
// For failure only no need to check content type
|
||||
return retrieveConf;
|
||||
}
|
||||
byte[] contentType = retrieveConf.getContentType();
|
||||
if (null == contentType) {
|
||||
return null;
|
||||
}
|
||||
String ctTypeStr = new String(contentType);
|
||||
if (ctTypeStr.equals(ContentType.MULTIPART_MIXED)
|
||||
|| ctTypeStr.equals(ContentType.MULTIPART_RELATED)
|
||||
|| ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
|
||||
if (ctTypeStr.equals(ContentType.MMS_MULTIPART_MIXED)
|
||||
|| ctTypeStr.equals(ContentType.MMS_MULTIPART_RELATED)
|
||||
|| ctTypeStr.equals(ContentType.MMS_MULTIPART_ALTERNATIVE)) {
|
||||
// The MMS content type must be "application/vnd.wap.multipart.mixed"
|
||||
// or "application/vnd.wap.multipart.related"
|
||||
// or "application/vnd.wap.multipart.alternative"
|
||||
return retrieveConf;
|
||||
} else if (ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {
|
||||
// "application/vnd.wap.multipart.alternative"
|
||||
// should take only the first part.
|
||||
PduPart firstPart = mBody.getPart(0);
|
||||
mBody.removeAll();
|
||||
mBody.addPart(0, firstPart);
|
||||
return retrieveConf;
|
||||
}
|
||||
return null;
|
||||
case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
|
||||
@@ -231,7 +246,7 @@ public class PduParser {
|
||||
* @param pduDataStream pdu data input stream
|
||||
* @return headers in PduHeaders structure, null when parse fail
|
||||
*/
|
||||
protected PduHeaders parseHeaders(ByteArrayInputStream pduDataStream){
|
||||
protected PduHeaders parseHeaders(ByteArrayInputStream pduDataStream) {
|
||||
if (pduDataStream == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -244,7 +259,7 @@ public class PduParser {
|
||||
/* parse custom text header */
|
||||
if ((headerField >= TEXT_MIN) && (headerField <= TEXT_MAX)) {
|
||||
pduDataStream.reset();
|
||||
byte [] bVal = parseWapString(pduDataStream, TYPE_TEXT_STRING);
|
||||
byte[] bVal = parseWapString(pduDataStream, TYPE_TEXT_STRING);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "TextHeader: " + new String(bVal));
|
||||
}
|
||||
@@ -256,7 +271,8 @@ public class PduParser {
|
||||
{
|
||||
int messageType = extractByteValue(pduDataStream);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: messageType: " + messageType);
|
||||
Log.v(LOG_TAG, "parseHeaders: messageType: " + messageType +
|
||||
" (" + Integer.toHexString(headerField) + ")");
|
||||
}
|
||||
switch (messageType) {
|
||||
// We don't support these kind of messages now.
|
||||
@@ -320,7 +336,8 @@ public class PduParser {
|
||||
{
|
||||
int value = extractByteValue(pduDataStream);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: byte: " + headerField + " value: " +
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") Octect value: " +
|
||||
value);
|
||||
}
|
||||
|
||||
@@ -345,7 +362,8 @@ public class PduParser {
|
||||
try {
|
||||
long value = parseLongInteger(pduDataStream);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: longint: " + headerField + " value: " +
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") longint value: " +
|
||||
value);
|
||||
}
|
||||
headers.setLongInteger(value, headerField);
|
||||
@@ -364,7 +382,8 @@ public class PduParser {
|
||||
try {
|
||||
long value = parseIntegerValue(pduDataStream);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: int: " + headerField + " value: " +
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") integer value: " +
|
||||
value);
|
||||
}
|
||||
headers.setLongInteger(value, headerField);
|
||||
@@ -400,7 +419,9 @@ public class PduParser {
|
||||
if (null != value) {
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: string: " + headerField + " value: " +
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") string value: "
|
||||
+
|
||||
new String(value));
|
||||
}
|
||||
headers.setTextString(value, headerField);
|
||||
@@ -429,8 +450,10 @@ public class PduParser {
|
||||
if (null != value) {
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: encoded string: " + headerField
|
||||
+ " value: " + value.getString());
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField)
|
||||
+ ") encoded string: " +
|
||||
value.getString());
|
||||
}
|
||||
headers.setEncodedStringValue(value, headerField);
|
||||
} catch(NullPointerException e) {
|
||||
@@ -510,8 +533,9 @@ public class PduParser {
|
||||
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: time value: " + headerField
|
||||
+ " value: " + timeValue);
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") time value: " +
|
||||
timeValue);
|
||||
}
|
||||
headers.setLongInteger(timeValue, headerField);
|
||||
} catch(RuntimeException e) {
|
||||
@@ -564,8 +588,9 @@ public class PduParser {
|
||||
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: from address: " + headerField
|
||||
+ " value: " + from.getString());
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") from address: " +
|
||||
from.getString());
|
||||
}
|
||||
headers.setEncodedStringValue(from, PduHeaders.FROM);
|
||||
} catch(NullPointerException e) {
|
||||
@@ -582,8 +607,9 @@ public class PduParser {
|
||||
pduDataStream.mark(1);
|
||||
int messageClass = extractByteValue(pduDataStream);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: MESSAGE_CLASS: " + headerField
|
||||
+ " value: " + messageClass);
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") MESSAGE_CLASS: " +
|
||||
messageClass);
|
||||
}
|
||||
|
||||
if (messageClass >= PduHeaders.MESSAGE_CLASS_PERSONAL) {
|
||||
@@ -635,8 +661,9 @@ public class PduParser {
|
||||
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: MMS_VERSION: " + headerField
|
||||
+ " value: " + version);
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") MMS_VERSION: " +
|
||||
version);
|
||||
}
|
||||
headers.setOctet(version, PduHeaders.MMS_VERSION);
|
||||
} catch(InvalidHeaderValueException e) {
|
||||
@@ -670,8 +697,9 @@ public class PduParser {
|
||||
if (null != previouslySentBy) {
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: PREVIOUSLY_SENT_BY: " + headerField
|
||||
+ " value: " + previouslySentBy.getString());
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) +
|
||||
") PREVIOUSLY_SENT_BY: " + previouslySentBy.getString());
|
||||
}
|
||||
headers.setEncodedStringValue(previouslySentBy,
|
||||
PduHeaders.PREVIOUSLY_SENT_BY);
|
||||
@@ -701,12 +729,13 @@ public class PduParser {
|
||||
|
||||
/* Date-value */
|
||||
try {
|
||||
long perviouslySentDate = parseLongInteger(pduDataStream);
|
||||
long previouslySentDate = parseLongInteger(pduDataStream);
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: PREVIOUSLY_SENT_DATE: " + headerField
|
||||
+ " value: " + perviouslySentDate);
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) +
|
||||
") PREVIOUSLY_SENT_DATE: " + previouslySentDate);
|
||||
}
|
||||
headers.setLongInteger(perviouslySentDate,
|
||||
headers.setLongInteger(previouslySentDate,
|
||||
PduHeaders.PREVIOUSLY_SENT_DATE);
|
||||
} catch(RuntimeException e) {
|
||||
log(headerField + "is not Long-Integer header field!");
|
||||
@@ -722,8 +751,9 @@ public class PduParser {
|
||||
* Encoded-string-value
|
||||
*/
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: MM_FLAGS: " + headerField
|
||||
+ " NOT REALLY SUPPORTED");
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") MM_FLAGS: " +
|
||||
" NOT REALLY SUPPORTED");
|
||||
}
|
||||
|
||||
/* parse Value-length */
|
||||
@@ -746,7 +776,8 @@ public class PduParser {
|
||||
case PduHeaders.MBOX_QUOTAS:
|
||||
{
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: MBOX_TOTALS: " + headerField);
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") MBOX_");
|
||||
}
|
||||
/* Value-length */
|
||||
parseValueLength(pduDataStream);
|
||||
@@ -769,7 +800,8 @@ public class PduParser {
|
||||
|
||||
case PduHeaders.ELEMENT_DESCRIPTOR: {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: ELEMENT_DESCRIPTOR: " + headerField);
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") ELEMENT_DESCRIPTOR");
|
||||
}
|
||||
parseContentType(pduDataStream, null);
|
||||
|
||||
@@ -779,15 +811,16 @@ public class PduParser {
|
||||
}
|
||||
|
||||
case PduHeaders.CONTENT_TYPE: {
|
||||
HashMap<Integer, Object> map = new HashMap<>();
|
||||
SparseArray<Object> map = new SparseArray<>();
|
||||
byte[] contentType =
|
||||
parseContentType(pduDataStream, map);
|
||||
|
||||
if (null != contentType) {
|
||||
try {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: CONTENT_TYPE: " + headerField +
|
||||
Arrays.toString(contentType));
|
||||
Log.v(LOG_TAG, "parseHeaders: headerField: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ") CONTENT_TYPE: "
|
||||
+ Arrays.toString(contentType));
|
||||
}
|
||||
headers.setTextString(contentType, PduHeaders.CONTENT_TYPE);
|
||||
} catch(NullPointerException e) {
|
||||
@@ -813,7 +846,8 @@ public class PduParser {
|
||||
case PduHeaders.ATTRIBUTES:
|
||||
default: {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.v(LOG_TAG, "parseHeaders: Unknown header: " + headerField);
|
||||
Log.v(LOG_TAG, "parseHeaders: Unknown header: " + headerField +
|
||||
" (" + Integer.toHexString(headerField) + ")");
|
||||
}
|
||||
log("Unknown header");
|
||||
}
|
||||
@@ -848,7 +882,7 @@ public class PduParser {
|
||||
}
|
||||
|
||||
/* parse part's content-type */
|
||||
HashMap<Integer, Object> map = new HashMap<>();
|
||||
SparseArray<Object> map = new SparseArray<>();
|
||||
byte[] contentType = parseContentType(pduDataStream, map);
|
||||
if (null != contentType) {
|
||||
part.setContentType(contentType);
|
||||
@@ -897,7 +931,7 @@ public class PduParser {
|
||||
byte[] partData = new byte[dataLength];
|
||||
String partContentType = new String(part.getContentType());
|
||||
pduDataStream.read(partData, 0, dataLength);
|
||||
if (partContentType.equalsIgnoreCase(ContentType.MULTIPART_ALTERNATIVE)) {
|
||||
if (partContentType.equalsIgnoreCase(ContentType.MMS_MULTIPART_ALTERNATIVE)) {
|
||||
// parse "multipart/vnd.wap.multipart.alternative".
|
||||
PduBody childBody = parseParts(new ByteArrayInputStream(partData));
|
||||
// take the first part of children.
|
||||
@@ -1031,7 +1065,7 @@ public class PduParser {
|
||||
assert(-1 != temp);
|
||||
int first = temp & 0xFF;
|
||||
if (first == 0) {
|
||||
return new EncodedStringValue("");
|
||||
return null; // Blank subject, bail.
|
||||
}
|
||||
|
||||
pduDataStream.reset();
|
||||
@@ -1335,7 +1369,7 @@ public class PduParser {
|
||||
* @param length length of all the parameters
|
||||
*/
|
||||
protected static void parseContentTypeParams(ByteArrayInputStream pduDataStream,
|
||||
HashMap<Integer, Object> map, Integer length) {
|
||||
SparseArray<Object> map, Integer length) {
|
||||
/**
|
||||
* From wap-230-wsp-20010705-a.pdf
|
||||
* Parameter = Typed-parameter | Untyped-parameter
|
||||
@@ -1518,7 +1552,7 @@ public class PduParser {
|
||||
* @return Content-Type value
|
||||
*/
|
||||
protected static byte[] parseContentType(ByteArrayInputStream pduDataStream,
|
||||
HashMap<Integer, Object> map) {
|
||||
SparseArray<Object> map) {
|
||||
/**
|
||||
* From wap-230-wsp-20010705-a.pdf
|
||||
* Content-type-value = Constrained-media | Content-general-form
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
package android.support.v7.mms.pdu;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import android.util.SparseArray;
|
||||
|
||||
/**
|
||||
* The pdu part.
|
||||
@@ -108,7 +106,7 @@ public class PduPart {
|
||||
/**
|
||||
* Header of part.
|
||||
*/
|
||||
private Map<Integer, Object> mPartHeader = null;
|
||||
private SparseArray<Object> mPartHeader = null;
|
||||
|
||||
/**
|
||||
* Data uri.
|
||||
@@ -126,7 +124,7 @@ public class PduPart {
|
||||
* Empty Constructor.
|
||||
*/
|
||||
public PduPart() {
|
||||
mPartHeader = new HashMap<>();
|
||||
mPartHeader = new SparseArray<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,41 +133,18 @@ public class PduPart {
|
||||
* @param data the data
|
||||
*/
|
||||
public void setData(byte[] data) {
|
||||
if(data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPartData = new byte[data.length];
|
||||
System.arraycopy(data, 0, mPartData, 0, data.length);
|
||||
mPartData = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A copy of the part data or null if the data wasn't set or
|
||||
* the data is stored as Uri.
|
||||
* @return The part data or null if the data wasn't set or
|
||||
* the data is stored as Uri.
|
||||
* @see #getDataUri
|
||||
*/
|
||||
public byte[] getData() {
|
||||
if(mPartData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] byteArray = new byte[mPartData.length];
|
||||
System.arraycopy(mPartData, 0, byteArray, 0, mPartData.length);
|
||||
return byteArray;
|
||||
return mPartData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The length of the data, if this object have data, else 0.
|
||||
*/
|
||||
public int getDataLength() {
|
||||
if(mPartData != null){
|
||||
return mPartData.length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set data uri. The data are stored as Uri.
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ReadOrigInd extends GenericPdu {
|
||||
*
|
||||
* @param headers Headers for this PDU.
|
||||
*/
|
||||
ReadOrigInd(PduHeaders headers) {
|
||||
public ReadOrigInd(PduHeaders headers) {
|
||||
super(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ReadRecInd extends GenericPdu {
|
||||
*
|
||||
* @param headers Headers for this PDU.
|
||||
*/
|
||||
ReadRecInd(PduHeaders headers) {
|
||||
public ReadRecInd(PduHeaders headers) {
|
||||
super(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RetrieveConf extends MultimediaMessagePdu {
|
||||
* @param headers Headers for this PDU.
|
||||
* @param body Body of this PDu.
|
||||
*/
|
||||
RetrieveConf(PduHeaders headers, PduBody body) {
|
||||
public RetrieveConf(PduHeaders headers, PduBody body) {
|
||||
super(headers, body);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,12 @@ public class RetrieveConf extends MultimediaMessagePdu {
|
||||
* @return the value
|
||||
*/
|
||||
public int getRetrieveStatus() {
|
||||
return mPduHeaders.getOctet(PduHeaders.RETRIEVE_STATUS);
|
||||
/*
|
||||
* If the header is not there, assuming it is OK status.
|
||||
* Some carriers may choose to not send this header.
|
||||
*/
|
||||
return mPduHeaders.hasHeader(PduHeaders.RETRIEVE_STATUS) ?
|
||||
mPduHeaders.getOctet(PduHeaders.RETRIEVE_STATUS) : PduHeaders.RETRIEVE_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,7 +83,7 @@ public class SendReq extends MultimediaMessagePdu {
|
||||
* @param headers Headers for this PDU.
|
||||
* @param body Body of this PDu.
|
||||
*/
|
||||
SendReq(PduHeaders headers, PduBody body) {
|
||||
public SendReq(PduHeaders headers, PduBody body) {
|
||||
super(headers, body);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user