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/AndroidManifest.xml b/AndroidManifest.xml
index dffb646..9e4ff1f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -436,14 +436,6 @@
</intent-filter>
</activity>
- <activity android:name=".settings.PhoneAccountSelectionPreferenceActivity"
- android:label="@string/phone_accounts"
- android:theme="@style/DialerSettingsLight">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
-
<!-- bluetooth phone service -->
<service android:name="BluetoothPhoneService">
<intent-filter>
@@ -499,8 +491,6 @@
<action android:name="com.android.phone.SIP_INCOMING_CALL" />
<action android:name="com.android.phone.SIP_REMOVE_PHONE" />
<action android:name="com.android.phone.SIP_CALL_OPTION_CHANGED" />
- <action android:name="android.telecom.action.PHONE_ACCOUNT_ENABLED" />
- <action android:name="android.telecom.action.PHONE_ACCOUNT_DISABLED" />
</intent-filter>
</receiver>
diff --git a/res/xml/phone_account_selection_activity.xml b/res/xml/phone_account_selection_activity.xml
deleted file mode 100644
index 6ae933c..0000000
--- a/res/xml/phone_account_selection_activity.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- ~ 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
- -->
-
-<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
- <header
- android:fragment="com.android.phone.settings.PhoneAccountSelectionPreferenceActivity$PhoneAccountSelectionPreferenceFragment"
- android:title="@string/phone_accounts_selection_header" />
-</preference-headers>
\ No newline at end of file
diff --git a/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java b/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
index 9c52324..c808133 100644
--- a/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
+++ b/sip/src/com/android/services/telephony/sip/SipAccountRegistry.java
@@ -177,38 +177,6 @@
}
/**
- * Handles a {@link PhoneAccount} becoming enabled by starting the SIP service for the
- * {@link SipProfile} associated with that {@linke PhoneAccount}.
- *
- * @param context The context.
- * @param phoneAccountHandle The handle for the {@link PhoneAccount} which is enabled.
- */
- void setPhoneAccountEnabled(Context context, PhoneAccountHandle phoneAccountHandle) {
- String sipUri = SipUtil.getSipUriFromPhoneAccount(phoneAccountHandle);
- if (sipUri == null) {
- return;
- }
-
- startSipService(context, sipUri);
- }
-
- /**
- * Handles a {@link PhoneAccount} becoming disabled by stopping the SIP service for the
- * {@link SipProfile} associated with that {@linke PhoneAccount}.
- *
- * @param context The context.
- * @param phoneAccountHandle The handle for the {@link PhoneAccount} which is disabled.
- */
- void setPhoneAccountDisabled(Context context, PhoneAccountHandle phoneAccountHandle) {
- String sipUri = SipUtil.getSipUriFromPhoneAccount(phoneAccountHandle);
- if (sipUri == null) {
- return;
- }
-
- stopSipService(context, sipUri);
- }
-
- /**
* Performs an asynchronous call to
* {@link SipAccountRegistry#startSipProfiles(android.content.Context, String)}, starting the
* specified SIP profile and registering its {@link android.telecom.PhoneAccount}.
@@ -232,11 +200,6 @@
* each with the telecom framework. If a specific sipUri is specified, this will only register
* the associated SIP account.
*
- * Also handles migration from using the primary account shared preference to indicate the
- * {@link SipProfile} to be used for outgoing Sip connections to using the enabled flag on
- * {@link android.telecom.PhoneAccount}s to indicate which profiles can be used for outgoing
- * or ingoing calls.
- *
* @param context The context.
* @param sipUri A specific SIP uri to start, or {@code null} to start all.
*/
@@ -255,21 +218,10 @@
if (sipUri == null || Objects.equals(sipUri, profile.getUriString())) {
PhoneAccount phoneAccount = SipUtil.createPhoneAccount(context, profile);
telecomManager.registerPhoneAccount(phoneAccount);
-
- // If this profile was the primary profile in the past, mark it as enabled.
- boolean isPrimaryProfile = primaryProfile != null &&
- profile.getUriString().equals(primaryProfile);
- if (isPrimaryProfile) {
- telecomManager.setPhoneAccountEnabled(
- phoneAccount.getAccountHandle(), true);
- }
}
- // Start the SIP service for the profile.
- if (SipUtil.isPhoneAccountEnabled(context, profile)) {
- if (sipUri == null || Objects.equals(sipUri, profile.getUriString())) {
- startSipServiceForProfile(profile, sipManager, context, isReceivingCalls);
- }
+ if (sipUri == null || Objects.equals(sipUri, profile.getUriString())) {
+ startSipServiceForProfile(profile, sipManager, context, isReceivingCalls);
}
}
diff --git a/sip/src/com/android/services/telephony/sip/SipBroadcastReceiver.java b/sip/src/com/android/services/telephony/sip/SipBroadcastReceiver.java
index d3d274d..0b701ce 100644
--- a/sip/src/com/android/services/telephony/sip/SipBroadcastReceiver.java
+++ b/sip/src/com/android/services/telephony/sip/SipBroadcastReceiver.java
@@ -51,20 +51,6 @@
if (VERBOSE) log("SIP_REMOVE_PHONE " +
intent.getStringExtra(SipManager.EXTRA_LOCAL_URI));
sipAccountRegistry.removeSipProfile(intent.getStringExtra(SipManager.EXTRA_LOCAL_URI));
- } else if (action.equals(TelecomManager.ACTION_PHONE_ACCOUNT_ENABLED)) {
- PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(
- TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
- if (phoneAccountHandle == null) {
- return;
- }
- sipAccountRegistry.setPhoneAccountEnabled(context, phoneAccountHandle);
- } else if (action.equals(TelecomManager.ACTION_PHONE_ACCOUNT_DISABLED)) {
- PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(
- TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
- if (phoneAccountHandle == null) {
- return;
- }
- sipAccountRegistry.setPhoneAccountDisabled(context, phoneAccountHandle);
} else {
if (VERBOSE) log("onReceive, action not processed: " + action);
}
diff --git a/sip/src/com/android/services/telephony/sip/SipSettings.java b/sip/src/com/android/services/telephony/sip/SipSettings.java
index 875b312..525fd0f 100644
--- a/sip/src/com/android/services/telephony/sip/SipSettings.java
+++ b/sip/src/com/android/services/telephony/sip/SipSettings.java
@@ -99,8 +99,7 @@
void setProfile(SipProfile p) {
mProfile = p;
setTitle(getProfileName(p));
- boolean isEnabled = SipUtil.isPhoneAccountEnabled(getContext(), p);
- updateSummary(isEnabled && mSipSharedPreferences.isReceivingCallsEnabled()
+ updateSummary(mSipSharedPreferences.isReceivingCallsEnabled()
? getString(R.string.registration_status_checking_status)
: getString(R.string.registration_status_not_receiving));
}
@@ -300,8 +299,7 @@
if (!mSipSharedPreferences.isReceivingCallsEnabled()) return;
for (SipProfile p : mSipProfileList) {
- if (mUid == p.getCallingUid() &&
- SipUtil.isPhoneAccountEnabled(getApplicationContext(), p)) {
+ if (mUid == p.getCallingUid()) {
try {
mSipManager.setRegistrationListener(
p.getUriString(), createRegistrationListener());
diff --git a/sip/src/com/android/services/telephony/sip/SipUtil.java b/sip/src/com/android/services/telephony/sip/SipUtil.java
index 458aaeb..e4d5d4c 100644
--- a/sip/src/com/android/services/telephony/sip/SipUtil.java
+++ b/sip/src/com/android/services/telephony/sip/SipUtil.java
@@ -95,20 +95,6 @@
}
/**
- * Determines if the {@link android.tlecom.PhoneAccount} associated with a {@link SipProfile}
- * is enabled.
- *
- * @param context The {@link Context}.
- * @param profile The {@link SipProfile}.
- * @return {@code True} if the {@code PhoneAccount} is enabled.
- */
- static boolean isPhoneAccountEnabled(Context context, SipProfile profile) {
- PhoneAccount phoneAccount = TelecomManager.from(context)
- .getPhoneAccount(SipUtil.createAccountHandle(context, profile.getUriString()));
- return phoneAccount != null && phoneAccount.isEnabled();
- }
-
- /**
* Creates a PhoneAccount for a SipProfile.
*
* @param context The context
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.