summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-11-05 02:05:13 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-11-05 02:05:13 +0000
commit7c181b11fb84f77cff84cb5d4d1c70ab825dcc2a (patch)
tree52a6d96c2b7c6e45a2924bc394ee811d5cb384c8
parent936bfb0e506ea5b482b6ac31681016b570a50de6 (diff)
parent1e52197fd0e3d96d0e64cdc109850915e7bbd08c (diff)
downloadMms-7c181b11fb84f77cff84cb5d4d1c70ab825dcc2a.tar.gz
Change-Id: I1110d51402dd5eae65cf478e094ff52d80308340
-rw-r--r--src/com/android/mms/service/MmsService.java61
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;
}