summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWarren Togami <wtogami@gmail.com>2012-03-10 16:57:56 -1000
committerWarren Togami <wtogami@gmail.com>2012-03-11 16:50:15 -1000
commit5108551e160bf84b67914e0f57eab56999865874 (patch)
tree2a2bb1c36e00bfe81e601e8f35bbefbd8ec68279 /telephony
parentbcab1a93e45a667eec405dec396c442f2acf16ad (diff)
downloadframeworks_base-5108551e160bf84b67914e0f57eab56999865874.zip
frameworks_base-5108551e160bf84b67914e0f57eab56999865874.tar.gz
frameworks_base-5108551e160bf84b67914e0f57eab56999865874.tar.bz2
Support for Virgin Mobile MMS.
Code cleaned up and reformatted to be closer to Android coding style. Credit: progmanos CM9 port of inferiorhumanorgans CM7 VM MMS. Change-Id: I25a7d8d21abca4318ccb901ff9755644a0e928b0
Diffstat (limited to 'telephony')
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java71
1 files changed, 70 insertions, 1 deletions
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index ca8d9ae..4387a17 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -45,6 +45,7 @@ import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.WspTypeDecoder;
import com.android.internal.telephony.cdma.sms.SmsEnvelope;
import com.android.internal.telephony.cdma.sms.UserData;
+import com.android.internal.util.BitwiseInputStream;
import com.android.internal.util.HexDump;
import java.io.ByteArrayOutputStream;
@@ -181,10 +182,78 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
(SmsEnvelope.MESSAGE_TYPE_BROADCAST != sms.getMessageType())) {
return Intents.RESULT_SMS_UNSUPPORTED;
}
-
+ /*
+ * Check to see if we have a Virgin Mobile MMS
+ * If so, do extra processsing for Virgin Mobile's non-standard format.
+ * Otherwise, dispatch normal message.
+ */
+ if (sms.getOriginatingAddress().equals("9999999999")) {
+ Log.d(TAG, "Got a suspect SMS from the Virgin MMS originator");
+ byte virginMMSPayload[] = null;
+ try {
+ int[] ourMessageRef = new int[1];
+ virginMMSPayload = getVirginMMS(sms.getUserData(), ourMessageRef);
+ if (virginMMSPayload == null) {
+ Log.e(TAG, "Not a virgin MMS like we were expecting");
+ throw new Exception("Not a Virgin MMS like we were expecting");
+ } else {
+ Log.d(TAG, "Sending our deflowered MMS to processCdmaWapPdu");
+ return processCdmaWapPdu(virginMMSPayload, ourMessageRef[0], "9999999999");
+ }
+ } catch (Exception ourException) {
+ Log.e(TAG, "Got an exception trying to get VMUS MMS data " + ourException);
+ }
+ }
return dispatchNormalMessage(smsb);
}
+ private synchronized byte[] getVirginMMS(final byte[] someEncodedMMSData, int[] aMessageRef) throws Exception {
+ if ((aMessageRef == null) || (aMessageRef.length != 1)) {
+ throw new Exception("aMessageRef is not usable. Must be an int array with one element.");
+ }
+ BitwiseInputStream ourInputStream;
+ int i1=0;
+ int desiredBitLength;
+ Log.d(TAG, "mmsVirginGetMsgId");
+ Log.d(TAG, "EncodedMMS: " + someEncodedMMSData);
+ try {
+ ourInputStream = new BitwiseInputStream(someEncodedMMSData);
+ ourInputStream.skip(20);
+ final int j = ourInputStream.read(8) << 8;
+ final int k = ourInputStream.read(8);
+ aMessageRef[0] = j | k;
+ Log.d(TAG, "MSGREF IS : " + aMessageRef[0]);
+ ourInputStream.skip(12);
+ i1 = ourInputStream.read(8) + -2;
+ ourInputStream.skip(13);
+ byte abyte1[] = new byte[i1];
+ for (int j1 = 0; j1 < i1; j1++) {
+ abyte1[j1] = 0;
+ }
+ desiredBitLength = i1 * 8;
+ if (ourInputStream.available() < desiredBitLength) {
+ int availableBitLength = ourInputStream.available();
+ Log.e(TAG, "mmsVirginGetMsgId inStream.available() = " + availableBitLength + " wantedBits = " + desiredBitLength);
+ throw new Exception("insufficient data (wanted " + desiredBitLength + " bits, but only have " + availableBitLength + ")");
+ }
+ } catch (com.android.internal.util.BitwiseInputStream.AccessException ourException) {
+ final String ourExceptionText = "mmsVirginGetMsgId failed: " + ourException;
+ Log.e(TAG, ourExceptionText);
+ throw new Exception(ourExceptionText);
+ }
+ byte ret[] = null;
+ try {
+ ret = ourInputStream.readByteArray(desiredBitLength);
+ Log.d(TAG, "mmsVirginGetMsgId user_length = " + i1 + " msgid = " + aMessageRef[0]);
+ Log.d(TAG, "mmsVirginGetMsgId userdata = " + ret.toString());
+ } catch (com.android.internal.util.BitwiseInputStream.AccessException ourException) {
+ final String ourExceptionText = "mmsVirginGetMsgId failed: " + ourException;
+ Log.e(TAG, ourExceptionText);
+ throw new Exception(ourExceptionText);
+ }
+ return ret;
+ }
+
/**
* Processes inbound messages that are in the WAP-WDP PDU format. See
* wap-259-wdp-20010614-a section 6.5 for details on the WAP-WDP PDU format.