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

Commit b36bcc88 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Pipe through attributeTag for one SMS permission check

Bug: 136595429
Test: TH
Change-Id: I99635efd0da5e72c3df9c6383779a059bbe3c1d1
Merged-In: I346ac2d3acad0e0d18b298f89f0b96324fc52333
parent e8640349
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9170,7 +9170,8 @@ package android.telephony {
    method public boolean enableCellBroadcastRange(int, int, int);
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_MESSAGES_ON_ICC) public java.util.List<android.telephony.SmsMessage> getMessagesFromIcc();
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSmsCapacityOnIcc();
    method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String);
    method @Deprecated public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String);
    method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String, @Nullable String);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List<java.lang.String>, java.util.List<android.app.PendingIntent>, java.util.List<android.app.PendingIntent>);
  }
+2 −1
Original line number Diff line number Diff line
@@ -3227,7 +3227,8 @@ package android.telephony {

  public final class SmsManager {
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int checkSmsShortCodeDestination(String, String);
    method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String);
    method @Deprecated public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String);
    method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String, @Nullable String);
    field public static final int SMS_CATEGORY_FREE_SHORT_CODE = 1; // 0x1
    field public static final int SMS_CATEGORY_NOT_SHORT_CODE = 0; // 0x0
    field public static final int SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE = 3; // 0x3
