Wap push parsing (3) -- implemented in Android

Source: Internet
Author: User

Tian haili @ csdn

2012-06-30

 

Android has implemented sms pdu parsing and WSP parsing, obtained wbxml encapsulated data, and broadcast "android. provider. telephony. wap_push_received ". In the native implementation, there is no response to the broadcast where the mimetype type is wap push Si and wap push sl. That is, the processing of the push data encapsulated by wbxml is missing. This article analyzes and summarizes the native Implementation of Android and provides the implementation reference of wap push Si/SL.

 

1. Native implementation in Android

I have already published several articles describing the process of receiving and processing SMS separately, the Encapsulation Format of SMS PDU/WSP/wbxml.

  • The SMS receiving process in Android focuses on the description of the SMS receiving process;
  • Wap push parsing (1)-sms pdu Code focuses on the PDU Encapsulation Format;
  • Wap push parsing (2) -- WSP and wbxml encoding describes the encapsulation of WSP and wbxml.

 

Here is a summary:

  1. RIL receives new SMS, calls Android. telephony. smsmessage. newfromcmt () decode PDU, and puts the result in smessage. Android. telephony. smsmessage. newfromcmt () uses COM. android. internal. telephony. GSM. smsmessage or com. android. internal. telephony. CDMA. the newfromcmt () of smsmessage implements PDU decode;
  2. Run the dispatchmessage () command of smsdispatcher (Implementation class: gsmsmsdispatcher/cdmasmsdispatcher) to send the message MSG. Wappushoversms: dispatchwappdu () is used to process information with the target port and the target port is wap push (smsheader. port_wap_push;
  3. Wappushoversms: dispatchwappdu () parses WSP and obtains the MIME type: Service indication (SI) of the corresponding contenttype as "application/vnd. WAP. sic "; service load (SL) is" application/vnd. WAP. SLC ". For Si and SL types, call dispatchwappdu_default ().

The following is the implementation of dispatchwappdu_default:

    private void dispatchWapPdu_default(byte[]pdu, int transactionId, int pduType,                                        StringmimeType, int headerStartIndex, int headerLength) {        byte[] header = new byte[headerLength];        System.arraycopy(pdu, headerStartIndex,header, 0, header.length);        int dataIndex = headerStartIndex +headerLength;        byte[] data;         data = new byte[pdu.length -dataIndex];        System.arraycopy(pdu, dataIndex, data,0, data.length);         Intent intent = newIntent(Intents.WAP_PUSH_RECEIVED_ACTION);        intent.setType(mimeType);        intent.putExtra("transactionId", transactionId);        intent.putExtra("pduType",pduType);        intent.putExtra("header",header);        intent.putExtra("data",data);         mSmsDispatcher.dispatch(intent,"android.permission.RECEIVE_WAP_PUSH");    }

The above are all processed in the framework. We can see that the wbxml encapsulated data of Si/SL has been parsed in the framework and broadcast has been broadcast. Next, it is the work of the application layer to process the specific business of the mimetype identity. The value of mimetype is "application/vnd. WAP. sic "(SI) and" application/vnd. WAP. SLC "(SL) wap_push_received processing is not implemented in the native Implementation of Android.

Follow the intent parameter of the broadcast:

  • Mimetype: "application/vnd. WAP. Sic" or application/vnd. WAP. SLC ";
  • Header: the header parsed by WSP. It is used to identify contenttype and has mimetype. This is meaningless;
  • Data: The Si or sl xml data encapsulated by wbxml.

 

To implement a complete wap push, As long:

  • Implement wap_push_received for "application/vnd. WAP. Sic" (SI) and "application/vnd. WAP. SLC" (SL;
  • The received broadcast parses wbxml-encapsulated Si/SL and inserts it into the message library.

See the implementation of wap_push_received processing for the "Application/vnd. WAP. MMS-message" (MMS) type in MMs.

 

2. Process "android. provider. telephony. wap_push_received"

 

To process "android. provider. telephony. wap_push_received ", defines the broardcastreceiver implementation class wappushreceiver, and in androidmanifest. add "application/vnd. WAP. sic "(SI) and" application/vnd. WAP. the declaration of wap_push_received processing of SLC "(SL) type.

        <receiver android:name=".transaction.WapPushReceiver"           android:permission="android.permission.BROADCAST_WAP_PUSH">           <intent-filter>                <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />                <data android:mimeType="application/vnd.wap.sic" />                <data android:mimeType="application/vnd.wap.slc" />           </intent-filter>        </receiver>

Iii. wappushreceiver parsing wbxml

You can refer to the native implementation of the pushcycler processing in MMS and do the following:

  1. The onreceive () of the wappushreceiver obtains the wbxml-encapsulated pushdata through the "data" parameter of the intent;
  2. Start asynctask to parse wbxml-encapsulated pushdata in the background and parse the pushdata (XML format );
  3. Parse pushdata in XML format to obtain URL, content, signal, and other information;
  4. Based on the result of 3, select to join the message database and notify the user.

HereKey PointsIt is parsed in wbxml format. You can refer to the patch for receiving wap push messages from miui Rom. This is the implementation of wap push parsing for Xiaomi mobile phones. The source code for wbxml Parsing is available for reference. However, the tag and attribute defined in wbxml are not fully supported. You can add the required support as needed.

 

References

1. Google Android source2.3.7 _ r1

Android native source code

2. WAP binary xmlcontent format

Wbxml standard. required!

3. miui Rom receives the patch of WAP PUSH SMS

The wappush parsing implementation on Android has the source code, but the parsing is incomplete.

4. wap push over sms

Overview of wap push over sms)

5. wap push sms Encoding

Wap push Service indication encapsulation instance (English)

6. Sending SMS wappush messages using the activexperts smsand MMS Toolkit

The tool that sends wap push. Is the usage instructions, although there is no implementation details, but you can refer to wbxml token and attribute comparison. (English)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.