PduParser MSIM support (4/4)
PduParser needs to know if Content-Disposition part header is supported
for a specific carrier. Originally this is loaded directly from system
resource in PduParser. This won't work for multi-SIM, which requires
getting that config based on carrier. This change adds parameter to
indicate if this header is supported and requires caller to provider the
config.
b/18371228
Change-Id: I8a0a7ce91d1b9581fe5d4545fa954277a661751b
diff --git a/samples/ApiDemos/src/com/example/android/apis/os/MmsMessagingDemo.java b/samples/ApiDemos/src/com/example/android/apis/os/MmsMessagingDemo.java
index 6a5d94c..0b66d6f 100644
--- a/samples/ApiDemos/src/com/example/android/apis/os/MmsMessagingDemo.java
+++ b/samples/ApiDemos/src/com/example/android/apis/os/MmsMessagingDemo.java
@@ -238,7 +238,8 @@
if (code == Activity.RESULT_OK) {
final byte[] response = intent.getByteArrayExtra(SmsManager.EXTRA_MMS_DATA);
if (response != null) {
- final GenericPdu pdu = new PduParser(response).parse();
+ final GenericPdu pdu = new PduParser(
+ response, PduParserUtil.shouldParseContentDisposition()).parse();
if (pdu instanceof SendConf) {
final SendConf sendConf = (SendConf) pdu;
if (sendConf.getResponseStatus() == PduHeaders.RESPONSE_STATUS_OK) {
@@ -281,7 +282,8 @@
final byte[] response = new byte[nBytes];
final int read = reader.read(response, 0, nBytes);
if (read == nBytes) {
- final GenericPdu pdu = new PduParser(response).parse();
+ final GenericPdu pdu = new PduParser(
+ response, PduParserUtil.shouldParseContentDisposition()).parse();
if (pdu instanceof RetrieveConf) {
final RetrieveConf retrieveConf = (RetrieveConf) pdu;
mRecipientsInput.setText(getRecipients(context, retrieveConf));
diff --git a/samples/ApiDemos/src/com/example/android/apis/os/MmsWapPushReceiver.java b/samples/ApiDemos/src/com/example/android/apis/os/MmsWapPushReceiver.java
index a291e4a..f2ca090 100644
--- a/samples/ApiDemos/src/com/example/android/apis/os/MmsWapPushReceiver.java
+++ b/samples/ApiDemos/src/com/example/android/apis/os/MmsWapPushReceiver.java
@@ -16,18 +16,18 @@
package com.example.android.apis.os;
-import com.google.android.mms.ContentType;
-import com.google.android.mms.pdu.GenericPdu;
-import com.google.android.mms.pdu.NotificationInd;
-import com.google.android.mms.pdu.PduHeaders;
-import com.google.android.mms.pdu.PduParser;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Telephony;
import android.util.Log;
+import com.google.android.mms.ContentType;
+import com.google.android.mms.pdu.GenericPdu;
+import com.google.android.mms.pdu.NotificationInd;
+import com.google.android.mms.pdu.PduHeaders;
+import com.google.android.mms.pdu.PduParser;
+
/**
* Receiver for MMS WAP push
*/
@@ -39,7 +39,8 @@
if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction())
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
final byte[] data = intent.getByteArrayExtra("data");
- final PduParser parser = new PduParser(data);
+ final PduParser parser = new PduParser(
+ data, PduParserUtil.shouldParseContentDisposition());
GenericPdu pdu = null;
try {
pdu = parser.parse();
diff --git a/samples/ApiDemos/src/com/example/android/apis/os/PduParserUtil.java b/samples/ApiDemos/src/com/example/android/apis/os/PduParserUtil.java
new file mode 100644
index 0000000..541854e
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/os/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.example.android.apis.os;
+
+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);
+ }
+}