2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-02 23:25:10 +00:00

Consider subscription id when sending SMS messages

This commit is contained in:
Abdel-Rahman Abdel-Rahman
2020-03-20 17:02:07 +02:00
parent d58dd649e0
commit bfbe6b55ec

View File

@@ -126,7 +126,8 @@ public class SMSPlugin extends Plugin {
* The body should look like so: * The body should look like so:
* { "sendSms": true, * { "sendSms": true,
* "phoneNumber": "542904563213", * "phoneNumber": "542904563213",
* "messageBody": "Hi mom!" * "messageBody": "Hi mom!",
* "sub_id": "3859358340534"
* } * }
*/ */
private final static String PACKET_TYPE_SMS_REQUEST = "kdeconnect.sms.request"; private final static String PACKET_TYPE_SMS_REQUEST = "kdeconnect.sms.request";
@@ -339,9 +340,11 @@ public class SMSPlugin extends Plugin {
if (np.getBoolean("sendSms")) { if (np.getBoolean("sendSms")) {
String phoneNo = np.getString("phoneNumber"); String phoneNo = np.getString("phoneNumber");
String sms = np.getString("messageBody"); String sms = np.getString("messageBody");
long subID = np.getLong("subID", -1);
try { try {
SmsManager smsManager = SmsManager.getDefault(); SmsManager smsManager = subID == -1? SmsManager.getDefault() :
SmsManager.getSmsManagerForSubscriptionId((int) subID);
ArrayList<String> parts = smsManager.divideMessage(sms); ArrayList<String> parts = smsManager.divideMessage(sms);
// If this message turns out to fit in a single SMS, sendMultipartTextMessage // If this message turns out to fit in a single SMS, sendMultipartTextMessage