Add default Dialer preference to Settings
Add a Default phone app setting under wireless settings, and also
a dialog activity that allows a user to confirm the selection of an
application as a default phone app.
Bug: 6948882
Bug: 15021725
Change-Id: I2c1473feba20da01b14fbd30dbecc01be560479d
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 507445f..17234e9 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -41,6 +41,7 @@
import android.preference.PreferenceScreen;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
+import android.telecomm.PhoneApplication;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -74,6 +75,7 @@
private static final String KEY_SMS_APPLICATION = "sms_application";
private static final String KEY_TOGGLE_NSD = "toggle_nsd"; //network service discovery
private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
+ private static final String KEY_PHONE_APPLICATION = "phone_application";
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
public static final int REQUEST_CODE_EXIT_ECM = 1;
@@ -93,6 +95,7 @@
private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
private AppListPreference mSmsApplicationPreference;
+ private AppListPreference mDialerApplicationPreference;
public WirelessSettings() {
super(null);
@@ -202,6 +205,24 @@
mSmsApplicationPreference.setPackageNames(packageNames, defaultPackageName);
}
+ private void initDialerApplicationSetting() {
+ log("initDialerApplicationSetting:");
+ final List<ComponentName> dialers =
+ PhoneApplication.getInstalledPhoneApplications(getActivity());
+
+ final int count = dialers.size();
+ final String[] packageNames = new String[count];
+ for (int i = 0; i < count; i++) {
+ packageNames[i] = dialers.get(i).getPackageName();
+ }
+ String defaultPackageName = null;
+ final ComponentName appName = PhoneApplication.getDefaultPhoneApplication(getActivity());
+ if (appName != null) {
+ defaultPackageName = appName.getPackageName();
+ }
+ mDialerApplicationPreference.setPackageNames(packageNames, defaultPackageName);
+ }
+
@Override
public Dialog onCreateDialog(int dialogId) {
log("onCreateDialog: dialogId=" + dialogId);
@@ -242,6 +263,10 @@
return mTm.isSmsCapable();
}
+ private boolean isVoiceCapable() {
+ return mTm.isVoiceCapable();
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -272,6 +297,10 @@
mSmsApplicationPreference.setOnPreferenceChangeListener(this);
initSmsApplicationSetting();
+ mDialerApplicationPreference = (AppListPreference) findPreference(KEY_PHONE_APPLICATION);
+ mDialerApplicationPreference.setOnPreferenceChangeListener(this);
+ initDialerApplicationSetting();
+
// Remove NSD checkbox by default
getPreferenceScreen().removePreference(nsd);
//mNsdEnabler = new NsdEnabler(activity, nsd);
@@ -346,6 +375,11 @@
removePreference(KEY_SMS_APPLICATION);
}
+ // Remove Dialer setting if the device does not support voice
+ if (!isVoiceCapable()) {
+ removePreference(KEY_PHONE_APPLICATION);
+ }
+
// Remove Airplane Mode settings if it's a stationary device such as a TV.
if (mPm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
removePreference(KEY_TOGGLE_AIRPLANE);
@@ -454,6 +488,9 @@
if (preference == mSmsApplicationPreference && newValue != null) {
SmsApplication.setDefaultApplication(newValue.toString(), getActivity());
return true;
+ } else if (preference == mDialerApplicationPreference && newValue != null) {
+ PhoneApplication.setDefaultPhoneApplication(newValue.toString(), getActivity());
+ return true;
}
return false;
}
@@ -513,12 +550,17 @@
}
// Remove SMS Application if the device does not support SMS
- TelephonyManager tm =
+ final TelephonyManager tm =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (!tm.isSmsCapable()) {
result.add(KEY_SMS_APPLICATION);
}
+ // Remove Phone Application if the device is not voice capable
+ if (!tm.isVoiceCapable()) {
+ result.add(KEY_PHONE_APPLICATION);
+ }
+
final PackageManager pm = context.getPackageManager();
// Remove Airplane Mode settings if it's a stationary device such as a TV.
@@ -530,8 +572,8 @@
result.add(KEY_PROXY_SETTINGS);
// Disable Tethering if it's not allowed or if it's a wifi-only device
- ConnectivityManager cm =
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(
+ Context.CONNECTIVITY_SERVICE);
if (isSecondaryUser || !cm.isTetheringSupported()) {
result.add(KEY_TETHER_SETTINGS);
}