Fix the default sub id returned by SmsManager.
SmsManager.getDefaultSmsSubscriptionId() did not handle the case
of no default set with a single SIM present. This CL adds the
handling for that.
Test: manual SMS sanity on single sim and DSDS devices
Bug: 132259056
Merged-in: I72ee7af9f0b2662e1ac26b7d3db60c667d06c471
Change-Id: I72ee7af9f0b2662e1ac26b7d3db60c667d06c471
(cherry picked from commit 1c0a7a16c1)
This commit is contained in:
@@ -1958,16 +1958,22 @@ public final class SmsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default sms subscription id
|
||||
* Get default sms subscription id.
|
||||
*
|
||||
* @return the user-defined default SMS subscription id or
|
||||
* {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if no default is set.
|
||||
* <p class="note"><strong>Note:</strong>This returns a value different from
|
||||
* {@link SubscriptionManager#getDefaultSmsSubscriptionId} if the user has not chosen a default.
|
||||
* In this case it returns the active subscription id if there's only one active subscription
|
||||
* available.
|
||||
*
|
||||
* @return the user-defined default SMS subscription id, or the active subscription id if
|
||||
* there's only one active subscription available, otherwise
|
||||
* {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}.
|
||||
*/
|
||||
public static int getDefaultSmsSubscriptionId() {
|
||||
try {
|
||||
return SubscriptionManager.getDefaultSmsSubscriptionId();
|
||||
} catch (NullPointerException ex) {
|
||||
return -1;
|
||||
return getISmsServiceOrThrow().getPreferredSmsSubscription();
|
||||
} catch (RemoteException e) {
|
||||
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user