diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-11-05 02:05:13 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-11-05 02:05:13 +0000 |
commit | 7c181b11fb84f77cff84cb5d4d1c70ab825dcc2a (patch) | |
tree | 52a6d96c2b7c6e45a2924bc394ee811d5cb384c8 | |
parent | 936bfb0e506ea5b482b6ac31681016b570a50de6 (diff) | |
parent | 1e52197fd0e3d96d0e64cdc109850915e7bbd08c (diff) | |
download | Mms-7c181b11fb84f77cff84cb5d4d1c70ab825dcc2a.tar.gz |
Snap for 5987146 from 1e52197fd0e3d96d0e64cdc109850915e7bbd08c to qt-qpr2-releaseandroid-10.0.0_r36android-10.0.0_r35android-10.0.0_r34android-10.0.0_r33android-10.0.0_r32android-10.0.0_r31android-10.0.0_r30android10-qpr2-s4-releaseandroid10-qpr2-s3-releaseandroid10-qpr2-s2-releaseandroid10-qpr2-s1-releaseandroid10-qpr2-release
Change-Id: I1110d51402dd5eae65cf478e094ff52d80308340
-rw-r--r-- | src/com/android/mms/service/MmsService.java | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/src/com/android/mms/service/MmsService.java b/src/com/android/mms/service/MmsService.java index b255234..27b6b4b 100644 --- a/src/com/android/mms/service/MmsService.java +++ b/src/com/android/mms/service/MmsService.java @@ -192,15 +192,6 @@ public class MmsService extends Service implements MmsRequest.RequestManager { return; } - // Make sure subId has MMS data - if (!getTelephonyManager(subId).isDataEnabledForApn(ApnSetting.TYPE_MMS)) { - LogUtil.w("Subscription with id: " + subId - + " cannot send MMS, data connection is not available"); - sendSettingsIntentForFailedMms(/*isIncoming=*/ false, subId); - sendErrorInPendingIntent(sentIntent); - return; - } - final SendRequest request = new SendRequest(MmsService.this, subId, contentUri, locationUrl, sentIntent, callingPkg, configOverrides, MmsService.this); @@ -210,46 +201,60 @@ public class MmsService extends Service implements MmsRequest.RequestManager { if (carrierMessagingServicePackage != null) { LogUtil.d(request.toString(), "sending message by carrier app"); request.trySendingByCarrierApp(MmsService.this, carrierMessagingServicePackage); - } else { - addSimRequest(request); + return; } + + // Make sure subId has MMS data. We intentionally do this after attempting to send via a + // carrier messaging service as the carrier messaging service may want to handle this in + // a different way and may not be restricted by whether data is enabled for an APN on a + // given subscription. + if (!getTelephonyManager(subId).isDataEnabledForApn(ApnSetting.TYPE_MMS)) { + LogUtil.w("Subscription with id: " + subId + + " cannot send MMS, data connection is not available"); + sendSettingsIntentForFailedMms(/*isIncoming=*/ false, subId); + sendErrorInPendingIntent(sentIntent); + return; + } + + addSimRequest(request); } @Override public void downloadMessage(int subId, String callingPkg, String locationUrl, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent) { + // If the subId is no longer active it could be caused by an MVNO using multiple + // subIds, so we should try to download anyway. + // TODO: Fail fast when downloading will fail (i.e. SIM swapped) LogUtil.d("downloadMessage: " + MmsHttpClient.redactUrlForNonVerbose(locationUrl)); + enforceSystemUid(); // Make sure the subId is correct subId = checkSubId(subId); - // Make sure subId has MMS data - if (!getTelephonyManager(subId).isDataEnabledForApn(ApnSetting.TYPE_MMS)) { - LogUtil.w("Subscription with id: " + subId - + " cannot download MMS, data connection is not available"); - sendSettingsIntentForFailedMms(/*isIncoming=*/ true, subId); - sendErrorInPendingIntent(downloadedIntent); - return; - } - - // If the subId is no longer active it could be caused by - // an MVNO using multiple subIds, so we should try to - // download anyway. - // TODO: Fail fast when downloading will fail (i.e. SIM swapped) - final DownloadRequest request = new DownloadRequest(MmsService.this, subId, locationUrl, contentUri, downloadedIntent, callingPkg, configOverrides, MmsService.this); + final String carrierMessagingServicePackage = getCarrierMessagingServicePackageIfExists(subId); if (carrierMessagingServicePackage != null) { LogUtil.d(request.toString(), "downloading message by carrier app"); request.tryDownloadingByCarrierApp(MmsService.this, carrierMessagingServicePackage); - } else { - addSimRequest(request); + return; } + + // Make sure subId has MMS data + if (!getTelephonyManager(subId).isDataEnabledForApn(ApnSetting.TYPE_MMS)) { + LogUtil.w("Subscription with id: " + subId + + " cannot download MMS, data connection is not available"); + sendSettingsIntentForFailedMms(/*isIncoming=*/ true, subId); + sendErrorInPendingIntent(downloadedIntent); + return; + } + + addSimRequest(request); } public Bundle getCarrierConfigValues(int subId) { @@ -715,7 +720,7 @@ public class MmsService extends Service implements MmsRequest.RequestManager { Telephony.Threads.CONTENT_URI, values, ARCHIVE_CONVERSATION_SELECTION, - new String[] {Long.toString(conversationId)}) != 1) { + new String[]{Long.toString(conversationId)}) != 1) { LogUtil.e("archiveConversation: failed to update database"); return false; } |