diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index d777bf123b67d..c39f1f5613b05 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -316,6 +316,7 @@ public final class SmsManager {
* RESULT_ERROR_GENERIC_FAILURE
* RESULT_ERROR_RADIO_OFF
* RESULT_ERROR_NULL_PDU
+ * RESULT_ERROR_NO_SERVICE
* For RESULT_ERROR_GENERIC_FAILURE the sentIntent may include
* the extra "errorCode" containing a radio technology specific value,
* generally only useful for troubleshooting.
@@ -365,19 +366,12 @@ public final class SmsManager {
if (DBG) {
Log.d(TAG, "for subId: " + subId + ", subscription-info: " + info);
}
- if (info == null) {
- // There is no subscription for the given subId. That can only mean one thing:
- // the caller is using a SmsManager instance with an obsolete subscription id.
- // That is most probably because caller didn't invalidate SmsManager instance
- // for an already deleted subscription id.
- Log.e(TAG, "subId: " + subId + " for this SmsManager instance is obsolete.");
- sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE);
- }
/* If the Subscription associated with this SmsManager instance belongs to a remote-sim,
* then send the message thru the remote-sim subscription.
*/
- if (info.getSubscriptionType() == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM) {
+ if (info != null
+ && info.getSubscriptionType() == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM) {
if (DBG) Log.d(TAG, "sending message thru bluetooth");
sendTextMessageBluetooth(destinationAddress, scAddress, text, sentIntent,
deliveryIntent, info);
@@ -385,8 +379,10 @@ public final class SmsManager {
}
try {
+ // 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.
ISms iccISms = getISmsServiceOrThrow();
- iccISms.sendTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(),
+ iccISms.sendTextForSubscriber(subId, ActivityThread.currentPackageName(),
destinationAddress,
scAddress, text, sentIntent, deliveryIntent,
persistMessage);
@@ -459,6 +455,9 @@ public final class SmsManager {
}
private void sendErrorInPendingIntent(PendingIntent intent, int errorCode) {
+ if (intent == null) {
+ return;
+ }
try {
intent.send(errorCode);
} catch (PendingIntent.CanceledException e) {