diff options
author | Gannon Macdonald <gannon050197@gmail.com> | 2013-01-28 20:56:32 -0600 |
---|---|---|
committer | rohan <rohanmathur34@gmail.com> | 2013-01-31 18:18:38 -0500 |
commit | 417458b50576a2438b0ed5771a2015b08659a32d (patch) | |
tree | c027f062768598b61602602d76965d520ffbfd48 | |
parent | 5343f09644650fae7708337eb55788f3d20aabb0 (diff) | |
download | frameworks_opt_telephony-417458b50576a2438b0ed5771a2015b08659a32d.zip frameworks_opt_telephony-417458b50576a2438b0ed5771a2015b08659a32d.tar.gz frameworks_opt_telephony-417458b50576a2438b0ed5771a2015b08659a32d.tar.bz2 |
telephony: Support for Virgin Mobile MMS
Based off of rmcc's bringup commit for jellybean:
https://github.com/CyanogenMod/android_frameworks_base/commit/657a58f681f389010f214dd3ee23102cf17e325b
Change-Id: Ife2d39da9a5adfc19bb6389cb36b5c12eb5a903a
Signed-off-by: Gannon Macdonald <gannon050197@gmail.com>
-rwxr-xr-x | src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java index 1a49db9..fd54813 100755 --- a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java +++ b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java @@ -55,6 +55,7 @@ import com.android.internal.telephony.cdma.sms.BearerData; import com.android.internal.telephony.cdma.sms.CdmaSmsAddress; import com.android.internal.telephony.cdma.sms.SmsEnvelope; import com.android.internal.telephony.cdma.sms.UserData; +import com.android.internal.util.BitwiseInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -224,10 +225,77 @@ 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 + * 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. |