Loading src/com/android/server/telecom/RespondViaSmsManager.java +22 −23 Original line number Original line Diff line number Diff line Loading @@ -18,15 +18,12 @@ package com.android.server.telecom; // TODO: Needed for move to system service: import com.android.internal.R; // TODO: Needed for move to system service: import com.android.internal.R; import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.SmsApplication; import com.android.internal.telephony.SmsApplication; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.Resources; import android.net.Uri; import android.os.Handler; import android.os.Handler; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; Loading @@ -34,8 +31,8 @@ import android.telecom.Connection; import android.telecom.Log; import android.telecom.Log; import android.telecom.Response; import android.telecom.Response; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.telephony.SmsManager; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.Spannable; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableString; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -178,26 +175,28 @@ public class RespondViaSmsManager extends CallsManagerListenerBase { */ */ private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage, private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage, int subId, String contactName) { int subId, String contactName) { if (!TextUtils.isEmpty(textMessage)) { if (TextUtils.isEmpty(textMessage)) { final ComponentName component = Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: empty text message. "); SmsApplication.getDefaultRespondViaMessageApplication(context, return; true /*updateIfNeeded*/); if (component != null) { // Build and send the intent final Uri uri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null); final Intent intent = new Intent(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE, uri); intent.putExtra(Intent.EXTRA_TEXT, textMessage); if (SubscriptionManager.isValidSubscriptionId(subId)) { intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); } } if (!SubscriptionManager.isValidSubscriptionId(subId)) { Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: Invalid SubId: " + subId); return; } SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId); try { smsManager.sendTextMessage(phoneNumber, null, textMessage, null /*sentIntent*/, null /*deliveryIntent*/); SomeArgs args = SomeArgs.obtain(); SomeArgs args = SomeArgs.obtain(); args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber; args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber; args.arg2 = context; args.arg2 = context; mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget(); mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget(); intent.setComponent(component); } catch (IllegalArgumentException e) { context.startService(intent); Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: " + } e.getMessage()); } } } } } } Loading
src/com/android/server/telecom/RespondViaSmsManager.java +22 −23 Original line number Original line Diff line number Diff line Loading @@ -18,15 +18,12 @@ package com.android.server.telecom; // TODO: Needed for move to system service: import com.android.internal.R; // TODO: Needed for move to system service: import com.android.internal.R; import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.SmsApplication; import com.android.internal.telephony.SmsApplication; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.Resources; import android.net.Uri; import android.os.Handler; import android.os.Handler; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; Loading @@ -34,8 +31,8 @@ import android.telecom.Connection; import android.telecom.Log; import android.telecom.Log; import android.telecom.Response; import android.telecom.Response; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.telephony.SmsManager; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.Spannable; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableString; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -178,26 +175,28 @@ public class RespondViaSmsManager extends CallsManagerListenerBase { */ */ private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage, private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage, int subId, String contactName) { int subId, String contactName) { if (!TextUtils.isEmpty(textMessage)) { if (TextUtils.isEmpty(textMessage)) { final ComponentName component = Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: empty text message. "); SmsApplication.getDefaultRespondViaMessageApplication(context, return; true /*updateIfNeeded*/); if (component != null) { // Build and send the intent final Uri uri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null); final Intent intent = new Intent(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE, uri); intent.putExtra(Intent.EXTRA_TEXT, textMessage); if (SubscriptionManager.isValidSubscriptionId(subId)) { intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); } } if (!SubscriptionManager.isValidSubscriptionId(subId)) { Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: Invalid SubId: " + subId); return; } SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId); try { smsManager.sendTextMessage(phoneNumber, null, textMessage, null /*sentIntent*/, null /*deliveryIntent*/); SomeArgs args = SomeArgs.obtain(); SomeArgs args = SomeArgs.obtain(); args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber; args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber; args.arg2 = context; args.arg2 = context; mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget(); mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget(); intent.setComponent(component); } catch (IllegalArgumentException e) { context.startService(intent); Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: " + } e.getMessage()); } } } } } }