Remove ability to enable/disable phoneaccounts (2/6)
Enabling/disabling of phone accounts was only used for SIP accounts and
is no longer necessary for the purpose it was put in.
- Remove all references to enabling/disabling phone accounts
- Remove PhoneAccountSelectionPreferenceActivity and related UI code
+ Rename getEnabledPhoneAccounts -> getCallCapablePhoneAccounts
Bug: 17510811
Change-Id: I6ea5c73bc62f35c2e487dd4d1262c0336b8b6e1e
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 6947727..245e97f 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -610,8 +610,7 @@
/**
* Called just prior to showing an AccountSelection dialog to re-populate the model of the
- * AccountSelection dialog. Important to ensure changes to the enabled state of
- * {@code PhoneAccount}s are reflected in the dialog.
+ * AccountSelection dialog.
*
* @param pref The account selection preference dialog being shown.
*/
@@ -1574,9 +1573,8 @@
TelecomManager telecomManager = TelecomManager.from(this);
int allPhoneAccountsCount = telecomManager.getAllPhoneAccountsCount();
- // Show the phone accounts preference if there are is more than one phone account (this
- // includes disabled phone accounts). The default selection, however, only includes those
- // PhoneAccounts which are enabled.
+ allPhoneAccountsCount = 2;
+ // Show the phone accounts preference if there are is more than one phone account
if (allPhoneAccountsCount > 1) {
populateDefaultOutgoingAccountsModel();
@@ -2149,10 +2147,11 @@
}
TelecomManager telecomManager = TelecomManager.from(this);
- List<PhoneAccountHandle> enabledPhoneAccounts = telecomManager.getEnabledPhoneAccounts();
+ List<PhoneAccountHandle> callCapablePhoneAccounts =
+ telecomManager.getCallCapablePhoneAccounts();
mDefaultOutgoingAccount.setModel(
telecomManager,
- enabledPhoneAccounts,
+ callCapablePhoneAccounts,
telecomManager.getUserSelectedOutgoingPhoneAccount(),
getString(R.string.phone_accounts_ask_every_time));
}
diff --git a/src/com/android/phone/settings/AccountSelectionPreference.java b/src/com/android/phone/settings/AccountSelectionPreference.java
index 88a12e7..2995cf4 100644
--- a/src/com/android/phone/settings/AccountSelectionPreference.java
+++ b/src/com/android/phone/settings/AccountSelectionPreference.java
@@ -116,26 +116,6 @@
// list of enabled accounts can be updated prior to showing the dialog.
mListener.onAccountSelectionDialogShow(this);
- final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- showSelectPhoneAccounts();
- }
- };
- builder.setNegativeButton(R.string.phone_accounts_choose_accounts, listener);
super.onPrepareDialogBuilder(builder);
}
-
- /**
- * Displays the {@link PhoneAccountSelectionPreferenceActivity} where the user is able to
- * enable and disable phone accounts.
- */
- private void showSelectPhoneAccounts() {
- Intent intent = new Intent(mContext, PhoneAccountSelectionPreferenceActivity.class);
- intent.setAction(Intent.ACTION_MAIN);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
- | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mContext.startActivityAsUser(intent, null, UserHandle.CURRENT);
- }
}
diff --git a/src/com/android/phone/settings/PhoneAccountSelectionPreferenceActivity.java b/src/com/android/phone/settings/PhoneAccountSelectionPreferenceActivity.java
deleted file mode 100644
index a5eadbb..0000000
--- a/src/com/android/phone/settings/PhoneAccountSelectionPreferenceActivity.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.phone.settings;
-
-import android.app.ActionBar;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceCategory;
-import android.preference.PreferenceFragment;
-import android.preference.SwitchPreference;
-import android.telecom.PhoneAccount;
-import android.telecom.PhoneAccountHandle;
-import android.telecom.TelecomManager;
-
-import com.android.internal.util.CharSequences;
-import com.android.phone.R;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Preference activity used to facilitate enabling and disabling phone accounts by the user.
- */
-public class PhoneAccountSelectionPreferenceActivity extends PreferenceActivity {
-
- /**
- * Preference fragment containing a list of all {@link PhoneAccount}s in the form of switches
- * the user can use to enable or disable accounts.
- */
- public static class PhoneAccountSelectionPreferenceFragment extends PreferenceFragment
- implements Preference.OnPreferenceChangeListener {
- private static final String CATEGORY_PHONE_ACCOUNTS_KEY = "phone_accounts_list";
-
- private TelecomManager mTelecomManager;
- private PreferenceCategory mPhoneAccountsCategory;
-
- /**
- * Represents a single {@link PhoneAccount} for the purpose enabling and disabling.
- */
- static class PhoneAccountPreference extends SwitchPreference {
- private PhoneAccountHandle mPhoneAccountHandle;
- private boolean mPreviousState;
-
- public PhoneAccountPreference(Context context, PhoneAccount phoneAccount) {
- super(context);
-
- setPhoneAccount(phoneAccount);
- }
-
- /**
- * Configures the {@code PhoneAccountPreference} for the passed in {@link PhoneAccount}.
- *
- * @param phoneAccount The phone account.
- */
- private void setPhoneAccount(PhoneAccount phoneAccount) {
- mPhoneAccountHandle = phoneAccount.getAccountHandle();
- mPreviousState = phoneAccount.isEnabled();
- this.setTitle(phoneAccount.getLabel());
- this.setChecked(mPreviousState);
- }
-
- public boolean getPreviousState() {
- return mPreviousState;
- }
-
- public PhoneAccountHandle getPhoneAccountHandle() {
- return mPhoneAccountHandle;
- }
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.phone_account_selection);
- mPhoneAccountsCategory = (PreferenceCategory) findPreference(
- CATEGORY_PHONE_ACCOUNTS_KEY);
- mTelecomManager = TelecomManager.from(this.getActivity());
-
- List<PhoneAccount> phoneAccounts = mTelecomManager.getAllPhoneAccounts();
- Collections.sort(phoneAccounts, new Comparator<PhoneAccount>() {
- @Override
- public int compare(PhoneAccount o1, PhoneAccount o2) {
- return CharSequences.compareToIgnoreCase(o1.getLabel(), o2.getLabel());
- }
- });
-
- for (PhoneAccount phoneAccount : phoneAccounts) {
- // Do not add Sim PhoneAccounts.
- if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
- continue;
- }
-
- PhoneAccountPreference phoneAccountPreference = new PhoneAccountPreference(
- getActivity(), phoneAccount);
- phoneAccountPreference.setOnPreferenceChangeListener(this);
- phoneAccountPreference.setEnabled(!phoneAccount.hasCapabilities(
- PhoneAccount.CAPABILITY_ALWAYS_ENABLED));
- mPhoneAccountsCategory.addPreference(phoneAccountPreference);
- }
- }
-
- /**
- * Handles changes to preferences
- * @param preference The preference which changed.
- * @param newValue The new value of the preference.
- * @return
- */
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (preference instanceof PhoneAccountPreference) {
- PhoneAccountPreference phoneAccountPreference = (PhoneAccountPreference) preference;
- boolean newState = Boolean.valueOf(newValue.toString()).booleanValue();
-
- if (newState != phoneAccountPreference.getPreviousState()) {
- mTelecomManager.setPhoneAccountEnabled(
- phoneAccountPreference.getPhoneAccountHandle(), newState);
- }
- return true;
- }
- return false;
- }
- }
-
- @Override
- public void onBuildHeaders(List<Header> target) {
- loadHeadersFromResource(R.xml.phone_account_selection_activity, target);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- setTitle(getResources().getString(R.string.call_settings));
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayShowHomeEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(false);
- }
-
- // By default, show the main fragment.
- Intent intent = getIntent();
- if (intent.getStringArrayExtra(EXTRA_SHOW_FRAGMENT) == null) {
- getIntent().putExtra(EXTRA_SHOW_FRAGMENT,
- PhoneAccountSelectionPreferenceFragment.class.getName());
- }
-
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public boolean isValidFragment(String fragmentName) {
- return true;
- }
-}
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 307c522..06badc3 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -139,12 +139,6 @@
PhoneAccount.CAPABILITY_CALL_PROVIDER |
PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS;
- // Indicate the emergency calling PhoneAccount is ALWAYS enabled. This capability is
- // important to ensure the emergency-only PhoneAccount cannot be disabled.
- if (isEmergency) {
- capabilities |= PhoneAccount.CAPABILITY_ALWAYS_ENABLED;
- }
-
PhoneAccount account = PhoneAccount.builder(phoneAccountHandle, label)
.setAddress(Uri.fromParts(PhoneAccount.SCHEME_TEL, line1Number, null))
.setSubscriptionAddress(
@@ -154,7 +148,6 @@
.setShortDescription(description)
.setSupportedUriSchemes(Arrays.asList(
PhoneAccount.SCHEME_TEL, PhoneAccount.SCHEME_VOICEMAIL))
- .setEnabled(true)
.build();
// Register with Telecom and put into the account entry.