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

Commit 49345a99 authored by Leland Miller's avatar Leland Miller Committed by Android (Google) Code Review
Browse files

Merge "Ensure permissions granted for correct SIM"

parents 880190e1 02c8524e
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),