+37 −20
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ public final class SmsManager {
            String destinationAddress, String scAddress, String text,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                true /* persistMessage*/, null);
                true /* persistMessage*/, null, null);
    }

    /**
@@ -507,7 +507,7 @@ public final class SmsManager {

    private void sendTextMessageInternal(String destinationAddress, String scAddress,
            String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
            boolean persistMessage, String packageName) {
            boolean persistMessage, String packageName, String attributionTag) {
        if (TextUtils.isEmpty(destinationAddress)) {
            throw new IllegalArgumentException("Invalid destinationAddress");
        }
@@ -532,7 +532,7 @@ public final class SmsManager {
                public void onSuccess(int subId) {
                    ISms iSms = getISmsServiceOrThrow();
                    try {
                        iSms.sendTextForSubscriber(subId, packageName,
                        iSms.sendTextForSubscriber(subId, packageName, attributionTag,
                                destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                                persistMessage);
                    } catch (RemoteException e) {
@@ -552,7 +552,7 @@ public final class SmsManager {
            // visible to the user.
            ISms iSms = getISmsServiceOrThrow();
            try {
                iSms.sendTextForSubscriber(getSubscriptionId(), packageName,
                iSms.sendTextForSubscriber(getSubscriptionId(), packageName, attributionTag,
                        destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                        persistMessage);
            } catch (RemoteException e) {
@@ -599,7 +599,7 @@ public final class SmsManager {
            String destinationAddress, String scAddress, String text,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                false /* persistMessage */, null);
                false /* persistMessage */, null, null);
    }

    private void sendTextMessageInternal(
@@ -882,7 +882,24 @@ public final class SmsManager {
            String destinationAddress, String scAddress, ArrayList<String> parts,
            ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
                deliveryIntents, true /* persistMessage*/, null);
                deliveryIntents, true /* persistMessage*/, null, null);
    }

    /**
     * @deprecated Use {@link #sendMultipartTextMessage(String, String, List, List, List, String,
     * String)} instead.
     *
     * @hide
     */
    @Deprecated
    @SystemApi
    @TestApi
    public void sendMultipartTextMessage(
            @NonNull String destinationAddress, @NonNull String scAddress,
            @NonNull List<String> parts, @Nullable List<PendingIntent> sentIntents,
            @Nullable List<PendingIntent> deliveryIntents, @NonNull String packageName) {
        sendMultipartTextMessage(destinationAddress, scAddress, parts, sentIntents, deliveryIntents,
                packageName, null);
    }

    /**
@@ -909,15 +926,16 @@ public final class SmsManager {
    public void sendMultipartTextMessage(
            @NonNull String destinationAddress, @NonNull String scAddress,
            @NonNull List<String> parts, @Nullable List<PendingIntent> sentIntents,
            @Nullable List<PendingIntent> deliveryIntents, @NonNull String packageName) {
            @Nullable List<PendingIntent> deliveryIntents, @NonNull String packageName,
            @Nullable String attributionTag) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
                deliveryIntents, true /* persistMessage*/, packageName);
                deliveryIntents, true /* persistMessage*/, packageName, attributionTag);
    }

    private void sendMultipartTextMessageInternal(
            String destinationAddress, String scAddress, List<String> parts,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents,
            boolean persistMessage, String packageName) {
            boolean persistMessage, String packageName, String attributionTag) {
        if (TextUtils.isEmpty(destinationAddress)) {
            throw new IllegalArgumentException("Invalid destinationAddress");
        }
@@ -942,7 +960,7 @@ public final class SmsManager {
                    public void onSuccess(int subId) {
                        try {
                            ISms iSms = getISmsServiceOrThrow();
                            iSms.sendMultipartTextForSubscriber(subId, packageName,
                            iSms.sendMultipartTextForSubscriber(subId, packageName, attributionTag,
                                    destinationAddress, scAddress, parts, sentIntents,
                                    deliveryIntents, persistMessage);
                        } catch (RemoteException e) {
@@ -963,8 +981,8 @@ public final class SmsManager {
                    ISms iSms = getISmsServiceOrThrow();
                    if (iSms != null) {
                        iSms.sendMultipartTextForSubscriber(getSubscriptionId(), packageName,
                                destinationAddress, scAddress, parts, sentIntents, deliveryIntents,
                                persistMessage);
                                attributionTag, destinationAddress, scAddress, parts, sentIntents,
                                deliveryIntents, persistMessage);
                    }
                } catch (RemoteException e) {
                    Log.e(TAG, "sendMultipartTextMessageInternal: Couldn't send SMS - "
@@ -982,7 +1000,7 @@ public final class SmsManager {
                deliveryIntent = deliveryIntents.get(0);
            }
            sendTextMessageInternal(destinationAddress, scAddress, parts.get(0),
                    sentIntent, deliveryIntent, true, packageName);
                    sentIntent, deliveryIntent, true, packageName, attributionTag);
        }
    }

@@ -1012,7 +1030,7 @@ public final class SmsManager {
            String destinationAddress, String scAddress, List<String> parts,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
                deliveryIntents, false /* persistMessage*/, null);
                deliveryIntents, false /* persistMessage*/, null, null);
    }

    /**
@@ -1174,7 +1192,7 @@ public final class SmsManager {
                            ISms iSms = getISmsServiceOrThrow();
                            if (iSms != null) {
                                iSms.sendMultipartTextForSubscriberWithOptions(subId,
                                        null, destinationAddress,
                                        null, null, destinationAddress,
                                        scAddress, parts, sentIntents, deliveryIntents,
                                        persistMessage, finalPriority, expectMore, finalValidity);
                            }
@@ -1196,7 +1214,7 @@ public final class SmsManager {
                    ISms iSms = getISmsServiceOrThrow();
                    if (iSms != null) {
                        iSms.sendMultipartTextForSubscriberWithOptions(getSubscriptionId(),
                                null, destinationAddress,
                                null, null, destinationAddress,
                                scAddress, parts, sentIntents, deliveryIntents,
                                persistMessage, finalPriority, expectMore, finalValidity);
                    }
@@ -1327,9 +1345,8 @@ public final class SmsManager {
            public void onSuccess(int subId) {
                try {
                    ISms iSms = getISmsServiceOrThrow();
                    iSms.sendDataForSubscriber(subId, null,
                            destinationAddress, scAddress, destinationPort & 0xFFFF, data,
                            sentIntent, deliveryIntent);
                    iSms.sendDataForSubscriber(subId, null, null, destinationAddress, scAddress,
                            destinationPort & 0xFFFF, data, sentIntent, deliveryIntent);
                } catch (RemoteException e) {
                    Log.e(TAG, "sendDataMessage: Couldn't send SMS - Exception: " + e.getMessage());
                    notifySmsError(sentIntent, RESULT_REMOTE_EXCEPTION);
@@ -1481,7 +1498,7 @@ public final class SmsManager {
            // it here because we do not have access to the activity context that is performing this
            // operation.
            // Requires that the calling process has the SEND_SMS permission.
            getITelephony().enqueueSmsPickResult(null,
            getITelephony().enqueueSmsPickResult(null, null,
                    new IIntegerConsumer.Stub() {
                        @Override
                        public void accept(int subId) {
+17 −14
Original line number Diff line number Diff line
@@ -86,9 +86,9 @@ interface ISms {
     *  raw pdu of the status report is in the extended data ("pdu").
     * @param subId the subId id.
     */
    void sendDataForSubscriber(int subId, String callingPkg, in String destAddr,
            in String scAddr, in int destPort, in byte[] data, in PendingIntent sentIntent,
            in PendingIntent deliveryIntent);
    void sendDataForSubscriber(int subId, String callingPkg, String callingattributionTag,
            in String destAddr, in String scAddr, in int destPort,in byte[] data,
            in PendingIntent sentIntent, in PendingIntent deliveryIntent);

    /**
     * Send an SMS.
@@ -118,8 +118,8 @@ interface ISms {
     *   by a non-default SMS app. Currently only the carrier app can set this
     *   parameter to false to skip auto message persistence.
     */
    void sendTextForSubscriber(in int subId, String callingPkg, in String destAddr,
            in String scAddr, in String text, in PendingIntent sentIntent,
    void sendTextForSubscriber(in int subId, String callingPkg, String callingAttributionTag,
            in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent,
            in PendingIntent deliveryIntent, in boolean persistMessageForNonDefaultSmsApp);

    /**
@@ -217,7 +217,7 @@ interface ISms {
     *   parameter to false to skip auto message persistence.
     */
    void sendMultipartTextForSubscriber(in int subId, String callingPkg,
            in String destinationAddress, in String scAddress,
            String callingAttributionTag, in String destinationAddress, in String scAddress,
            in List<String> parts, in List<PendingIntent> sentIntents,
            in List<PendingIntent> deliveryIntents, in boolean persistMessageForNonDefaultSmsApp);

@@ -266,10 +266,10 @@ interface ISms {
     *  Any Other values included Negative considered as Invalid Validity Period of the message.
     */
    void sendMultipartTextForSubscriberWithOptions(in int subId, String callingPkg,
            in String destinationAddress, in String scAddress, in List<String> parts,
            in List<PendingIntent> sentIntents, in List<PendingIntent> deliveryIntents,
            in boolean persistMessageForNonDefaultSmsApp, in int priority, in boolean expectMore,
            in int validityPeriod);
            String callingAttributionTag, in String destinationAddress, in String scAddress,
            in List<String> parts, in List<PendingIntent> sentIntents,
            in List<PendingIntent> deliveryIntents, in boolean persistMessageForNonDefaultSmsApp,
            in int priority, in boolean expectMore, in int validityPeriod);

    /**
     * Enable reception of cell broadcast (SMS-CB) messages with the given
@@ -427,6 +427,7 @@ interface ISms {
     *
     * @param subId the SIM id.
     * @param callingPkg the package name of the calling app
     * @param callingAttributionTag the attribution tag of calling context
     * @param messageUri the URI of the stored message
     * @param scAddress is the service center address or null to use the current default SMSC
     * @param sentIntent if not NULL this <code>PendingIntent</code> is
@@ -446,8 +447,9 @@ interface ISms {
     *  broadcast when the message is delivered to the recipient.  The
     *  raw pdu of the status report is in the extended data ("pdu").
     */
    void sendStoredText(int subId, String callingPkg, in Uri messageUri, String scAddress,
            in PendingIntent sentIntent, in PendingIntent deliveryIntent);
    void sendStoredText(int subId, String callingPkg, String callingAttributionTag,
            in Uri messageUri, String scAddress, in PendingIntent sentIntent,
            in PendingIntent deliveryIntent);

    /**
     * Send a system stored multi-part text message.
@@ -459,6 +461,7 @@ interface ISms {
     *
     * @param subId the SIM id.
     * @param callingPkg the package name of the calling app
     * @param callingAttributeTag the attribute tag of the calling context
     * @param messageUri the URI of the stored message
     * @param scAddress is the service center address or null to use
     *   the current default SMSC
@@ -482,8 +485,8 @@ interface ISms {
     *   to the recipient.  The raw pdu of the status report is in the
     *   extended data ("pdu").
     */
    void sendStoredMultipartText(int subId, String callingPkg, in Uri messageUri,
                String scAddress, in List<PendingIntent> sentIntents,
    void sendStoredMultipartText(int subId, String callingPkg, String callingAttributeTag,
                in Uri messageUri, String scAddress, in List<PendingIntent> sentIntents,
                in List<PendingIntent> deliveryIntents);

    /**
+11 −10
Original line number Diff line number Diff line
@@ -45,15 +45,15 @@ public class ISmsImplBase extends ISms.Stub {
    }

    @Override
    public void sendDataForSubscriber(int subId, String callingPkg, String destAddr,
            String scAddr, int destPort, byte[] data, PendingIntent sentIntent,
    public void sendDataForSubscriber(int subId, String callingPkg, String callingAttributionTag,
            String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent,
            PendingIntent deliveryIntent) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void sendTextForSubscriber(int subId, String callingPkg, String destAddr,
            String scAddr, String text, PendingIntent sentIntent,
    public void sendTextForSubscriber(int subId, String callingPkg, String callingAttributionTag,
            String destAddr, String scAddr, String text, PendingIntent sentIntent,
            PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp) {
        throw new UnsupportedOperationException();
    }
@@ -75,7 +75,7 @@ public class ISmsImplBase extends ISms.Stub {

    @Override
    public void sendMultipartTextForSubscriber(int subId, String callingPkg,
            String destinationAddress, String scAddress,
            String callingAttributionTag, String destinationAddress, String scAddress,
            List<String> parts, List<PendingIntent> sentIntents,
            List<PendingIntent> deliveryIntents, boolean persistMessageForNonDefaultSmsApp) {
        throw new UnsupportedOperationException();
@@ -83,7 +83,7 @@ public class ISmsImplBase extends ISms.Stub {

    @Override
    public void sendMultipartTextForSubscriberWithOptions(int subId, String callingPkg,
            String destinationAddress, String scAddress,
            String callingAttributionTag, String destinationAddress, String scAddress,
            List<String> parts, List<PendingIntent> sentIntents,
            List<PendingIntent> deliveryIntents, boolean persistMessageForNonDefaultSmsApp,
            int priority, boolean expectMore, int validityPeriod) {
@@ -160,14 +160,15 @@ public class ISmsImplBase extends ISms.Stub {
    }

    @Override
    public void sendStoredText(int subId, String callingPkg, Uri messageUri, String scAddress,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
    public void sendStoredText(int subId, String callingPkg, String callingAttributionTag,
            Uri messageUri, String scAddress, PendingIntent sentIntent,
            PendingIntent deliveryIntent) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void sendStoredMultipartText(int subId, String callingPkg, Uri messageUri,
            String scAddress, List<PendingIntent> sentIntents,
    public void sendStoredMultipartText(int subId, String callingPkg, String callingAttributionTag,
            Uri messageUri, String scAddress, List<PendingIntent> sentIntents,
            List<PendingIntent> deliveryIntents) {
        throw new UnsupportedOperationException();
    }
Loading