彩信发送流程

27 篇文章 1 订阅
23 篇文章 2 订阅

 发送彩信基本流程:

Log分析:

study_message: sendMessage

study_message: WorkingMessage_send:recipientsInUI=18862631722,subId=1

study_message: WorkingMessage_sendMmsWorker,mmsUri:content://mms/drafts/11

study_message: dest[0]:18862631722

study_message: before_mmsUri:content://mms/drafts/11

study_message: totalPendingSize:0

study_message: WorkingMessage_mmsUri_getMessageUri:content://mms/drafts/11

study_message: __WorkingMessage_mmsUri:content://mms/drafts/11

study_message: MmsMessageSender_sendMessage:1

study_message: MmsMessageSender_messageId:11

study_message: intent:Intent { cmp=com.android.mms/.transaction.TransactionService },flags:0,startId:1

study_message: msg_EVENT_NEW_INTENT:5

study_message: TransactionService_handleMessage_obj:Intent { cmp=com.android.mms/.transaction.TransactionService },msg.arg1:1

study_message: TransactionService_action:null

study_message: Scan database to find all pending operations

study_message: TransactionService_transactionType:2

study_message: TransactionService_default

study_message: TransactionService_serviceId:1-->launchTransaction

study_message: zy_launchTransaction_serviceId:1,noNetwork:false,subId:1,txnBundle:transactionType: 2 uri: content://mms/11 pushData: null mmscUrl: null proxyAddress: null proxyPort: 0

study_message: SendTransaction_serviceId:1,mmsc:null,args.getUri:content://mms/11,subId:1

