insert Vodafone sim card,open the mms read report,when receive the read report,cann't download the message

Test steps:

1.insert Vodafone sim card

2.open the mms read report

3.send the mms successfully

4.when receive the read report

这里的环境需要描述一下:在国内不会出现这个问题,该问题在土耳其测试发现,经过分析主要因国内外网络差异导致。

问题大概意思是在国外发送一条彩信,对方成功接收,发送方测试会接收一条阅读报告。该阅读报告是以彩信的方式接收。这个时候问题来了,彩信无法自动下载,点击下载按钮也无法完成下载(这里从界面时的确可以这么理解,分析代码之后才发现彩信数据已经下载成功,只是在解析的时候格式不兼容导致解析发生异常,返回null。)

因此经过分析打开NotificationTransaction.java中的log,从log中得到已经下载好的彩信数据,然后在国内用此模拟数据来解决问题。

if (retrieveConfData != null) {(这里添加注释的意思也就是在这里输出log,得到国外模拟数据,然后在国内进行模拟测试)

                //if (Log.isLoggable(LogTag.TRANSACTION, Log.DEBUG)) {

                    Log.v(TAG, "NotificationTransaction: retrieve data=" +

                            HexDump.dumpHexString(retrieveConfData));//HexDump这个工具类很重要,如果有时间大家仔细阅读一下源码(可以将16进制字符串和字节数组进行转换)

//}

当然,最终修改解决问题的实在解析pdu和持久化保存的PduParser.java类。

case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:

                if (LOCAL_LOGV) {

                    Log.v(LOG_TAG, "parse: MESSAGE_TYPE_RETRIEVE_CONF");

                }

                RetrieveConf retrieveConf =

                    new RetrieveConf(mHeaders, mBody);



                byte[] contentType = retrieveConf.getContentType();

                if (null == contentType) {

                    if (LOCAL_LOGV)

                        Log.v(LOG_TAG, "contentType is null");

                    return null;

                }

                String ctTypeStr = new String(contentType);

                if (LOCAL_LOGV)

                    Log.v(LOG_TAG, "ctTypeStr is l"+ctTypeStr);

                if (ctTypeStr.equals(ContentType.MULTIPART_MIXED)

                        || ctTypeStr.equals(ContentType.MULTIPART_RELATED)

                        || ctTypeStr.equals(ContentType.TEXT_PLAIN)//这里是添加对“text/plain”格式彩信的兼容

                        || ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {

                    // The MMS content type must be "application/vnd.wap.multipart.mixed"

                    // or "application/vnd.wap.multipart.related"

                    // or "application/vnd.wap.multipart.alternative"

                    return retrieveConf;

                } else if (ctTypeStr.equals(ContentType.MULTIPART_ALTERNATIVE)) {

                    // "application/vnd.wap.multipart.alternative"

                    // should take only the first part.

                    PduPart firstPart = mBody.getPart(0);

                    mBody.removeAll();

                    mBody.addPart(0, firstPart);

                    return retrieveConf;

                }

                return null;

下面这发现异常的时候忽视异常:

protected static PduBody parseParts(ByteArrayInputStream pduDataStream) {

        if (pduDataStream == null) {

            if (LOCAL_LOGV)

                Log.v(LOG_TAG, "pduDataStream is null");

            return null;

        }



        int count = parseUnsignedInt(pduDataStream); // get the number of parts

        PduBody body = new PduBody();



        for (int i = 0 ; i < count ; i++) {

            int headerLength = parseUnsignedInt(pduDataStream);

            int dataLength = parseUnsignedInt(pduDataStream);

            PduPart part = new PduPart();

            int startPos = pduDataStream.available();

            if (startPos <= 0) {

                // Invalid part.

                return body;//这里原本是返回null

            }




            /* parse part's content-type */

            HashMap<Integer, Object> map = new HashMap<Integer, Object>();

            byte[] contentType = parseContentType(pduDataStream, map);

            if (null != contentType) {

                part.setContentType(contentType);

            } else {

                if (LOCAL_LOGV)

                    Log.v(LOG_TAG, "contentType isn't null");

                part.setContentType((PduContentTypes.contentTypes[0]).getBytes()); //"*/*"

            }



            /* get name parameter */

            byte[] name = (byte[]) map.get(PduPart.P_NAME);

            if (null != name) {

                part.setName(name);

            }

            else{

                if (LOCAL_LOGV)

                    Log.v(LOG_TAG, "name isn't null");

            }

            /* get charset parameter */

            Integer charset = (Integer) map.get(PduPart.P_CHARSET);

            if (null != charset) {

                part.setCharset(charset);

            }

            else{

                if (LOCAL_LOGV)

                    Log.v(LOG_TAG, "charset isn't null");

            }

            /* parse part's headers */

            int endPos = pduDataStream.available();

            int partHeaderLen = headerLength - (startPos - endPos);

            if (partHeaderLen > 0) {

                if (false == parsePartHeaders(pduDataStream, part, partHeaderLen)) {

                    // Parse part header faild.

                    if (LOCAL_LOGV)

                        Log.v(LOG_TAG, "Parse part header faild.");

                    //return null;

                }

            } else if (partHeaderLen < 0) {

                // Invalid length of content-type.

                if (LOCAL_LOGV)

                    Log.v(LOG_TAG, "Invalid length of content-type.");

                //return null;

            }



            /* FIXME: check content-id, name, filename and content location,

             * if not set anyone of them, generate a default content-location

             */

            if ((null == part.getContentLocation())

                    && (null == part.getName())

                    && (null == part.getFilename())

                    && (null == part.getContentId())) {

                part.setContentLocation(Long.toOctalString(

                        System.currentTimeMillis()).getBytes());

            }



            /* get part's data */

            if (dataLength > 0) {

                byte[] partData = new byte[dataLength];

                String partContentType = new String(part.getContentType());

                pduDataStream.read(partData, 0, dataLength);

                if (partContentType.equalsIgnoreCase(ContentType.MULTIPART_ALTERNATIVE)) {

                    // parse "multipart/vnd.wap.multipart.alternative".

                    PduBody childBody = parseParts(new ByteArrayInputStream(partData));

                    // take the first part of children.

                    part = childBody.getPart(0);

                } else {

                    // Check Content-Transfer-Encoding.

                    byte[] partDataEncoding = part.getContentTransferEncoding();

                    if (null != partDataEncoding) {

                        String encoding = new String(partDataEncoding);

                        if (encoding.equalsIgnoreCase(PduPart.P_BASE64)) {

                            // Decode "base64" into "binary".

                            partData = Base64.decodeBase64(partData);

                        } else if (encoding.equalsIgnoreCase(PduPart.P_QUOTED_PRINTABLE)) {

                            // Decode "quoted-printable" into "binary".

                            partData = QuotedPrintable.decodeQuotedPrintable(partData);

                        } else {

                            // "binary" is the default encoding.

                        }

                    }

                    else{

                        if (LOCAL_LOGV)

                            Log.v(LOG_TAG, "partDataEncoding isn't null");

                    }

                    if (null == partData) {

                        log("Decode part data error!");

                        return null;

                    }

                    else{

                        if (LOCAL_LOGV)

                            Log.v(LOG_TAG, "partData isn't null");

                    }

                    part.setData(partData);

                }

            }



            if(LOCAL_LOGV)

                Log.v(LOG_TAG,"checkPartPosition is "+checkPartPosition(part));

            /* add this part to body */

            if (THE_FIRST_PART == checkPartPosition(part)) {

                /* this is the first part */

                body.addPart(0, part);

            } else {

                /* add the part to the end */

                body.addPart(part);

            }

        }



        return body;

    }

解决:insert Vodafone sim card,open the mms read report,when receive the read report,cann't download..的更多相关文章

  1. 解决:insert Vodafone sim card,open the mms read report,when receive the read report,cann&#39;t download..

    insert Vodafone sim card,open the mms read report,when receive the read report,cann't download the m ...

  2. Windows 10 - View SIM Card Number

     If your device isn't running Windows 10, refer to the Windows 8 instructions. From the Windows desk ...

  3. 在Debian8.3中解决Odoo出现的问题:Unable to find Wkhtmltopdf on this system. The report will be shown in html.

    解决Odoo出现的问题:Unable to find Wkhtmltopdf on this system. The report will be shown in html. 下载wkhtmltop ...

  4. 解决insert语句插入时,需要写列值的问题

    今天发现解决这个问题其实很简单,闲话不多谈,我直接附上语句 ) select @s = isnull(@s+',', '') + [name] from syscolumns where id = o ...

  5. 论山寨手机与Android联姻 【8】 自己动手做XP手机

    2010年1月20日,ViewSonic在北京发布了一款真正意义的电脑手机VCP08.根据商家的宣传,VCP08之所以能够被称为真正的电脑手机,是因为“该机做到了把真正的WindowsXP操作系统嵌入 ...

  6. Arduino 3g shield using GSM bought from ITead

    This is an old arduino 3G module bought half years ago. Its wiki: http://wiki.iteadstudio.com/ITEAD_ ...

  7. android之GMS认证

    来到了新的公司,才知道做手机是须要做GMS认证的.于是从一个从没有做过GMS认证的小白到一个月做了8个项目的GMS认证.最后.自己都是吐了.每天晚上都是一个人傻傻在加班.更是知道了高通的支持力度让人发 ...

  8. 【译】Asp.net mvc 使用ITextSharp PDF to HTML (解决img标签问题)

    前言:因项目需求,需要将HTML代码转成PDF.大致上已经实现了,可以是发现使用ITextSharp(我现在的版本是5.5.9)的时候,img标签中的src只能跟绝对路径. 在百度上找了一个上午,有一 ...

  9. mysql insert一条记录后怎样返回创建记录的主键id,last_insert_id(),selectkey

    mysql插入数据后返回自增ID的方法 mysql和oracle插入的时候有一个很大的区别是,oracle支持序列做id,mysql本身有一个列可以做自增长字段,mysql在插入一条数据后,如何能获得 ...

随机推荐

  1. Eclipse管理Java工程(j2se/j2ee/maven)

    Eclipse管理J2SE/J2EE(Maven)项目 eclipse是一个集成开发工具,有编译,运行,打包部署等功能.eclipse可以新建多种项目,不同的项目有不同的IDE层次结构,方便用户管理资 ...

  2. Runner之记计账项目的典型用户分析

  3. wxpython颜色选择

    Color Code Color Name Color #000000 BLACK   #0000FF BLUE   #007FFF SLATE BLUE   #00FF00 GREEN   #00F ...

  4. Echart多图联动

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  5. 用HTML5实现手机摇一摇的功能(转)

    在百度开发者大会上我介绍过HTML5另外一个重要特性就是DeviceOrientation,它将底层的方向传感器和运动传感器进行了高级封装,提供了DOM事件的支持.这个特性包括两种事件: 1.devi ...

  6. JavaScript EventLoop

    转自:http://cek.io/blog/2015/12/03/event-loop/ What is JavaScript What is JavaScript anyway? Some word ...

  7. Jquery异步提交$.ajax的使用

    function test(){ var myEntity=new Object(); myEntity.pro1="xxx"; myEntity.pro2=10; $.ajax( ...

  8. php 应用 cpu 100% 调试方法

    找出进程占用cpu高的原因. 进程占用cpu高,一般是由于进程长时间占用cpu,又没有主动释放占用.如果想主动释放cpu,可以调用sleep.在写程序的时候,尤其要注意while 等循环的地方. 找出 ...

  9. 在Html中使用JavaScript的几点小结

    前言 越发的意识到JS这门作为前端语言的重要性.所以下定决心这段时间在项目允许的情况下花大量时间在学习JS上.争取让自己的前端功底深厚一点. 小结 在包含外部js文件时,必须将src属性设置为指向相应 ...

  10. hibernate框架

    在之前的DAO开发中,对关系型数据库进行增删改查都是直接通过sql语句,需要人工的进行对象和表之间的转换.而Hibernate提供了对象和表之间进行映射的框架,使得这种转换更加方便. 1.ORM概念 ...