diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:29:54 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:29:54 +0000 |
commit | 43b3152d075138b11e1fe297682b3bbc775e5641 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/dialer/app/settings/DialerSettingsActivity.java | |
parent | 2034759538273aed8a0b412d8fb90994eba1f7ea (diff) | |
parent | 300a8683b9c28424fb0f0c571a0abe128c461f69 (diff) |
Update Dialer to V10 RC16 am: 10b34a5ebf
am: 300a8683b9
Change-Id: If5695bad59f8a4dab6e6c90b54943b900bd2652a
Diffstat (limited to 'java/com/android/dialer/app/settings/DialerSettingsActivity.java')
-rw-r--r-- | java/com/android/dialer/app/settings/DialerSettingsActivity.java | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/java/com/android/dialer/app/settings/DialerSettingsActivity.java b/java/com/android/dialer/app/settings/DialerSettingsActivity.java index ff3841aa1..fae5ff3ee 100644 --- a/java/com/android/dialer/app/settings/DialerSettingsActivity.java +++ b/java/com/android/dialer/app/settings/DialerSettingsActivity.java @@ -24,6 +24,7 @@ import android.os.Bundle; import android.os.UserManager; import android.preference.PreferenceManager; import android.provider.Settings; +import android.support.annotation.Nullable; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; @@ -151,21 +152,57 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { return; } - PhoneAccountHandle phoneAccountHandle = - getSystemService(TelecomManager.class) - .getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL); - if (phoneAccountHandle == null) { - LogUtil.e("DialerSettingsActivity.addVoicemailSettings", "phoneAccountHandle is null"); - return; - } LogUtil.i("DialerSettingsActivity.addVoicemailSettings", "adding voicemail settings"); Header voicemailSettings = new Header(); voicemailSettings.titleRes = R.string.voicemail_settings_label; - voicemailSettings.fragment = voicemailSettingsFragment; - Bundle bundle = new Bundle(); - bundle.putParcelable(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE, phoneAccountHandle); - voicemailSettings.fragmentArguments = bundle; - target.add(voicemailSettings); + PhoneAccountHandle soleAccount = getSoleSimAccount(); + if (soleAccount == null) { + LogUtil.i( + "DialerSettingsActivity.addVoicemailSettings", "showing multi-SIM voicemail settings"); + voicemailSettings.fragment = PhoneAccountSelectionFragment.class.getName(); + Bundle bundle = new Bundle(); + bundle.putString( + PhoneAccountSelectionFragment.PARAM_TARGET_FRAGMENT, voicemailSettingsFragment); + bundle.putString( + PhoneAccountSelectionFragment.PARAM_PHONE_ACCOUNT_HANDLE_KEY, + VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE); + bundle.putBundle(PhoneAccountSelectionFragment.PARAM_ARGUMENTS, new Bundle()); + bundle.putInt( + PhoneAccountSelectionFragment.PARAM_TARGET_TITLE_RES, R.string.voicemail_settings_label); + voicemailSettings.fragmentArguments = bundle; + target.add(voicemailSettings); + } else { + LogUtil.i( + "DialerSettingsActivity.addVoicemailSettings", "showing single-SIM voicemail settings"); + voicemailSettings.fragment = voicemailSettingsFragment; + Bundle bundle = new Bundle(); + bundle.putParcelable(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE, soleAccount); + voicemailSettings.fragmentArguments = bundle; + target.add(voicemailSettings); + } + } + + /** + * @return the only SIM phone account, or {@code null} if there are none or more than one. Note: + * having a empty SIM slot still count as a PhoneAccountHandle that is "invalid", and + * voicemail settings should still be available for it. + */ + @Nullable + private PhoneAccountHandle getSoleSimAccount() { + TelecomManager telecomManager = getSystemService(TelecomManager.class); + PhoneAccountHandle result = null; + for (PhoneAccountHandle phoneAccountHandle : telecomManager.getCallCapablePhoneAccounts()) { + PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle); + if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) { + LogUtil.i( + "DialerSettingsActivity.getSoleSimAccount", phoneAccountHandle + " is a SIM account"); + if (result != null) { + return null; + } + result = phoneAccountHandle; + } + } + return result; } /** |