summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShishir Agrawal <shishir@google.com>2014-12-10 10:17:05 -0800
committerCheuksan Wang <edwang@google.com>2015-03-25 17:47:52 -0700
commitd78cb30b2244be989ba6566d6c72563d56780c04 (patch)
tree1089784039491d2498cff32566adf641b5f9b9f2
parent77ee8480374b1e5a7dc5a0eed49ac80ddc6af3e5 (diff)
downloadandroid_packages_services_Mms-d78cb30b2244be989ba6566d6c72563d56780c04.tar.gz
android_packages_services_Mms-d78cb30b2244be989ba6566d6c72563d56780c04.tar.bz2
android_packages_services_Mms-d78cb30b2244be989ba6566d6c72563d56780c04.zip
Fail SmsManager requests if SubId is not active.
If subId is not active, expected subIds can be assigned to the messages being processed due to SmsManager calls. The change will fail any SmsManager calls if SubId is not active. Bug: 18629526 Change-Id: I77aab323352347dcb296ad842adfd486fc89a622
-rw-r--r--src/com/android/mms/service/MmsService.java35
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 8c31e71..17c4a34 100644
--- a/src/com/android/mms/service/MmsService.java
+++ b/src/com/android/mms/service/MmsService.java
@@ -184,8 +184,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);
@@ -205,8 +213,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 =
@@ -358,6 +374,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) {
+ }
+ }
+ }
};
// Running request queues, one thread per queue