Fix Calling Accounts UI regression
A regression in the Calling Accounts UI caused the default
calling account to not show up.
Bug: 124321210
Test: atest TeleServiceTests
Change-Id: I1a5743384b97d150684d348940480e5fca14cb20
diff --git a/res/xml/phone_account_settings.xml b/res/xml/phone_account_settings.xml
index ae3e9d9..d230328 100644
--- a/res/xml/phone_account_settings.xml
+++ b/res/xml/phone_account_settings.xml
@@ -29,6 +29,7 @@
android:order="1" />
<PreferenceScreen
+ android:key="phone_accounts_all_calling_accounts"
android:title="@string/phone_accounts_all_calling_accounts"
android:summary="@string/phone_accounts_all_calling_accounts_summary"
android:persistent="false"
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 41063e2..ca45b31 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -18,7 +18,6 @@
import android.telecom.TelecomManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -45,7 +44,7 @@
"phone_accounts_accounts_list_category_key";
private static final String DEFAULT_OUTGOING_ACCOUNT_KEY = "default_outgoing_account";
- private static final String ALL_CALLING_ACCOUNTS_KEY = "phone_account_all_calling_accounts";
+ private static final String ALL_CALLING_ACCOUNTS_KEY = "phone_accounts_all_calling_accounts";
private static final String SIP_SETTINGS_CATEGORY_PREF_KEY =
"phone_accounts_sip_settings_category_key";
@@ -72,6 +71,7 @@
private PreferenceCategory mAccountList;
private AccountSelectionPreference mDefaultOutgoingAccount;
+ private Preference mAllCallingAccounts;
private ListPreference mUseSipCalling;
private SwitchPreference mSipReceiveCallsPreference;
@@ -132,6 +132,9 @@
*/
mAccountList = (PreferenceCategory) getPreferenceScreen().findPreference(
ACCOUNTS_LIST_CATEGORY_KEY);
+ mDefaultOutgoingAccount = (AccountSelectionPreference)
+ getPreferenceScreen().findPreference(DEFAULT_OUTGOING_ACCOUNT_KEY);
+ mAllCallingAccounts = getPreferenceScreen().findPreference(ALL_CALLING_ACCOUNTS_KEY);
updateAccounts();
@@ -397,25 +400,21 @@
// Initialize the account list with the set of enabled & SIM accounts.
initAccountList(enabledAccounts);
- mDefaultOutgoingAccount = (AccountSelectionPreference)
- getPreferenceScreen().findPreference(DEFAULT_OUTGOING_ACCOUNT_KEY);
- if (mDefaultOutgoingAccount != null) {
- mDefaultOutgoingAccount.setListener(this);
-
- // Only show the 'Make Calls With..." option if there are multiple accounts.
- if (enabledAccounts.size() > 1) {
- updateDefaultOutgoingAccountsModel();
- } else {
- mAccountList.removePreference(mDefaultOutgoingAccount);
- }
+ mDefaultOutgoingAccount.setListener(this);
+ // Only show the 'Make Calls With..." option if there are multiple accounts.
+ if (enabledAccounts.size() > 1) {
+ mAccountList.addPreference(mDefaultOutgoingAccount);
+ updateDefaultOutgoingAccountsModel();
+ } else {
+ mAccountList.removePreference(mDefaultOutgoingAccount);
}
- Preference allAccounts =
- getPreferenceScreen().findPreference(ALL_CALLING_ACCOUNTS_KEY);
// If there are no third party (nonSim) accounts,
// then don't show enable/disable dialog.
- if (allNonSimAccounts.isEmpty() && allAccounts != null) {
- mAccountList.removePreference(allAccounts);
+ if (!allNonSimAccounts.isEmpty()) {
+ mAccountList.addPreference(mAllCallingAccounts);
+ } else {
+ mAccountList.removePreference(mAllCallingAccounts);
}
} else {
getPreferenceScreen().removePreference(mAccountList);