diff options
author | Prerepa Viswanadham <dham@google.com> | 2015-05-05 01:05:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-05 01:07:21 +0000 |
commit | 96069ef72d77e1a01b3404fdfe6af9a13cacabda (patch) | |
tree | 5c08e067bdbcc17fed25dfcf98c9ea5c3d4a9816 | |
parent | c833674670d8aee6047c371870431d029b41c6b2 (diff) | |
parent | f530063c0d23a722b2ad3706a9de92e02e5ee442 (diff) | |
download | android_packages_services_Mms-96069ef72d77e1a01b3404fdfe6af9a13cacabda.tar.gz android_packages_services_Mms-96069ef72d77e1a01b3404fdfe6af9a13cacabda.tar.bz2 android_packages_services_Mms-96069ef72d77e1a01b3404fdfe6af9a13cacabda.zip |
Merge "Merge commit '2dbe575' into master_merge" into mnc-dev
-rw-r--r-- | src/com/android/mms/service/MmsService.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/android/mms/service/MmsService.java b/src/com/android/mms/service/MmsService.java index eb6065f..dd01f30 100644 --- a/src/com/android/mms/service/MmsService.java +++ b/src/com/android/mms/service/MmsService.java @@ -161,8 +161,16 @@ public class MmsService extends Service implements MmsRequest.RequestManager { throws RemoteException { Log.d(TAG, "sendMessage"); enforceSystemUid(); + // Make sure the subId is correct subId = checkSubId(subId); + + // Make sure the subId is active + if (!isActiveSubId(subId)) { + sendErrorInPendingIntent(sentIntent); + return; + } + final SendRequest request = new SendRequest(MmsService.this, subId, contentUri, locationUrl, sentIntent, callingPkg, configOverrides); @@ -182,8 +190,16 @@ public class MmsService extends Service implements MmsRequest.RequestManager { PendingIntent downloadedIntent) throws RemoteException { Log.d(TAG, "downloadMessage: " + MmsHttpClient.redactUrlForNonVerbose(locationUrl)); enforceSystemUid(); + // Make sure the subId is correct subId = checkSubId(subId); + + // Make sure the subId is active + if (!isActiveSubId(subId)) { + sendErrorInPendingIntent(downloadedIntent); + return; + } + final DownloadRequest request = new DownloadRequest(MmsService.this, subId, locationUrl, contentUri, downloadedIntent, callingPkg, configOverrides); final String carrierMessagingServicePackage = @@ -335,6 +351,25 @@ public class MmsService extends Service implements MmsRequest.RequestManager { Log.d(TAG, "getAutoPersisting"); return getAutoPersistingPref(); } + + /* + * @return true if the subId is active. + */ + private boolean isActiveSubId(int subId) { + return SubscriptionManager.from(MmsService.this).isActiveSubId(subId); + } + + /* + * Calls the pending intent with <code>MMS_ERROR_NO_DATA_NETWORK</code>. + */ + private void sendErrorInPendingIntent(@Nullable PendingIntent intent) { + if (intent != null) { + try { + intent.send(SmsManager.MMS_ERROR_NO_DATA_NETWORK); + } catch (PendingIntent.CanceledException ex) { + } + } + } }; @Override |