summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Wen <ywen@google.com>2014-11-19 00:15:18 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-19 00:15:18 +0000
commite43c88b8d4604a6d89f73c5e95d69935b41d27a0 (patch)
treebd6a70b52bae9385d73e693dab842bed35cf079f
parent8c66dd2bf9656676462cff2e55489a11ae8be265 (diff)
parent9fcdc6e0b930e32bcef65c811b30d01dfb7d41d9 (diff)
downloadMms-e43c88b8d4604a6d89f73c5e95d69935b41d27a0.tar.gz
am 9fcdc6e0: am 178eb839: PduParser MSIM support (3/4)
* commit '9fcdc6e0b930e32bcef65c811b30d01dfb7d41d9': PduParser MSIM support (3/4)
-rw-r--r--src/com/android/mms/transaction/NotificationTransaction.java10
-rw-r--r--src/com/android/mms/transaction/PduParserUtil.java37
-rw-r--r--src/com/android/mms/transaction/PushReceiver.java3
-rw-r--r--src/com/android/mms/transaction/RetrieveTransaction.java7
-rw-r--r--src/com/android/mms/transaction/SendTransaction.java7
-rw-r--r--src/com/android/mms/transaction/TransactionService.java4
6 files changed, 55 insertions, 13 deletions
diff --git a/src/com/android/mms/transaction/NotificationTransaction.java b/src/com/android/mms/transaction/NotificationTransaction.java
index b643f23e..b6d5cb6d 100644
--- a/src/com/android/mms/transaction/NotificationTransaction.java
+++ b/src/com/android/mms/transaction/NotificationTransaction.java
@@ -24,16 +24,13 @@ import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF;
import static com.google.android.mms.pdu.PduHeaders.STATUS_DEFERRED;
import static com.google.android.mms.pdu.PduHeaders.STATUS_RETRIEVED;
import static com.google.android.mms.pdu.PduHeaders.STATUS_UNRECOGNIZED;
-
-import java.io.IOException;
-
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SqliteWrapper;
import android.net.Uri;
import android.provider.Telephony.Mms;
-import android.provider.Telephony.Threads;
import android.provider.Telephony.Mms.Inbox;
+import android.provider.Telephony.Threads;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -53,6 +50,8 @@ import com.google.android.mms.pdu.PduHeaders;
import com.google.android.mms.pdu.PduParser;
import com.google.android.mms.pdu.PduPersister;
+import java.io.IOException;
+
/**
* The NotificationTransaction is responsible for handling multimedia
* message notifications (M-Notification.ind). It:
@@ -175,7 +174,8 @@ public class NotificationTransaction extends Transaction implements Runnable {
}
if (retrieveConfData != null) {
- GenericPdu pdu = new PduParser(retrieveConfData).parse();
+ GenericPdu pdu = new PduParser(
+ retrieveConfData, PduParserUtil.shouldParseContentDisposition()).parse();
if ((pdu == null) || (pdu.getMessageType() != MESSAGE_TYPE_RETRIEVE_CONF)) {
Log.e(TAG, "Invalid M-RETRIEVE.CONF PDU. " +
(pdu != null ? "message type: " + pdu.getMessageType() : "null pdu"));
diff --git a/src/com/android/mms/transaction/PduParserUtil.java b/src/com/android/mms/transaction/PduParserUtil.java
new file mode 100644
index 00000000..8d0caa0a
--- /dev/null
+++ b/src/com/android/mms/transaction/PduParserUtil.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 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.mms.transaction;
+
+import android.telephony.SmsManager;
+
+/**
+ * Util methods for PduParser
+ */
+public class PduParserUtil {
+ /**
+ * Get the config of whether Content-Disposition header is supported
+ * for default carrier using new SmsManager API
+ *
+ * @return true if supported, false otherwise
+ */
+ public static boolean shouldParseContentDisposition() {
+ return SmsManager
+ .getDefault()
+ .getCarrierConfigValues()
+ .getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION, true);
+ }
+}
diff --git a/src/com/android/mms/transaction/PushReceiver.java b/src/com/android/mms/transaction/PushReceiver.java
index 4f6ed728..8e7212d1 100644
--- a/src/com/android/mms/transaction/PushReceiver.java
+++ b/src/com/android/mms/transaction/PushReceiver.java
@@ -70,7 +70,8 @@ public class PushReceiver extends BroadcastReceiver {
// Get raw PDU push-data from the message and parse it
byte[] pushData = intent.getByteArrayExtra("data");
- PduParser parser = new PduParser(pushData);
+ PduParser parser = new PduParser(
+ pushData, PduParserUtil.shouldParseContentDisposition());
GenericPdu pdu = parser.parse();
if (null == pdu) {
diff --git a/src/com/android/mms/transaction/RetrieveTransaction.java b/src/com/android/mms/transaction/RetrieveTransaction.java
index 7277d499..74adc024 100644
--- a/src/com/android/mms/transaction/RetrieveTransaction.java
+++ b/src/com/android/mms/transaction/RetrieveTransaction.java
@@ -17,8 +17,6 @@
package com.android.mms.transaction;
-import java.io.IOException;
-
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@@ -45,6 +43,8 @@ import com.google.android.mms.pdu.PduParser;
import com.google.android.mms.pdu.PduPersister;
import com.google.android.mms.pdu.RetrieveConf;
+import java.io.IOException;
+
/**
* The RetrieveTransaction is responsible for retrieving multimedia
* messages (M-Retrieve.conf) from the MMSC server. It:
@@ -137,7 +137,8 @@ public class RetrieveTransaction extends Transaction implements Runnable {
byte[] resp = getPdu(mContentLocation);
// Parse M-Retrieve.conf
- RetrieveConf retrieveConf = (RetrieveConf) new PduParser(resp).parse();
+ RetrieveConf retrieveConf = (RetrieveConf) new PduParser(
+ resp, PduParserUtil.shouldParseContentDisposition()).parse();
if (null == retrieveConf) {
throw new MmsException("Invalid M-Retrieve.conf PDU.");
}
diff --git a/src/com/android/mms/transaction/SendTransaction.java b/src/com/android/mms/transaction/SendTransaction.java
index e07a77a4..f7f7c11e 100644
--- a/src/com/android/mms/transaction/SendTransaction.java
+++ b/src/com/android/mms/transaction/SendTransaction.java
@@ -17,8 +17,6 @@
package com.android.mms.transaction;
-import java.util.Arrays;
-
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
@@ -41,6 +39,8 @@ import com.google.android.mms.pdu.PduPersister;
import com.google.android.mms.pdu.SendConf;
import com.google.android.mms.pdu.SendReq;
+import java.util.Arrays;
+
/**
* The SendTransaction is responsible for sending multimedia messages
* (M-Send.req) to the MMSC server. It:
@@ -119,7 +119,8 @@ public class SendTransaction extends Transaction implements Runnable {
Log.d(TAG, "[SendTransaction] run: send mms msg (" + mId + "), resp=" + respStr);
}
- SendConf conf = (SendConf) new PduParser(response).parse();
+ SendConf conf = (SendConf) new PduParser(
+ response, PduParserUtil.shouldParseContentDisposition()).parse();
if (conf == null) {
Log.e(TAG, "No M-Send.conf received.");
}
diff --git a/src/com/android/mms/transaction/TransactionService.java b/src/com/android/mms/transaction/TransactionService.java
index d7c53660..dbe56d01 100644
--- a/src/com/android/mms/transaction/TransactionService.java
+++ b/src/com/android/mms/transaction/TransactionService.java
@@ -706,7 +706,9 @@ public class TransactionService extends Service implements Observer {
} else {
// Now it's only used for test purpose.
byte[] pushData = args.getPushData();
- PduParser parser = new PduParser(pushData);
+ PduParser parser = new PduParser(
+ pushData,
+ PduParserUtil.shouldParseContentDisposition());
GenericPdu ind = parser.parse();
int type = PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;