diff options
author | Nancy Chen <nancychen@google.com> | 2015-01-15 16:37:26 -0800 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2015-01-16 12:53:33 -0800 |
commit | 1eb16ea1adca302ff19f64d6ae55e586194a6127 (patch) | |
tree | 07479b9ed042afa58e6cb8f5831fe134bc32e481 /src | |
parent | e8d45249118ddb43ed4e8e999c9e8b60d95b0f41 (diff) |
When dialing voicemail, check voicemail number of correct default SIM.
Before dialing voicemail when a default SIM is set, Dialer checks first if it
has a valid voicemail number. However, the previous code was checking the
voicemail number of the first SIM as opposed to the default SIM. This
change corrects the logic.
Bug: 18938231
Change-Id: Ia83aa44bc773e99aabbe7474439d22eb1c4e6fd9
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index ce6475ec2..f1112f175 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -924,9 +924,10 @@ public class DialpadFragment extends Fragment PhoneAccountUtils.getSubscriptionPhoneAccounts(getActivity()); boolean hasUserSelectedDefault = subscriptionAccountHandles.contains( getTelecomManager().getUserSelectedOutgoingPhoneAccount()); - boolean multiSim = subscriptionAccountHandles.size() > 1; + boolean needsAccountDisambiguation = subscriptionAccountHandles.size() > 1 + && !hasUserSelectedDefault; - if ((multiSim && !hasUserSelectedDefault) || isVoicemailAvailable()) { + if (needsAccountDisambiguation || isVoicemailAvailable()) { // On a multi-SIM phone, if the user has not selected a default // subscription, initiate a call to voicemail so they can select an account // from the "Call with" dialog. @@ -1519,13 +1520,21 @@ public class DialpadFragment extends Fragment /** * Check if voicemail is enabled/accessible. * - * @return true if voicemail is enabled and accessibly. Note that this can be false + * @return true if voicemail is enabled and accessible. Note that this can be false * "temporarily" after the app boot. - * @see TelephonyManager#getVoiceMailNumber() + * @see TelecomManager#hasVoiceMailNumber(PhoneAccountHandle) */ private boolean isVoicemailAvailable() { try { - return getTelephonyManager().getVoiceMailNumber() != null; + PhoneAccountHandle defaultUserSelectedAccount = + getTelecomManager().getUserSelectedOutgoingPhoneAccount(); + if (defaultUserSelectedAccount == null) { + // In a single-SIM phone, there is no default outgoing phone account selected by + // the user, so just call TelephonyManager#getVoicemailNumber directly. + return getTelephonyManager().getVoiceMailNumber() != null; + } else { + return getTelecomManager().hasVoiceMailNumber(defaultUserSelectedAccount); + } } catch (SecurityException se) { // Possibly no READ_PHONE_STATE privilege. Log.w(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient."); |