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

Commit 448c12c2 authored by Abhijith Shastry's avatar Abhijith Shastry Committed by Nathan Harold
Browse files

Permit privileged system apps to send SMS without persisting.

The system app needs to have MODIFY_PHONE_STATE permission.

Original Change-Id: Ic9242972a211c90378c183c3abf95672c2816ac7
BUG: 35325136
Test: API visibility change, Manual

Change-Id: I37b185feaa72e330a0845eff137ea310ad0dca08
parent b94d28ac
Loading
Loading
Loading
Loading
+27 −18
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.telephony;
package android.telephony;


import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.app.ActivityThread;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ActivityNotFoundException;
@@ -307,13 +308,13 @@ public final class SmsManager {
    public void sendTextMessage(
    public void sendTextMessage(
            String destinationAddress, String scAddress, String text,
            String destinationAddress, String scAddress, String text,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        sendTextMessageInternal(destinationAddress, scAddress, text,
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
            sentIntent, deliveryIntent, true /* persistMessageForCarrierApp*/);
                true /* persistMessage*/);
    }
    }


    private void sendTextMessageInternal(String destinationAddress, String scAddress,
    private void sendTextMessageInternal(String destinationAddress, String scAddress,
            String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
            String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
            boolean persistMessageForCarrierApp) {
            boolean persistMessage) {
        if (TextUtils.isEmpty(destinationAddress)) {
        if (TextUtils.isEmpty(destinationAddress)) {
            throw new IllegalArgumentException("Invalid destinationAddress");
            throw new IllegalArgumentException("Invalid destinationAddress");
        }
        }
@@ -327,7 +328,7 @@ public final class SmsManager {
            iccISms.sendTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(),
            iccISms.sendTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(),
                    destinationAddress,
                    destinationAddress,
                    scAddress, text, sentIntent, deliveryIntent,
                    scAddress, text, sentIntent, deliveryIntent,
                    persistMessageForCarrierApp);
                    persistMessage);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // ignore it
            // ignore it
        }
        }
@@ -336,16 +337,20 @@ public final class SmsManager {
    /**
    /**
     * Send a text based SMS without writing it into the SMS Provider.
     * Send a text based SMS without writing it into the SMS Provider.
     *
     *
     * <p>Only the carrier app can call this method.</p>
     * <p>Requires Permission:
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE} or the calling app has carrier
     * privileges.
     * </p>
     *
     *
     * @see #sendTextMessage(String, String, String, PendingIntent, PendingIntent)
     * @see #sendTextMessage(String, String, String, PendingIntent, PendingIntent)
     * @hide
     * @hide
     */
     */
    @SystemApi
    public void sendTextMessageWithoutPersisting(
    public void sendTextMessageWithoutPersisting(
            String destinationAddress, String scAddress, String text,
            String destinationAddress, String scAddress, String text,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        sendTextMessageInternal(destinationAddress, scAddress, text,
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
            sentIntent, deliveryIntent, false /* persistMessageForCarrierApp*/);
                false /* persistMessage */);
    }
    }


    /**
    /**
@@ -474,14 +479,14 @@ public final class SmsManager {
    public void sendMultipartTextMessage(
    public void sendMultipartTextMessage(
            String destinationAddress, String scAddress, ArrayList<String> parts,
            String destinationAddress, String scAddress, ArrayList<String> parts,
            ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
            ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts,
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
              sentIntents, deliveryIntents, true /* persistMessageForCarrierApp*/);
                deliveryIntents, true /* persistMessage*/);
    }
    }


    private void sendMultipartTextMessageInternal(
    private void sendMultipartTextMessageInternal(
            String destinationAddress, String scAddress, ArrayList<String> parts,
            String destinationAddress, String scAddress, List<String> parts,
            ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents,
            boolean persistMessageForCarrierApp) {
            boolean persistMessage) {
        if (TextUtils.isEmpty(destinationAddress)) {
        if (TextUtils.isEmpty(destinationAddress)) {
            throw new IllegalArgumentException("Invalid destinationAddress");
            throw new IllegalArgumentException("Invalid destinationAddress");
        }
        }
@@ -495,7 +500,7 @@ public final class SmsManager {
                iccISms.sendMultipartTextForSubscriber(getSubscriptionId(),
                iccISms.sendMultipartTextForSubscriber(getSubscriptionId(),
                        ActivityThread.currentPackageName(),
                        ActivityThread.currentPackageName(),
                        destinationAddress, scAddress, parts,
                        destinationAddress, scAddress, parts,
                        sentIntents, deliveryIntents, persistMessageForCarrierApp);
                        sentIntents, deliveryIntents, persistMessage);
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                // ignore it
                // ignore it
            }
            }
@@ -516,16 +521,20 @@ public final class SmsManager {
    /**
    /**
     * Send a multi-part text based SMS without writing it into the SMS Provider.
     * Send a multi-part text based SMS without writing it into the SMS Provider.
     *
     *
     * <p>Only the carrier app can call this method.</p>
     * <p>Requires Permission:
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE} or the calling app has carrier
     * privileges.
     * </p>
     *
     *
     * @see #sendMultipartTextMessage(String, String, ArrayList, ArrayList, ArrayList)
     * @see #sendMultipartTextMessage(String, String, ArrayList, ArrayList, ArrayList)
     * @hide
     * @hide
     **/
     **/
    @SystemApi
    public void sendMultipartTextMessageWithoutPersisting(
    public void sendMultipartTextMessageWithoutPersisting(
            String destinationAddress, String scAddress, ArrayList<String> parts,
            String destinationAddress, String scAddress, List<String> parts,
            ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts,
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
            sentIntents, deliveryIntents, false /* persistMessageForCarrierApp*/);
                deliveryIntents, false /* persistMessage*/);
    }
    }


    /**
    /**