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

Commit de029072 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Gerrit Code Review
Browse files

Merge "Pipe through attributeTag for one self-permission check"

parents 22575e1f 1f28ee38
Loading
Loading
Loading
Loading
+16 −13
Original line number Original line Diff line number Diff line
@@ -406,10 +406,11 @@ public class IccSmsInterfaceManager {
     * A permissions check before passing to {@link IccSmsInterfaceManager#sendDataInternal}.
     * A permissions check before passing to {@link IccSmsInterfaceManager#sendDataInternal}.
     * This method checks if the calling package or itself has the permission to send the data sms.
     * This method checks if the calling package or itself has the permission to send the data sms.
     */
     */
    public void sendDataWithSelfPermissions(String callingPackage, String destAddr, String scAddr,
    public void sendDataWithSelfPermissions(String callingPackage, String callingAttributionTag,
            int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent,
            String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent,
            boolean isForVvm) {
            PendingIntent deliveryIntent, boolean isForVvm) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, callingAttributionTag,
                "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            returnUnspecifiedFailure(sentIntent);
            return;
            return;
        }
        }
@@ -489,10 +490,11 @@ public class IccSmsInterfaceManager {
     * A permissions check before passing to {@link IccSmsInterfaceManager#sendTextInternal}.
     * A permissions check before passing to {@link IccSmsInterfaceManager#sendTextInternal}.
     * This method checks if the calling package or itself has the permission to send the sms.
     * This method checks if the calling package or itself has the permission to send the sms.
     */
     */
    public void sendTextWithSelfPermissions(String callingPackage, String destAddr, String scAddr,
    public void sendTextWithSelfPermissions(String callingPackage, String callingAttributeTag,
            String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
            String destAddr, String scAddr, String text, PendingIntent sentIntent,
            boolean persistMessage, boolean isForVvm) {
            PendingIntent deliveryIntent, boolean persistMessage, boolean isForVvm) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, callingAttributeTag,
                "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            returnUnspecifiedFailure(sentIntent);
            return;
            return;
        }
        }
@@ -610,11 +612,12 @@ public class IccSmsInterfaceManager {
     *  Any Other values including negative considered as Invalid Validity Period of the message.
     *  Any Other values including negative considered as Invalid Validity Period of the message.
     */
     */


    public void sendTextWithOptions(String callingPackage, String destAddr, String scAddr,
    public void sendTextWithOptions(String callingPackage, String callingAttributionTag,
            String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
            String destAddr, String scAddr, String text, PendingIntent sentIntent,
            boolean persistMessageForNonDefaultSmsApp, int priority, boolean expectMore,
            PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, int priority,
            int validityPeriod) {
            boolean expectMore, int validityPeriod) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, "Sending SMS message")) {
        if (!mSmsPermissions.checkCallingOrSelfCanSendSms(callingPackage, callingAttributionTag,
                "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            returnUnspecifiedFailure(sentIntent);
            return;
            return;
        }
        }
+24 −35
Original line number Original line Diff line number Diff line
@@ -146,21 +146,13 @@ public class SmsController extends ISmsImplBase {
        }
        }
    }
    }


    @Override
    public void sendDataForSubscriberWithSelfPermissions(int subId, String callingPackage,
            String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent,
            PendingIntent deliveryIntent) {
        sendDataForSubscriberWithSelfPermissionsInternal(subId, callingPackage, destAddr, scAddr,
                destPort, data, sentIntent, deliveryIntent, false /* isForVvm */);
    }

    private void sendDataForSubscriberWithSelfPermissionsInternal(int subId, String callingPackage,
    private void sendDataForSubscriberWithSelfPermissionsInternal(int subId, String callingPackage,
            String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent,
            String callingAttributionTag, String destAddr, String scAddr, int destPort, byte[] data,
            PendingIntent deliveryIntent, boolean isForVvm) {
            PendingIntent sentIntent, PendingIntent deliveryIntent, boolean isForVvm) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        if (iccSmsIntMgr != null) {
        if (iccSmsIntMgr != null) {
            iccSmsIntMgr.sendDataWithSelfPermissions(callingPackage, destAddr, scAddr, destPort,
            iccSmsIntMgr.sendDataWithSelfPermissions(callingPackage, callingAttributionTag,
                    data, sentIntent, deliveryIntent, isForVvm);
                    destAddr, scAddr, destPort, data, sentIntent, deliveryIntent, isForVvm);
        } else {
        } else {
            Rlog.e(LOG_TAG, "sendText iccSmsIntMgr is null for"
            Rlog.e(LOG_TAG, "sendText iccSmsIntMgr is null for"
                    + " Subscription: " + subId);
                    + " Subscription: " + subId);
@@ -225,21 +217,14 @@ public class SmsController extends ISmsImplBase {
        }
        }
    }
    }


    @Override
    public void sendTextForSubscriberWithSelfPermissions(int subId, String callingPackage,
            String destAddr, String scAddr, String text, PendingIntent sentIntent,
            PendingIntent deliveryIntent, boolean persistMessage) {
        sendTextForSubscriberWithSelfPermissionsInternal(subId, callingPackage, destAddr, scAddr,
                text, sentIntent, deliveryIntent, persistMessage, false /* isForVvm */);
    }

    private void sendTextForSubscriberWithSelfPermissionsInternal(int subId, String callingPackage,
    private void sendTextForSubscriberWithSelfPermissionsInternal(int subId, String callingPackage,
            String destAddr, String scAddr, String text, PendingIntent sentIntent,
            String callingAttributeTag, String destAddr, String scAddr, String text,
            PendingIntent deliveryIntent, boolean persistMessage, boolean isForVvm) {
            PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessage,
            boolean isForVvm) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        if (iccSmsIntMgr != null) {
        if (iccSmsIntMgr != null) {
            iccSmsIntMgr.sendTextWithSelfPermissions(callingPackage, destAddr, scAddr, text,
            iccSmsIntMgr.sendTextWithSelfPermissions(callingPackage, callingAttributeTag, destAddr,
                    sentIntent, deliveryIntent, persistMessage, isForVvm);
                    scAddr, text, sentIntent, deliveryIntent, persistMessage, isForVvm);
        } else {
        } else {
            Rlog.e(LOG_TAG, "sendText iccSmsIntMgr is null for"
            Rlog.e(LOG_TAG, "sendText iccSmsIntMgr is null for"
                    + " Subscription: " + subId);
                    + " Subscription: " + subId);
@@ -249,16 +234,17 @@ public class SmsController extends ISmsImplBase {


    @Override
    @Override
    public void sendTextForSubscriberWithOptions(int subId, String callingPackage,
    public void sendTextForSubscriberWithOptions(int subId, String callingPackage,
            String destAddr, String scAddr, String parts, PendingIntent sentIntent,
            String callingAttributionTag, String destAddr, String scAddr, String parts,
            PendingIntent deliveryIntent, boolean persistMessage, int priority,
            PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessage,
            boolean expectMore, int validityPeriod) {
            int priority, boolean expectMore, int validityPeriod) {
        if (callingPackage == null) {
        if (callingPackage == null) {
            callingPackage = getCallingPackage();
            callingPackage = getCallingPackage();
        }
        }
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        if (iccSmsIntMgr != null) {
        if (iccSmsIntMgr != null) {
            iccSmsIntMgr.sendTextWithOptions(callingPackage, destAddr, scAddr, parts, sentIntent,
            iccSmsIntMgr.sendTextWithOptions(callingPackage, callingAttributionTag, destAddr,
                    deliveryIntent, persistMessage, priority, expectMore, validityPeriod);
                    scAddr, parts, sentIntent, deliveryIntent, persistMessage, priority, expectMore,
                    validityPeriod);
        } else {
        } else {
            Rlog.e(LOG_TAG, "sendTextWithOptions iccSmsIntMgr is null for"
            Rlog.e(LOG_TAG, "sendTextWithOptions iccSmsIntMgr is null for"
                    + " Subscription: " + subId);
                    + " Subscription: " + subId);
@@ -695,15 +681,18 @@ public class SmsController extends ISmsImplBase {
     * Internal API to send visual voicemail related SMS. This is not exposed outside the phone
     * Internal API to send visual voicemail related SMS. This is not exposed outside the phone
     * process, and should be called only after verifying that the caller is the default VVM app.
     * process, and should be called only after verifying that the caller is the default VVM app.
     */
     */
    public void sendVisualVoicemailSmsForSubscriber(String callingPackage, int subId,
    public void sendVisualVoicemailSmsForSubscriber(String callingPackage,
            String number, int port, String text, PendingIntent sentIntent) {
            String callingAttributionTag, int subId, String number, int port, String text,
            PendingIntent sentIntent) {
        if (port == 0) {
        if (port == 0) {
            sendTextForSubscriberWithSelfPermissionsInternal(subId, callingPackage, number,
            sendTextForSubscriberWithSelfPermissionsInternal(subId, callingPackage,
                    null, text, sentIntent, null, false, true /* isForVvm */);
                    callingAttributionTag, number, null, text, sentIntent, null, false,
                    true /* isForVvm */);
        } else {
        } else {
            byte[] data = text.getBytes(StandardCharsets.UTF_8);
            byte[] data = text.getBytes(StandardCharsets.UTF_8);
            sendDataForSubscriberWithSelfPermissionsInternal(subId, callingPackage, number,
            sendDataForSubscriberWithSelfPermissionsInternal(subId, callingPackage,
                    null, (short) port, data, sentIntent, null, true /* isForVvm */);
                    callingAttributionTag, number, null, (short) port, data, sentIntent, null,
                    true /* isForVvm */);
        }
        }
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -121,7 +121,8 @@ public class SmsPermissions {
     *                           permission revoked at runtime.
     *                           permission revoked at runtime.
     * @return whether the caller has the OP_SEND_SMS AppOps bit.
     * @return whether the caller has the OP_SEND_SMS AppOps bit.
     */
     */
    public boolean checkCallingOrSelfCanSendSms(String callingPackage, String message) {
    public boolean checkCallingOrSelfCanSendSms(String callingPackage, String callingAttributionTag,
            String message) {
        mContext.enforceCallingOrSelfPermission(Manifest.permission.SEND_SMS, message);
        mContext.enforceCallingOrSelfPermission(Manifest.permission.SEND_SMS, message);
        return mAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), callingPackage)
        return mAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), callingPackage)
                == AppOpsManager.MODE_ALLOWED;
                == AppOpsManager.MODE_ALLOWED;