Snap for 5987242 from 1e52197fd0e3d96d0e64cdc109850915e7bbd08c to qt-d4-release
Change-Id: I8ed5fb665f998109010f56f4fea8674517de99c9
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 @@
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,21 +201,50 @@
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);
+ 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);
+ return;
+ }
+
// Make sure subId has MMS data
if (!getTelephonyManager(subId).isDataEnabledForApn(ApnSetting.TYPE_MMS)) {
LogUtil.w("Subscription with id: " + subId
@@ -234,22 +254,7 @@
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);
- }
+ addSimRequest(request);
}
public Bundle getCarrierConfigValues(int subId) {
@@ -715,7 +720,7 @@
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;
}