Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cfd01d5 authored by Leland Miller's avatar Leland Miller
Browse files

Ensure permissions granted for correct SIM

This change ensures that the content URI permissions when writing or
reading an MMS are set for the carrier services package for the correct
SIM. Previously we did not specify the SIM, so the permissions would
only be granted to the carrier services package for the default SIM
(which would be whichever SIM is set to default voice).

This is basically a follow-up to b/128542685, which fixed the issue in
MmsService.

Fixes: 133514914
Change-Id: I3190961d53a72c3c14c453fcc32503ed579f5959
Test: Manually verified
parent d75df1b6
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.SystemClock;
import android.os.UserHandle;
import android.service.carrier.CarrierMessagingService;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Slog;

@@ -341,7 +342,8 @@ public class MmsServiceBroker extends SystemService {
            }
            contentUri = adjustUriForUserAndGrantPermission(contentUri,
                    CarrierMessagingService.SERVICE_INTERFACE,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    Intent.FLAG_GRANT_READ_URI_PERMISSION,
                    subId);
            getServiceGuarded().sendMessage(subId, callingPkg, contentUri, locationUrl,
                    configOverrides, sentIntent);
        }
@@ -360,7 +362,8 @@ public class MmsServiceBroker extends SystemService {
            }
            contentUri = adjustUriForUserAndGrantPermission(contentUri,
                    CarrierMessagingService.SERVICE_INTERFACE,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                    Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION,
                    subId);

            getServiceGuarded().downloadMessage(subId, callingPkg, locationUrl, contentUri,
                    configOverrides, downloadedIntent);
@@ -501,7 +504,7 @@ public class MmsServiceBroker extends SystemService {
         * @return The adjusted Uri containing the calling userId.
         */
        private Uri adjustUriForUserAndGrantPermission(Uri contentUri, String action,
                int permission) {
                int permission, int subId) {
            final Intent grantIntent = new Intent();
            grantIntent.setData(contentUri);
            grantIntent.setFlags(permission);
@@ -522,8 +525,9 @@ public class MmsServiceBroker extends SystemService {
                Intent intent = new Intent(action);
                TelephonyManager telephonyManager =
                        (TelephonyManager) mContext.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) {
                    LocalServices.getService(UriGrantsManagerInternal.class)
                            .grantUriPermissionFromIntent(callingUid, carrierPackages.get(0),