summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorYe Wen <ywen@google.com>2014-11-18 23:16:08 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-18 23:16:09 +0000
commit565cafe77001fc15f66d9a45d3e3e4c799f9f9cf (patch)
tree570f6faa22075311735c2ead9726f372b3a36dde /samples
parentd51791b0825a8812798425640a9b3632e77ffcfe (diff)
parent03f9acc909322c6de525ea92ff34dfe36f39f4f8 (diff)
Merge "PduParser MSIM support (4/4)" into lmp-mr1-dev
Diffstat (limited to 'samples')
-rw-r--r--samples/ApiDemos/src/com/example/android/apis/os/MmsMessagingDemo.java6
-rw-r--r--samples/ApiDemos/src/com/example/android/apis/os/MmsWapPushReceiver.java15
-rw-r--r--samples/ApiDemos/src/com/example/android/apis/os/PduParserUtil.java37
3 files changed, 49 insertions, 9 deletions
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 6a5d94c99..0b66d6f5b 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 @@ public class MmsMessagingDemo extends Activity {
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 @@ public class MmsMessagingDemo extends Activity {
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 a291e4aee..f2ca090b0 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 @@ public class MmsWapPushReceiver extends BroadcastReceiver {
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 000000000..541854e6e
--- /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);
+ }
+}