只有default AP才有权限去读写数据库,如果非default AP去发送彩信,发送完后Framework会将这条短信写入数据库
KK之前的版本,如果三方Apk去发送短信,只要这个apk不将该短信内容写入数据库就不会显示。
kk之后的版本,如果三方APK去发送短信,虽然这个apk不将该短信内容写入数据库,但由于它并不是default AP,发送完后framework会检测到这种情况然后将该短信写入数据库
Android开发之Android5.1.1(CM12.1)源码中短信发送流程解析
http://blog.csdn.net/poison_h/article/details/50972149
GsmSMSDispatcher.java
/** {@inheritDoc} */
@VisibleForTesting
@Override
public void sendText(String destAddr, String scAddr, String text, PendingIntent sentIntent,
PendingIntent deliveryIntent, Uri messageUri, String callingPkg,
boolean persistMessage, int priority, boolean isExpectMore, int validityPeriod) {
SmsMessage.SubmitPdu pdu = SmsMessage.getSubmitPdu(
scAddr, destAddr, text, (deliveryIntent != null), validityPeriod);
if (pdu != null) {
HashMap map = getSmsTrackerMap(destAddr, scAddr, text, pdu);
SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent, getFormat(),
messageUri, false /*isExpectMore*/, text /*fullMessageText*/, true /*isText*/,
validityPeriod, persistMessage);
String carrierPackage = getCarrierAppPackageName();
if (carrierPackage != null) {
Rlog.d(TAG, "Found carrier package.");
TextSmsSender smsSender = new TextSmsSender(tracker);
smsSender.sendSmsByCarrierApp(carrierPackage, new SmsSenderCallback(smsSender));
} else {
Rlog.v(TAG, "No carrier package.");
sendRawPdu(tracker);
}
} else {
Rlog.e(TAG, "GsmSMSDispatcher.sendText(): getSubmitPdu() returned null");
}
}
/** {@inheritDoc} */
@Override
protected void sendSmsByPstn(SmsTracker tracker) {
int ss = mPhone.getServiceState().getState();
// if sms over IMS is not supported on data and voice is not available...
if (!isIms() && ss != ServiceState.STATE_IN_SERVICE) {
tracker.onFailed(mContext, getNotInServiceError(ss), 0/*errorCode*/);
return;
}
HashMap<String, Object> map = tracker.getData();
byte smsc[] = (byte[]) map.get("smsc");
byte[] pdu = (byte[]) map.get("pdu");
Message reply = obtainMessage(EVENT_SEND_SMS_COMPLETE, tracker);
// sms over gsm is used:
// if sms over IMS is not supported AND
// this is not a retry case after sms over IMS failed
// indicated by mImsRetry > 0
if (0 == tracker.mImsRetry && !isIms()) {