am 42ca4250: am 565cafe7: Merge "PduParser MSIM support (4/4)" into lmp-mr1-dev

* commit '42ca42509c76f23d883ffa991d06afb36673b21c':
  PduParser MSIM support (4/4)
This commit is contained in:
Ye Wen
2014-11-19 00:19:17 +00:00
committed by Android Git Automerger
3 changed files with 49 additions and 9 deletions

View File

@@ -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));

View File

@@ -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();

View File

@@ -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);
}
}