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

Commit cdb0a56b authored by Youming Ye's avatar Youming Ye Committed by android-build-merger
Browse files

Merge "Pass in external packageName" am: 1764f6a4

am: fb96cce3

Change-Id: Ifd2a0e2374b54f193541453c195f293e39a27376
parents 1fd36008 fb96cce3
Loading
Loading
Loading
Loading
+28 −13
Original line number Original line Diff line number Diff line
@@ -337,12 +337,12 @@ public final class SmsManager {
            String destinationAddress, String scAddress, String text,
            String destinationAddress, String scAddress, String text,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                true /* persistMessage*/);
                true /* persistMessage*/, ActivityThread.currentPackageName());
    }
    }


    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 persistMessage) {
            boolean persistMessage, String packageName) {
        if (TextUtils.isEmpty(destinationAddress)) {
        if (TextUtils.isEmpty(destinationAddress)) {
            throw new IllegalArgumentException("Invalid destinationAddress");
            throw new IllegalArgumentException("Invalid destinationAddress");
        }
        }
@@ -355,9 +355,8 @@ public final class SmsManager {
            // If the subscription is invalid or default, we will use the default phone to send the
            // If the subscription is invalid or default, we will use the default phone to send the
            // SMS and possibly fail later in the SMS sending process.
            // SMS and possibly fail later in the SMS sending process.
            ISms iSms = getISmsServiceOrThrow();
            ISms iSms = getISmsServiceOrThrow();
            iSms.sendTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(),
            iSms.sendTextForSubscriber(getSubscriptionId(), packageName,
                    destinationAddress,
                    destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                    scAddress, text, sentIntent, deliveryIntent,
                    persistMessage);
                    persistMessage);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // ignore it
            // ignore it
@@ -389,7 +388,7 @@ public final class SmsManager {
            String destinationAddress, String scAddress, String text,
            String destinationAddress, String scAddress, String text,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
        sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
                false /* persistMessage */);
                false /* persistMessage */, ActivityThread.currentPackageName());
    }
    }


    /**
    /**
@@ -630,13 +629,30 @@ public final class SmsManager {
            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, sentIntents,
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
                deliveryIntents, true /* persistMessage*/);
                deliveryIntents, true /* persistMessage*/, ActivityThread.currentPackageName());
    }

    /**
     * @hide
     * Similar method as #sendMultipartTextMessage(String, String, ArrayList, ArrayList, ArrayList)
     * With an additional argument
     * @param packageName serves as the default package name if ActivityThread.currentpackageName is
     *                    null.
     */
    public void sendMultipartTextMessageExternal(
            String destinationAddress, String scAddress, ArrayList<String> parts,
            ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents,
            String packageName) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
                deliveryIntents, true /* persistMessage*/,
                ActivityThread.currentPackageName() == null
                        ? packageName : ActivityThread.currentPackageName());
    }
    }


    private void sendMultipartTextMessageInternal(
    private void sendMultipartTextMessageInternal(
            String destinationAddress, String scAddress, List<String> parts,
            String destinationAddress, String scAddress, List<String> parts,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents,
            boolean persistMessage) {
            boolean persistMessage, String packageName) {
        if (TextUtils.isEmpty(destinationAddress)) {
        if (TextUtils.isEmpty(destinationAddress)) {
            throw new IllegalArgumentException("Invalid destinationAddress");
            throw new IllegalArgumentException("Invalid destinationAddress");
        }
        }
@@ -648,8 +664,7 @@ public final class SmsManager {
            try {
            try {
                ISms iSms = getISmsServiceOrThrow();
                ISms iSms = getISmsServiceOrThrow();
                iSms.sendMultipartTextForSubscriber(getSubscriptionId(),
                iSms.sendMultipartTextForSubscriber(getSubscriptionId(),
                        ActivityThread.currentPackageName(),
                        packageName, destinationAddress, scAddress, parts,
                        destinationAddress, scAddress, parts,
                        sentIntents, deliveryIntents, persistMessage);
                        sentIntents, deliveryIntents, persistMessage);
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                // ignore it
                // ignore it
@@ -663,8 +678,8 @@ public final class SmsManager {
            if (deliveryIntents != null && deliveryIntents.size() > 0) {
            if (deliveryIntents != null && deliveryIntents.size() > 0) {
                deliveryIntent = deliveryIntents.get(0);
                deliveryIntent = deliveryIntents.get(0);
            }
            }
            sendTextMessage(destinationAddress, scAddress, parts.get(0),
            sendTextMessageInternal(destinationAddress, scAddress, parts.get(0),
                    sentIntent, deliveryIntent);
                    sentIntent, deliveryIntent, true, packageName);
        }
        }
    }
    }


@@ -685,7 +700,7 @@ public final class SmsManager {
            String destinationAddress, String scAddress, List<String> parts,
            String destinationAddress, String scAddress, List<String> parts,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
        sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
                deliveryIntents, false /* persistMessage*/);
                deliveryIntents, false /* persistMessage*/, ActivityThread.currentPackageName());
    }
    }


    /**
    /**