summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Brad Ebinger <breadley@google.com> 2019-03-28 15:46:50 -0700
committer Brad Ebinger <breadley@google.com> 2019-03-29 13:23:11 -0700
commit099d985844be826e4ed093868ac5e70297592f61 (patch)
tree79c8537fe118192f1a09df5bb46dffeb340242a4
parent213812ba28b4532eda453bf322e71cf628d0d59a (diff)
Do not show SMS SIM pick UI for Cell Broadcast Config change
If the user did not pick their default SIM subscription for SMS, we were showing many dialogs to the user whenever SmsManager#getSubscriptionId was called for cell broadcast related APIs. Instead, if we instantiate the SmsManager using SmsManager.getDefault() and the user has not set a default, use the default Phone and do not show SIM picker activity (consistent with legacy implementation). Bug: 129315610 Test: set up DSDS, disable eSIM operator in settings Change-Id: I3cc4839632eede75c8943836432b07978d0efda0
-rw-r--r--telephony/java/android/telephony/SmsManager.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index 4d1b89c0e8ce..def7fbe5bd3f 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -941,8 +941,7 @@ public final class SmsManager {
* @return associated subscription id
*/
public int getSubscriptionId() {
- final int subId = (mSubId == DEFAULT_SUBSCRIPTION_ID)
- ? getDefaultSmsSubscriptionId() : mSubId;
+ final int subId = getSubIdOrDefault();
boolean isSmsSimPickActivityNeeded = false;
final Context context = ActivityThread.currentApplication().getApplicationContext();
try {
@@ -975,6 +974,17 @@ public final class SmsManager {
}
/**
+ * @return the subscription ID associated with this {@link SmsManager} or the default set by the
+ * user if this instance was created using {@link SmsManager#getDefault}.
+ *
+ * If there is no default set by the user, this method returns
+ * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}.
+ */
+ private int getSubIdOrDefault() {
+ return (mSubId == DEFAULT_SUBSCRIPTION_ID) ? getDefaultSmsSubscriptionId() : mSubId;
+ }
+
+ /**
* Returns the ISms service, or throws an UnsupportedOperationException if
* the service does not exist.
*/
@@ -1141,8 +1151,9 @@ public final class SmsManager {
try {
ISms iSms = getISmsService();
if (iSms != null) {
- success = iSms.enableCellBroadcastForSubscriber(
- getSubscriptionId(), messageIdentifier, ranType);
+ // If getSubIdOrDefault() returns INVALID, we will use the default phone internally.
+ success = iSms.enableCellBroadcastForSubscriber(getSubIdOrDefault(),
+ messageIdentifier, ranType);
}
} catch (RemoteException ex) {
// ignore it
@@ -1177,8 +1188,9 @@ public final class SmsManager {
try {
ISms iSms = getISmsService();
if (iSms != null) {
- success = iSms.disableCellBroadcastForSubscriber(
- getSubscriptionId(), messageIdentifier, ranType);
+ // If getSubIdOrDefault() returns INVALID, we will use the default phone internally.
+ success = iSms.disableCellBroadcastForSubscriber(getSubIdOrDefault(),
+ messageIdentifier, ranType);
}
} catch (RemoteException ex) {
// ignore it
@@ -1220,7 +1232,8 @@ public final class SmsManager {
try {
ISms iSms = getISmsService();
if (iSms != null) {
- success = iSms.enableCellBroadcastRangeForSubscriber(getSubscriptionId(),
+ // If getSubIdOrDefault() returns INVALID, we will use the default phone internally.
+ success = iSms.enableCellBroadcastRangeForSubscriber(getSubIdOrDefault(),
startMessageId, endMessageId, ranType);
}
} catch (RemoteException ex) {
@@ -1263,7 +1276,8 @@ public final class SmsManager {
try {
ISms iSms = getISmsService();
if (iSms != null) {
- success = iSms.disableCellBroadcastRangeForSubscriber(getSubscriptionId(),
+ // If getSubIdOrDefault() returns INVALID, we will use the default phone internally.
+ success = iSms.disableCellBroadcastRangeForSubscriber(getSubIdOrDefault(),
startMessageId, endMessageId, ranType);
}
} catch (RemoteException ex) {