diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-05 15:23:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-05 15:23:13 +0000 |
commit | 300a8683b9c28424fb0f0c571a0abe128c461f69 (patch) | |
tree | 3a325b0effac02fbd228b8ddf2f96589e5df72cd /java/com/android/dialer/app/settings/DialerSettingsActivity.java | |
parent | d67f1627521b174f12e0c247f154c7c93c5e408e (diff) | |
parent | 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 (diff) |
Update Dialer to V10 RC16
am: 10b34a5ebf
Change-Id: Iea3e96ccdeaf1fa796ceca702cace82ca20f298c
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; } /** |