diff options
author | Abhijith Shastry <ashastry@google.com> | 2016-03-02 11:35:14 -0800 |
---|---|---|
committer | Abhijith Shastry <ashastry@google.com> | 2016-03-02 15:34:27 -0800 |
commit | abb8a5b4d9e3cdf5ffe5140d30552ffc8eb6c991 (patch) | |
tree | f484ce470eba524795a5e85cc2225160e7fab412 | |
parent | 033ab5c9c0bc18d2623cd526bf79ea2d7bb34e21 (diff) | |
download | Mms-abb8a5b4d9e3cdf5ffe5140d30552ffc8eb6c991.tar.gz |
Suppress blocks after sending MMS to emergency services.
BUG: 26989170
Change-Id: Ibe6befb4e460767b78faf8b82f622c79401a28e9
-rw-r--r-- | src/com/android/mms/service/SendRequest.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/android/mms/service/SendRequest.java b/src/com/android/mms/service/SendRequest.java index 37704c8..50d6112 100644 --- a/src/com/android/mms/service/SendRequest.java +++ b/src/com/android/mms/service/SendRequest.java @@ -29,12 +29,15 @@ import android.provider.Telephony; import android.service.carrier.CarrierMessagingService; import android.service.carrier.ICarrierMessagingService; import android.telephony.CarrierMessagingServiceManager; +import android.telephony.PhoneNumberUtils; import android.telephony.SmsManager; import android.text.TextUtils; +import com.android.internal.telephony.AsyncEmergencyContactNotifier; import com.android.internal.telephony.SmsApplication; import com.android.mms.service.exception.MmsHttpException; import com.google.android.mms.MmsException; +import com.google.android.mms.pdu.EncodedStringValue; import com.google.android.mms.pdu.GenericPdu; import com.google.android.mms.pdu.PduHeaders; import com.google.android.mms.pdu.PduParser; @@ -70,6 +73,7 @@ public class SendRequest extends MmsRequest { LogUtil.e(requestId, "MMS network is not ready!"); throw new MmsHttpException(0/*statusCode*/, "MMS network is not ready"); } + notifyIfEmergencyContactNoThrow(); return mmsHttpClient.execute( mLocationUrl != null ? mLocationUrl : apn.getMmscUrl(), mPduData, @@ -82,6 +86,39 @@ public class SendRequest extends MmsRequest { requestId); } + /** + * If the MMS is being sent to an emergency number, the blocked number provider is notified + * so that it can disable number blocking. + */ + private void notifyIfEmergencyContactNoThrow() { + try { + notifyIfEmergencyContact(); + } catch (Exception e) { + LogUtil.w("Error in notifyIfEmergencyContact: ", e); + } + } + + private void notifyIfEmergencyContact() { + final boolean supportContentDisposition = + mMmsConfig.getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION); + GenericPdu parsedPdu = new PduParser(mPduData, supportContentDisposition).parse(); + + if (parsedPdu != null && parsedPdu.getMessageType() == PduHeaders.MESSAGE_TYPE_SEND_REQ) { + SendReq sendReq = (SendReq) parsedPdu; + for (EncodedStringValue encodedStringValue : sendReq.getTo()) { + if (isEmergencyNumber(encodedStringValue.getString())) { + LogUtil.i("Notifying emergency contact."); + new AsyncEmergencyContactNotifier(mContext).execute(); + return; + } + } + } + } + + private boolean isEmergencyNumber(String address) { + return !TextUtils.isEmpty(address) && PhoneNumberUtils.isEmergencyNumber(mSubId, address); + } + @Override protected PendingIntent getPendingIntent() { return mSentIntent; |