SoFunction
Updated on 2025-03-01

Android Mms: Detailed explanation of the use of PDU

The operation of MMS (Multimedia Messaging Service) in Android is done by the MMS protocol partly through the API provided in Frameworks: this package is not open in the SDK and can only be used by internal programs. It encapsulates the API required by all MMSs.
This package is the implementation of the MMS protocol in Android, including some data structures: GenericPdu, MultimediaMessagePdu, SendReq, SendConf, NotificationInd, RetrieveConf, PduHeaders, PduBody, PduPart, etc. Also includes classes that operate on these data: PduPersister, PduParser and PduComposer. PduPersister is mainly used for applications within Android; while PduParser and PduComposer will involve PDU-related protocols and will have mutual influence with MMSC or other platforms (such as whether the packaged byte stream meets the standards, whether it can be successfully parsed and identified by other platforms, etc.)
The function of this packet is to package the multimedia data into PDU format data that can be recognized by standard MMSCs when sent, and parse the PDU data packets for more convenient use by the application. It also provides some storage interfaces, such as saving the PDU to the database and loading the PDU from the database.

Class Purpose
PduPersister Used to manage PDU storage
PduParser Used to parse PDUs
PduComposer Used to generate PDUs

PduPersister: A key method for managing PDU storage:

Return
Method
Description
PduPersister
getPduPersister(Context)
Get the object
Uri
persist(GenericPdu, Uri)
Save a GenericPdu to the database specified by Uri and return the Uri pointing to the newly generated data
GenericPdu
load(Uri)
Load the data referred to by Uri from the database into a GenericPdu object
Uri
move(Uri, Uri)
Move Pdu from one place to another, such as from draft box to outbox, when the MMS has been sent.

Why do we also encapsulate the PDU storage into PduPersister? Because the storage method of PDU is placed in the standard SQLiteDatabase, through TelephonyProvider, and the storage in SQLiteDatabase cannot be stored in a direct PDU byte stream, and the PDU must be disassembled into a readable field. Therefore, the processing of PDU data is involved in the process of storing PDUs and loading PDUs from storage, so it is encapsulated and more convenient to use.
PduParser: used to parse PDU byte streams into Android-recognizable GenericPdu

Return Method Description
PduParser PduParser(byte[]) Construct an object
GenericPdu parse() Parse the PDU byte stream into Android PDU GenericPdu

PduComposer: Package GenericPdu to generate PDU byte stream

Return Method Description
PduComposer PduComposer(Context, GenericPdu) Construct an object
byte[] make() Transfer the GenericPdu into a PDU byte stream