study_message: intent:Intent { act=com.android.mms.transaction.TRANSACION_PROCESSED dat=content://mms/11 flg=0x10 cmp=com.android.mms/.transaction.TransactionService (has extras) },flags:0,startId:2

 

 

 

发送彩信的解析

 

W:\Android8.1_intergration_2\vendor\mediatek\proprietary\frameworks\opt\telephony\src\java\com\mediatek\android\mms\pdu\MtkPduPersister.java

 

 

 

 

对于发送的彩信,彩信在编辑保存草稿时,转化为PDU包,再通过PduPersister将PDUDATA保存到数据库中。这句话应该理解为比如:拍摄了一张照片,显示到彩信展示列表中时,(即彩信编辑草稿时,转化为PDU,PduPersister将PDUDATA保存到数据库中)。

在pdu表中msg_box字段的含义:

msg_box: 区分彩信的收件箱,发件箱,草稿箱等.

很明显1.代表收件箱 2代表收件箱 3.代表草稿箱

 

由上面的图中显示,pdu表中,msg_box的字段值分别是2、3、3、1,分别表示已发送,草稿箱,收件箱。 其实还有一个 4表示发件箱,表示还没有发送。

 

W:\Android8.1_intergration_2\frameworks\opt\telephony\src\java\com\google\android\mms\pdu\PduPersister.java

 

/* MTK Change access type */

protected static final HashMap<Uri, Integer> MESSAGE_BOX_MAP;

 

static {

MESSAGE_BOX_MAP = new HashMap<Uri, Integer>();

MESSAGE_BOX_MAP.put(Mms.Inbox.CONTENT_URI, Mms.MESSAGE_BOX_INBOX);

MESSAGE_BOX_MAP.put(Mms.Sent.CONTENT_URI, Mms.MESSAGE_BOX_SENT);

MESSAGE_BOX_MAP.put(Mms.Draft.CONTENT_URI, Mms.MESSAGE_BOX_DRAFTS);

MESSAGE_BOX_MAP.put(Mms.Outbox.CONTENT_URI, Mms.MESSAGE_BOX_OUTBOX);

}

 

 

 

//sendMessage中通过MtkPduPersister的move方法构建并返回发送uri(sendUri)。
/**
 * Move a PDU object from one location to another.
 *(将PDU对象从一个位置移动到另一个位置。)
 * @param from Specify the PDU object to be moved.
 * @param to The destination location, should be one of the following:
 *        "content://mms/inbox", "content://mms/sent",
 *        "content://mms/drafts", "content://mms/outbox",
 *        "content://mms/trash".
 * @return New Uri of the moved PDU.
 * @throws MmsException Error occurred while moving the message.
 */
public Uri move(Uri from, Uri to) throws MmsException {
    // Check whether the 'msgId' has been assigned a valid value.
//传入from参数的目的是从uri中获取msgId。
    long msgId = ContentUris.parseId(from);
    if (msgId == -1L) {
        throw new MmsException("Error! ID of the message: -1.");
    }

    // Get corresponding int value of destination box.
//HashMap<Uri, Integer> MESSAGE_BOX_MAP;中存放了以uri为key,以Integer为值(msg_box中的值)的键值对。
    Integer msgBox = MESSAGE_BOX_MAP.get(to);
    if (msgBox == null) {
        throw new MmsException(
                "Bad destination, must be one of "
                + "content://mms/inbox, content://mms/sent, "
                + "content://mms/drafts, content://mms/outbox, "
                + "content://mms/temp.");
    }

    ContentValues values = new ContentValues(1);
    values.put(Mms.MESSAGE_BOX, msgBox);
    SqliteWrapper.update(mContext, mContentResolver, from, values, null, null);
    return ContentUris.withAppendedId(to, msgId);
}

发送一些彩信前的操作如下: 

//这个是彩信保存为草稿时的ContentValues信息,从现象上看应该是msg_box字段初始时设置为2,应该是在sql语句中默认处理的。

study_message:

values:date=1538030917

thread_id=1

m_size=120

v=18

ct_t=application/vnd.wap.multipart.related

need_notify=false

tr_id=T16619c95902

text_only=1

m_type=128

W:\Android8.1_intergration_2\vendor\mediatek\proprietary\packages\apps\Mms\src\com\android\mms\transaction\SendTransaction.java





/**(返回给定{@link文件}的内容URI。)

* Return a content URI for a given {@link File}. Specific temporary

* permissions for the content URI can be set with

* {@link Context#grantUriPermission(String, Uri, int)}, or added

* to an {@link Intent} by calling {@link Intent#setData(Uri) setData()} and then

* {@link Intent#setFlags(int) setFlags()}; in both cases, the applicable flags are

* {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} and

* {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}. A FileProvider can only return a

* <code>content</code> {@link Uri} for file paths defined in their <code>&lt;paths&gt;</code>

* meta-data element. See the Class Overview for more information.

*

* @param context A {@link Context} for the current component.

* @param authority The authority of a {@link FileProvider} defined in a

* {@code <provider>} element in your app's manifest.

* @param file A {@link File} pointing to the filename for which you want a

* <code>content</code> {@link Uri}.

* @return A content URI for the file.

* @throws IllegalArgumentException When the given {@link File} is outside

* the paths supported by the provider.

*/

public static Uri getUriForFile(Context context, String authority, File file) {

final PathStrategy strategy = getPathStrategy(context, authority);

return strategy.getUriForFile(file);

}

Log分析:

 

study_message: ComposeMessageActivity_addImageAsync_uri:file:///storage/emulated/0/Android/data/com.android.mms/cache/.temp.jpg,append:true

study_message: ComposeMessage_addImageAsync_addImage

study_message: zy_addImage_uri:file:///storage/emulated/0/Android/data/com.android.mms/cache/.temp.jpg,append:true

study_message: MessageUtils_imageUri:file:///storage/emulated/0/Android/data/com.android.mms/cache/.temp.jpg,append:true,showToast:true

study_message: MessageUtils_part:com.google.android.mms.pdu.PduPart@18d4ae0

study_message: ResizeImageResultCallback_onResizeResult_messageUri:null

study_message: WorkingMessage.saveAsMms:null

study_message: WorkingMessage_saveAsMms:com.android.mms.ui.ComposeMessageActivity$14.onResizeResult:7176 com.android.mms.ui.MessageUtils.resizeImage:1307 com.android.mms.ui.ComposeMessageActivity.addImage:7413 com.android.mms.ui.ComposeMessageActivity.-wrap29:0 com.android.mms.ui.ComposeMessageActivity$73.run:7356 com.android.mms.ui.AsyncDialog$ModalDialogAsyncTask.doInBackground:178 com.android.mms.ui.AsyncDialog$ModalDialogAsyncTask.doInBackground:170 android.os.AsyncTask$2.call:333 java.util.concurrent.FutureTask.run:266 android.os.AsyncTask$SerialExecutor$1.run:245

study_message: WorkingMessage_saveAsMms_start_saveDraft

study_message: saveDraft_DraftManager.SYNC_SAVE_ACTION:16,threadId:1,mMessageUri:null

study_message: DraftManager_saveDraft_type:16,threadId:1,uri:null

study_message: DraftManager.getDraftTask:type:16,threadId:1

study_message: DraftManager dt:com.android.mms.draft.DraftTask@775c936

study_message: SaveReq_executeReq_mMessageUri:null(SaveReq.executeReq-->createDraftMmsMessage)

study_message: executeReq:com.android.mms.draft.DraftTask$TaskThread.run:254 <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack>

study_message: SaveReq_mMessageUri:null

study_message: DraftAction->createDraftMmsMessage:preUri:null

(DraftAction --> createDraftMmsMessage)

study_message: persist_pdu:com.mediatek.android.mms.pdu.MtkSendReq@e6219a4,uri:content://mms/drafts (MtkPduPersister.java)

study_message: WorkingMessage_saveAsMms:com.android.mms.ui.ComposeMessageActivity$14.onResizeResult:7236 com.android.mms.ui.MessageUtils.resizeImage:1307 com.android.mms.ui.ComposeMessageActivity.addImage:7413 com.android.mms.ui.ComposeMessageActivity.-wrap29:0 com.android.mms.ui.ComposeMessageActivity$73.run:7356 com.android.mms.ui.AsyncDialog$ModalDialogAsyncTask.doInBackground:178 com.android.mms.ui.AsyncDialog$ModalDialogAsyncTask.doInBackground:170 android.os.AsyncTask$2.call:333 java.util.concurrent.FutureTask.run:266 android.os.AsyncTask$SerialExecutor$1.run:245

study_message: WorkingMessage_saveAsMms_start_saveDraft

study_message: saveDraft_DraftManager.SYNC_SAVE_ACTION:16,threadId:1,mMessageUri:content://mms/drafts/1

study_message: DraftManager_saveDraft_type:16,threadId:1,uri:content://mms/drafts/1

study_message: DraftManager.getDraftTask:type:16,threadId:1

study_message: DraftManager dt:com.android.mms.draft.DraftTask@aacf93c

study_message: SaveReq_executeReq_mMessageUri:content://mms/drafts/1(SaveReq.executeReq-->updateDraftMmsMessage)

study_message: executeReq:com.android.mms.draft.DraftTask$TaskThread.run:254 <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack> <bottom of call stack>

study_message: SaveReq_mMessageUri:content://mms/drafts/1

study_message: ComposeMessage_addImage_after_mNeedSaveAsMms:false(从这一行log可以看出这行Log以上都是ComposeMessageActivity的addImage方法)

 

 

 

 

 

 

 

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值