Move Wi-Fi call configuration to third-party app
Allow the third-party app to control Wi-Fi calling settings (when to
use it, which account to use).
Change-Id: I382591aaac483870ba299d36b44c0b727be3d33f
diff --git a/res/values/array.xml b/res/values/array.xml
index c8c2e61..245c09b 100644
--- a/res/values/array.xml
+++ b/res/values/array.xml
@@ -39,19 +39,6 @@
<item>@string/sip_ask_me_each_time</item>
</string-array>
- <string-array translatable="true" name="wifi_calling_choice_entries">
- <item>@string/wifi_calling_choice_entry_always_use</item>
- <item>@string/wifi_calling_choice_entry_ask_every_time</item>
- <item>@string/wifi_calling_choice_entry_never_use</item>
- </string-array>
-
- <!-- android.telephony.TelephonyManager.WifiCallingChoices -->
- <string-array translatable="false" name="wifi_calling_choice_values">
- <item>@string/wifi_calling_choices_always_use</item>
- <item>@string/wifi_calling_choices_ask_every_time</item>
- <item>@string/wifi_calling_choices_never_use</item>
- </string-array>
-
<string-array translatable="false" name="phone_type_values">
<item>@string/pstn_phone</item>
<item>@string/internet_phone</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 16c52e1..9be0e2e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1159,16 +1159,12 @@
<string name="wifi_settings">Wi-Fi call settings</string>
<!-- Title of option allowing user to pick when to make Wi-Fi calls [CHAR LIMIT=NONE] -->
<string name="when_to_make_wifi_calls_title">When to make Wi-Fi calls</string>
- <!-- Item of Wi-Fi settings: For always using Wi-Fi to make calls. [CHAR LIMIT=NONE] -->
- <string name="wifi_calling_choice_entry_always_use">Always use Wi-Fi to make calls</string>
- <!-- Item of Wi-Fi settings: For never using Wi-Fi to make calls. [CHAR LIMIT=NONE] -->
- <string name="wifi_calling_choice_entry_never_use">Never use Wi-Fi to make calls</string>
- <!-- Item of Wi-Fi settings: For asking each time whether to use Wi-Fi. [CHAR LIMIT=NONE] -->
- <string name="wifi_calling_choice_entry_ask_every_time">Always ask</string>
-
- <string translatable="false" name="wifi_calling_choices_always_use">ALWAYS_USE</string>
- <string translatable="false" name="wifi_calling_choices_never_use">NEVER_USE</string>
- <string translatable="false" name="wifi_calling_choices_ask_every_time">ASK_EVERY_TIME</string>
+ <!-- Summary of option allowing user to pick when to make Wi-Fi calls [CHAR LIMIT=NONE] -->
+ <string name="when_to_make_wifi_calls_summary">Control when to place calls using Wi-Fi</string>
+ <!-- Title of option allowing user to pick account used to make Wi-Fi calls [CHAR LIMIT=NONE]-->
+ <string name="wifi_calling_account_title">Wi-Fi calling account</string>
+ <!-- Summary of option allowing user to pick account used to make Wi-Fi calls [CHAR LIMIT=NONE] -->
+ <string name="wifi_calling_account_summary">Pick which account is used for to place Wi-Fi calls</string>
<!-- Title of the dialog to select the phone type for the outgoing call. [CHAR LIMIT=NONE] -->
<string name ="pick_outgoing_call_phone_type">Place call</string>
diff --git a/res/xml/wifi_settings_category.xml b/res/xml/wifi_settings_category.xml
index 91041fd..25f95e8 100644
--- a/res/xml/wifi_settings_category.xml
+++ b/res/xml/wifi_settings_category.xml
@@ -20,12 +20,24 @@
android:title="@string/wifi_settings"
android:persistent="false">
- <ListPreference
+ <Preference
android:key="when_to_make_wifi_calls_key"
android:title="@string/when_to_make_wifi_calls_title"
- android:persistent="true"
- android:entries="@array/wifi_calling_choice_entries"
- android:entryValues="@array/wifi_calling_choice_values"/>
+ android:summary="@string/when_to_make_wifi_calls_summary"
+ android:persistent="false">
+ <intent
+ android:action="android.telecomm.CONTROL_WIFI_CALLING"
+ android:category="android.intent.category.DEFAULT" />
+ </Preference>
+ <Preference
+ android:key="wifi_calling_account_key"
+ android:title="@string/wifi_calling_account_title"
+ android:summary="@string/wifi_calling_account_summary"
+ android:persistent="false">
+ <intent
+ android:action="android.telecomm.CHOOSE_WIFI_CALLING_ACCOUNT"
+ android:category="android.intent.category.DEFAULT" />
+ </Preference>
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 01719b7..d80ef3e 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -18,6 +18,7 @@
import android.app.ActionBar;
import android.app.Activity;
+import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
@@ -95,8 +96,9 @@
public class CallFeaturesSetting extends PreferenceActivity
implements DialogInterface.OnClickListener,
Preference.OnPreferenceChangeListener,
+ Preference.OnPreferenceClickListener,
EditPhoneNumberPreference.OnDialogClosedListener,
- EditPhoneNumberPreference.GetDefaultNumberListener{
+ EditPhoneNumberPreference.GetDefaultNumberListener {
private static final String LOG_TAG = "CallFeaturesSetting";
private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
@@ -193,6 +195,8 @@
private static final String WHEN_TO_MAKE_WIFI_CALLS_KEY =
"when_to_make_wifi_calls_key";
+ private static final String WIFI_CALLING_ACCOUNT_KEY =
+ "wifi_calling_account_key";
private Intent mContactListIntent;
@@ -273,7 +277,8 @@
private ListPreference mButtonDTMF;
private ListPreference mButtonTTY;
private ListPreference mButtonSipCallOptions;
- private ListPreference mWifiCallOptionsPreference;
+ private Preference mWifiCallOptionsPreference;
+ private Preference mWifiCallAccountPreference;
private ListPreference mVoicemailProviders;
private PreferenceScreen mVoicemailSettings;
private Preference mVoicemailNotificationRingtone;
@@ -592,14 +597,20 @@
}
} else if (preference == mButtonSipCallOptions) {
handleSipCallOptionsChange(objValue);
- } else if (preference == mWifiCallOptionsPreference) {
- handleWifiCallSettingsChange(objValue);
}
// always let the preference setting proceed.
return true;
}
@Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (preference == mWifiCallOptionsPreference || preference == mWifiCallAccountPreference) {
+ handleWifiCallSettingsClick(preference);
+ }
+ return true;
+ }
+
+ @Override
public void onDialogClosed(EditPhoneNumberPreference preference, int buttonClicked) {
if (DBG) log("onPreferenceClick: request preference click on dialog close: " +
buttonClicked);
@@ -1742,52 +1753,19 @@
private void createWifiCallSettings() {
addPreferencesFromResource(R.xml.wifi_settings_category);
- mWifiCallOptionsPreference = (ListPreference) findPreference(WHEN_TO_MAKE_WIFI_CALLS_KEY);
- mWifiCallOptionsPreference.setOnPreferenceChangeListener(this);
- mWifiCallOptionsPreference.setValueIndex(
- mWifiCallOptionsPreference.findIndexOfValue(
- getWhenToMakeWifiCalls()));
- mWifiCallOptionsPreference.setSummary(mWifiCallOptionsPreference.getEntry());
+ mWifiCallOptionsPreference = (Preference) findPreference(WHEN_TO_MAKE_WIFI_CALLS_KEY);
+ mWifiCallOptionsPreference.setOnPreferenceClickListener(this);
+ mWifiCallOptionsPreference.setEnabled(
+ canLaunchIntent(mWifiCallOptionsPreference.getIntent()));
+ mWifiCallAccountPreference = (Preference) findPreference(WIFI_CALLING_ACCOUNT_KEY);
+ mWifiCallAccountPreference.setOnPreferenceClickListener(this);
+ mWifiCallAccountPreference.setEnabled(
+ canLaunchIntent(mWifiCallAccountPreference.getIntent()));
}
- /**
- * @see android.telephony.TelephonyManager.WifiCallingChoices
- */
- private String getWhenToMakeWifiCalls() {
- TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
- Context.TELEPHONY_SERVICE);
- int intValue = telephonyManager.getWhenToMakeWifiCalls();
- switch (intValue) {
- case TelephonyManager.WifiCallingChoices.ALWAYS_USE:
- return getString(R.string.wifi_calling_choices_always_use);
- case TelephonyManager.WifiCallingChoices.ASK_EVERY_TIME:
- return getString(R.string.wifi_calling_choices_ask_every_time);
- case TelephonyManager.WifiCallingChoices.NEVER_USE:
- return getString(R.string.wifi_calling_choices_never_use);
- default:
- Log.wtf(LOG_TAG, "unknown wifi call int value: " + intValue);
- return getString(R.string.wifi_calling_choices_always_use);
- }
- }
-
- /**
- * @see android.telephony.TelephonyManager.WifiCallingChoices
- */
- public void setWhenToMakeWifiCalls(String stringValue) {
- TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
- Context.TELEPHONY_SERVICE);
- int intValue;
- if (stringValue.equals(getString(R.string.wifi_calling_choices_always_use))) {
- intValue = TelephonyManager.WifiCallingChoices.ALWAYS_USE;
- } else if (stringValue.equals(getString(R.string.wifi_calling_choices_ask_every_time))) {
- intValue = TelephonyManager.WifiCallingChoices.ASK_EVERY_TIME;
- } else if (stringValue.equals(getString(R.string.wifi_calling_choices_never_use))) {
- intValue = TelephonyManager.WifiCallingChoices.NEVER_USE;
- } else {
- Log.wtf(LOG_TAG, "unknown wifi call string value: " + stringValue);
- return;
- }
- telephonyManager.setWhenToMakeWifiCalls(intValue);
+ private boolean canLaunchIntent(Intent intent) {
+ PackageManager pm = getPackageManager();
+ return pm.resolveActivity(intent, PackageManager.GET_ACTIVITIES) != null;
}
// Gets the call options for SIP depending on whether SIP is allowed only
@@ -1947,12 +1925,13 @@
mButtonSipCallOptions.setSummary(mButtonSipCallOptions.getEntry());
}
- private void handleWifiCallSettingsChange(Object objValue) {
- String option = objValue.toString();
- setWhenToMakeWifiCalls(option);
- mWifiCallOptionsPreference.setValueIndex(
- mWifiCallOptionsPreference.findIndexOfValue(option));
- mWifiCallOptionsPreference.setSummary(mWifiCallOptionsPreference.getEntry());
+ private void handleWifiCallSettingsClick(Preference preference) {
+ Intent intent = preference.getIntent();
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ // TODO - Restrict to a (the?) blessed Wi-Fi calling app.
+
+ Bundle noAnimations = ActivityOptions.makeCustomAnimation(this, 0, 0).toBundle();
+ startActivity(intent, noAnimations);
}
private void updatePreferredTtyModeSummary(int TtyMode) {