Fix always using carrier package on DSDS

This change makes it so that we actually get the carrier package
associated with the subscription instead of just sending the MMS over
the default package.

Test: tested manually
Bug: 120850686

Change-Id: Ia05be70af7f42f35aaf68204bdaf9940da0919af
diff --git a/src/com/android/mms/service/MmsService.java b/src/com/android/mms/service/MmsService.java
index 9d16d01..ff937ea 100644
--- a/src/com/android/mms/service/MmsService.java
+++ b/src/com/android/mms/service/MmsService.java
@@ -138,11 +138,12 @@
     }
 
     @Nullable
-    private String getCarrierMessagingServicePackageIfExists() {
+    private String getCarrierMessagingServicePackageIfExists(int subId) {
         Intent intent = new Intent(CarrierMessagingService.SERVICE_INTERFACE);
         TelephonyManager telephonyManager =
                 (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
-        List<String> carrierPackages = telephonyManager.getCarrierPackageNamesForIntent(intent);
+        List<String> carrierPackages = telephonyManager.getCarrierPackageNamesForIntentAndPhone(
+                intent, SubscriptionManager.getPhoneId(subId));
 
         if (carrierPackages == null || carrierPackages.size() != 1) {
             return null;
@@ -172,7 +173,8 @@
                     locationUrl, sentIntent, callingPkg, configOverrides, MmsService.this);
 
             final String carrierMessagingServicePackage =
-                    getCarrierMessagingServicePackageIfExists();
+                    getCarrierMessagingServicePackageIfExists(subId);
+
             if (carrierMessagingServicePackage != null) {
                 LogUtil.d(request.toString(), "sending message by carrier app");
                 request.trySendingByCarrierApp(MmsService.this, carrierMessagingServicePackage);
@@ -199,7 +201,8 @@
             final DownloadRequest request = new DownloadRequest(MmsService.this, subId, locationUrl,
                     contentUri, downloadedIntent, callingPkg, configOverrides, MmsService.this);
             final String carrierMessagingServicePackage =
-                    getCarrierMessagingServicePackageIfExists();
+                    getCarrierMessagingServicePackageIfExists(subId);
+
             if (carrierMessagingServicePackage != null) {
                 LogUtil.d(request.toString(), "downloading message by carrier app");
                 request.tryDownloadingByCarrierApp(MmsService.this, carrierMessagingServicePackage);