blob: b5e8026d7bcdfef4699975f2964ba610a025fdad [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.phone;
18
19import android.app.ActionBar;
20import android.app.Activity;
Evan Charlton1c696832014-04-15 14:24:23 -070021import android.app.ActivityOptions;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070022import android.app.AlertDialog;
23import android.app.Dialog;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070024import android.content.ContentResolver;
25import android.content.Context;
26import android.content.DialogInterface;
27import android.content.Intent;
Yorke Lee0b8d2252015-06-10 16:31:20 -070028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070030import android.os.Bundle;
Jonathan Basseric31f1f32015-05-12 10:13:03 -070031import android.os.PersistableBundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070032import android.os.UserHandle;
Xiaohui Chen9dc2bea2015-10-14 11:42:04 -070033import android.os.UserManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070034import android.preference.CheckBoxPreference;
35import android.preference.ListPreference;
36import android.preference.Preference;
37import android.preference.PreferenceActivity;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070038import android.preference.PreferenceScreen;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070039import android.provider.Settings;
Tyler Gunn4d45d1c2014-09-12 22:17:53 -070040import android.telecom.PhoneAccountHandle;
41import android.telecom.TelecomManager;
Jonathan Basseri4b40ff42015-04-30 21:54:10 -070042import android.telephony.CarrierConfigManager;
pkanwarb4aef112016-07-17 15:39:30 -070043import android.telephony.PhoneStateListener;
Andrew Lee93c345f2014-10-27 15:25:07 -070044import android.telephony.TelephonyManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070045import android.text.TextUtils;
46import android.util.Log;
47import android.view.MenuItem;
Jay Shraunerc2684732014-11-12 12:10:37 -080048import android.widget.Toast;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070049
Andrew Leeeffef9c2015-02-19 16:02:37 -080050import com.android.ims.ImsConfig;
Andrew Lee312e8172014-10-23 17:01:36 -070051import com.android.ims.ImsManager;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070052import com.android.internal.telephony.CallForwardInfo;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070053import com.android.internal.telephony.Phone;
54import com.android.internal.telephony.PhoneConstants;
Andrew Lee2170a972014-08-13 18:13:01 -070055import com.android.phone.common.util.SettingsUtil;
Andrew Leedb2fe562014-09-03 15:40:43 -070056import com.android.phone.settings.AccountSelectionPreference;
Santos Cordon499378a2015-06-25 18:51:39 -070057import com.android.phone.settings.PhoneAccountSettingsFragment;
Andrew Leebf07f762015-04-07 19:05:50 -070058import com.android.phone.settings.VoicemailSettingsActivity;
Andrew Lee5ed870c2014-10-29 11:47:49 -070059import com.android.phone.settings.fdn.FdnSetting;
Sailesh Nepal788959e2014-07-08 23:36:40 -070060import com.android.services.telephony.sip.SipUtil;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070061
Andrew Lee2170a972014-08-13 18:13:01 -070062import java.lang.String;
Andrew Leef1776d82014-11-04 14:45:02 -080063import java.util.ArrayList;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070064import java.util.List;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070065
66/**
67 * Top level "Call settings" UI; see res/xml/call_feature_setting.xml
68 *
Andrew Leece8ae2a2014-09-10 10:41:48 -070069 * This preference screen is the root of the "Call settings" hierarchy available from the Phone
70 * app; the settings here let you control various features related to phone calls (including
71 * voicemail settings, the "Respond via SMS" feature, and others.) It's used only on
72 * voice-capable phone devices.
Santos Cordon7d4ddf62013-07-10 11:58:08 -070073 *
74 * Note that this activity is part of the package com.android.phone, even
75 * though you reach it from the "Phone" app (i.e. DialtactsActivity) which
76 * is from the package com.android.contacts.
77 *
78 * For the "Mobile network settings" screen under the main Settings app,
79 * See {@link MobileNetworkSettings}.
80 *
81 * @see com.android.phone.MobileNetworkSettings
82 */
83public class CallFeaturesSetting extends PreferenceActivity
Andrew Leebf07f762015-04-07 19:05:50 -070084 implements Preference.OnPreferenceChangeListener {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070085 private static final String LOG_TAG = "CallFeaturesSetting";
86 private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
87
Santos Cordon7d4ddf62013-07-10 11:58:08 -070088 // String keys for preference lookup
89 // TODO: Naming these "BUTTON_*" is confusing since they're not actually buttons(!)
Andrew Lee8d66d812014-11-24 14:54:02 -080090 // TODO: Consider moving these strings to strings.xml, so that they are not duplicated here and
91 // in the layout files. These strings need to be treated carefully; if the setting is
92 // persistent, they are used as the key to store shared preferences and the name should not be
93 // changed unless the settings are also migrated.
Andrew Lee97708a42014-09-25 12:39:07 -070094 private static final String VOICEMAIL_SETTING_SCREEN_PREF_KEY = "button_voicemail_category_key";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070095 private static final String BUTTON_FDN_KEY = "button_fdn_key";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070096 private static final String BUTTON_RETRY_KEY = "button_auto_retry_key";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070097 private static final String BUTTON_GSM_UMTS_OPTIONS = "button_gsm_more_expand_key";
98 private static final String BUTTON_CDMA_OPTIONS = "button_cdma_more_expand_key";
99
Andrew Leece8ae2a2014-09-10 10:41:48 -0700100 private static final String PHONE_ACCOUNT_SETTINGS_KEY =
101 "phone_account_settings_preference_screen";
Andrew Leedb2fe562014-09-03 15:40:43 -0700102
Andrew Leedf14ead2014-10-17 14:22:52 -0700103 private static final String ENABLE_VIDEO_CALLING_KEY = "button_enable_video_calling";
104
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700105 private Phone mPhone;
Andrew Lee5ed870c2014-10-29 11:47:49 -0700106 private SubscriptionInfoHelper mSubscriptionInfoHelper;
Yorke Lee0b8d2252015-06-10 16:31:20 -0700107 private TelecomManager mTelecomManager;
Andrew Lee5ed870c2014-10-29 11:47:49 -0700108
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700109 private CheckBoxPreference mButtonAutoRetry;
Andrew Lee97708a42014-09-25 12:39:07 -0700110 private PreferenceScreen mVoicemailSettingsScreen;
Andrew Leedf14ead2014-10-17 14:22:52 -0700111 private CheckBoxPreference mEnableVideoCalling;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700112
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700113 /*
114 * Click Listeners, handle click based on objects attached to UI.
115 */
116
117 // Click listener for all toggle events
118 @Override
119 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
Andrew Leebf07f762015-04-07 19:05:50 -0700120 if (preference == mButtonAutoRetry) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700121 android.provider.Settings.Global.putInt(mPhone.getContext().getContentResolver(),
122 android.provider.Settings.Global.CALL_AUTO_RETRY,
123 mButtonAutoRetry.isChecked() ? 1 : 0);
124 return true;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700125 }
126 return false;
127 }
128
129 /**
130 * Implemented to support onPreferenceChangeListener to look for preference
131 * changes.
132 *
133 * @param preference is the preference to be changed
134 * @param objValue should be the value of the selection, NOT its localized
135 * display value.
136 */
137 @Override
138 public boolean onPreferenceChange(Preference preference, Object objValue) {
Andrew Lee4ddb9bb2014-11-05 15:03:20 -0800139 if (DBG) log("onPreferenceChange: \"" + preference + "\" changed to \"" + objValue + "\"");
Andrew Lee2170a972014-08-13 18:13:01 -0700140
Andrew Leebf07f762015-04-07 19:05:50 -0700141 if (preference == mEnableVideoCalling) {
Andrew Lee312e8172014-10-23 17:01:36 -0700142 if (ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mPhone.getContext())) {
143 PhoneGlobals.getInstance().phoneMgr.enableVideoCalling((boolean) objValue);
144 } else {
145 AlertDialog.Builder builder = new AlertDialog.Builder(this);
146 DialogInterface.OnClickListener networkSettingsClickListener =
147 new Dialog.OnClickListener() {
148 @Override
149 public void onClick(DialogInterface dialog, int which) {
150 startActivity(new Intent(mPhone.getContext(),
151 com.android.phone.MobileNetworkSettings.class));
152 }
153 };
154 builder.setMessage(getResources().getString(
155 R.string.enable_video_calling_dialog_msg))
156 .setNeutralButton(getResources().getString(
157 R.string.enable_video_calling_dialog_settings),
158 networkSettingsClickListener)
159 .setPositiveButton(android.R.string.ok, null)
160 .show();
161 return false;
162 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700163 }
Andrew Lee4ddb9bb2014-11-05 15:03:20 -0800164
165 // Always let the preference setting proceed.
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700166 return true;
167 }
168
169 @Override
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700170 protected void onCreate(Bundle icicle) {
171 super.onCreate(icicle);
Andrew Lee4ddb9bb2014-11-05 15:03:20 -0800172 if (DBG) log("onCreate: Intent is " + getIntent());
173
Xiaohui Chen9dc2bea2015-10-14 11:42:04 -0700174 // Make sure we are running as an admin user.
175 if (!UserManager.get(this).isAdminUser()) {
176 Toast.makeText(this, R.string.call_settings_admin_user_only,
Jay Shraunerc2684732014-11-12 12:10:37 -0800177 Toast.LENGTH_SHORT).show();
178 finish();
179 return;
180 }
181
Andrew Leedd4f6df2014-12-09 19:13:51 -0800182 mSubscriptionInfoHelper = new SubscriptionInfoHelper(this, getIntent());
Andrew Lee5ed870c2014-10-29 11:47:49 -0700183 mSubscriptionInfoHelper.setActionBarTitle(
184 getActionBar(), getResources(), R.string.call_settings_with_label);
Andrew Lee1479dd12014-11-06 23:06:32 -0800185 mPhone = mSubscriptionInfoHelper.getPhone();
Yorke Lee0b8d2252015-06-10 16:31:20 -0700186 mTelecomManager = TelecomManager.from(this);
Tyler Gunnbaee2952014-09-10 16:01:02 -0700187 }
188
pkanwarb4aef112016-07-17 15:39:30 -0700189 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
190 @Override
191 public void onCallStateChanged(int state, String incomingNumber) {
192 if (DBG) log("PhoneStateListener onCallStateChanged: state is " + state);
193 if (mEnableVideoCalling != null) {
194 mEnableVideoCalling.setEnabled(state == TelephonyManager.CALL_STATE_IDLE);
195 }
196 }
197 };
198
199 @Override
200 protected void onPause() {
pkanwar0a663122016-07-19 12:26:44 -0700201 super.onPause();
pkanwarb4aef112016-07-17 15:39:30 -0700202 TelephonyManager telephonyManager =
203 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
204 telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
205 }
206
Tyler Gunnbaee2952014-09-10 16:01:02 -0700207 @Override
208 protected void onResume() {
209 super.onResume();
Tyler Gunnbaee2952014-09-10 16:01:02 -0700210
211 PreferenceScreen preferenceScreen = getPreferenceScreen();
212 if (preferenceScreen != null) {
213 preferenceScreen.removeAll();
214 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700215
216 addPreferencesFromResource(R.xml.call_feature_setting);
Andrew Lee5ed870c2014-10-29 11:47:49 -0700217
Andrew Lee6fee2cb2014-12-09 16:42:18 -0800218 TelephonyManager telephonyManager =
219 (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
pkanwarb4aef112016-07-17 15:39:30 -0700220 telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
Andrew Lee6fee2cb2014-12-09 16:42:18 -0800221
222 Preference phoneAccountSettingsPreference = findPreference(PHONE_ACCOUNT_SETTINGS_KEY);
Santos Cordonc9c48432015-06-12 17:01:21 -0700223 if (telephonyManager.isMultiSimEnabled() || !SipUtil.isVoipSupported(mPhone.getContext())) {
Andrew Lee6fee2cb2014-12-09 16:42:18 -0800224 getPreferenceScreen().removePreference(phoneAccountSettingsPreference);
225 }
Andrew Leedb2fe562014-09-03 15:40:43 -0700226
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700227 PreferenceScreen prefSet = getPreferenceScreen();
Andrew Lee2c027892014-10-29 11:29:54 -0700228 mVoicemailSettingsScreen =
229 (PreferenceScreen) findPreference(VOICEMAIL_SETTING_SCREEN_PREF_KEY);
Andrew Leebf07f762015-04-07 19:05:50 -0700230 mVoicemailSettingsScreen.setIntent(mSubscriptionInfoHelper.getIntent(
231 VoicemailSettingsActivity.class));
Andrew Lee8d66d812014-11-24 14:54:02 -0800232
Andrew Leebf07f762015-04-07 19:05:50 -0700233 mButtonAutoRetry = (CheckBoxPreference) findPreference(BUTTON_RETRY_KEY);
Andrew Lee64e5c9d2014-11-26 12:00:10 -0800234
235 mEnableVideoCalling = (CheckBoxPreference) findPreference(ENABLE_VIDEO_CALLING_KEY);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700236
Jonathan Basseric31f1f32015-05-12 10:13:03 -0700237 PersistableBundle carrierConfig =
238 PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
Jonathan Basseri4b40ff42015-04-30 21:54:10 -0700239
Jonathan Basseri9504c6b2015-06-04 14:23:32 -0700240 if (carrierConfig.getBoolean(CarrierConfigManager.KEY_AUTO_RETRY_ENABLED_BOOL)) {
Andrew Lee64a7d792014-10-15 17:38:38 -0700241 mButtonAutoRetry.setOnPreferenceChangeListener(this);
242 int autoretry = Settings.Global.getInt(
243 getContentResolver(), Settings.Global.CALL_AUTO_RETRY, 0);
244 mButtonAutoRetry.setChecked(autoretry != 0);
245 } else {
246 prefSet.removePreference(mButtonAutoRetry);
247 mButtonAutoRetry = null;
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700248 }
249
Sanket Padawee09a6f62015-03-05 11:59:39 -0800250 Preference cdmaOptions = prefSet.findPreference(BUTTON_CDMA_OPTIONS);
251 Preference gsmOptions = prefSet.findPreference(BUTTON_GSM_UMTS_OPTIONS);
Jonathan Basseri9504c6b2015-06-04 14:23:32 -0700252 if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
Sanket Padawee09a6f62015-03-05 11:59:39 -0800253 cdmaOptions.setIntent(mSubscriptionInfoHelper.getIntent(CdmaCallOptions.class));
254 gsmOptions.setIntent(mSubscriptionInfoHelper.getIntent(GsmUmtsCallOptions.class));
255 } else {
Andrew Lee2b36ba22014-11-05 17:08:49 -0800256 prefSet.removePreference(cdmaOptions);
Andrew Lee2b36ba22014-11-05 17:08:49 -0800257 prefSet.removePreference(gsmOptions);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700258
259 int phoneType = mPhone.getPhoneType();
Andrew Lee5ed870c2014-10-29 11:47:49 -0700260 Preference fdnButton = prefSet.findPreference(BUTTON_FDN_KEY);
Junda Liua9ba9d42015-06-01 01:26:52 -0700261 if (carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)) {
Andrew Lee5ed870c2014-10-29 11:47:49 -0700262 prefSet.removePreference(fdnButton);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700263 } else {
Junda Liua09d6962014-11-12 13:39:02 -0800264 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
265 prefSet.removePreference(fdnButton);
266
Jonathan Basseri9504c6b2015-06-04 14:23:32 -0700267 if (!carrierConfig.getBoolean(
Jonathan Basseri38c58552015-06-09 15:14:06 -0700268 CarrierConfigManager.KEY_VOICE_PRIVACY_DISABLE_UI_BOOL)) {
Junda Liua09d6962014-11-12 13:39:02 -0800269 addPreferencesFromResource(R.xml.cdma_call_privacy);
270 }
271 } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
Andrew Leedd4f6df2014-12-09 19:13:51 -0800272 fdnButton.setIntent(mSubscriptionInfoHelper.getIntent(FdnSetting.class));
Junda Liua09d6962014-11-12 13:39:02 -0800273
Jonathan Basseri9504c6b2015-06-04 14:23:32 -0700274 if (carrierConfig.getBoolean(
275 CarrierConfigManager.KEY_ADDITIONAL_CALL_SETTING_BOOL)) {
Junda Liua09d6962014-11-12 13:39:02 -0800276 addPreferencesFromResource(R.xml.gsm_umts_call_options);
Sanket Padawee09a6f62015-03-05 11:59:39 -0800277 GsmUmtsCallOptions.init(prefSet, mSubscriptionInfoHelper);
Junda Liua09d6962014-11-12 13:39:02 -0800278 }
279 } else {
280 throw new IllegalStateException("Unexpected phone type: " + phoneType);
281 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700282 }
283 }
284
Jack Yu75ab2952016-07-08 14:29:33 -0700285 if (ImsManager.isVtEnabledByPlatform(mPhone.getContext()) &&
Amit Mahajan26b5b8e2016-07-21 14:41:38 -0700286 ImsManager.isVtProvisionedOnDevice(mPhone.getContext()) &&
Jack Yub7628322016-11-28 11:10:18 -0800287 (carrierConfig.getBoolean(
288 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
289 || mPhone.mDcTracker.isDataEnabled(true))) {
Andrew Lee312e8172014-10-23 17:01:36 -0700290 boolean currentValue =
291 ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mPhone.getContext())
Svet Ganovb320e182015-04-16 12:30:10 -0700292 ? PhoneGlobals.getInstance().phoneMgr.isVideoCallingEnabled(
293 getOpPackageName()) : false;
Andrew Lee312e8172014-10-23 17:01:36 -0700294 mEnableVideoCalling.setChecked(currentValue);
Andrew Lee77527ac2014-10-21 16:57:39 -0700295 mEnableVideoCalling.setOnPreferenceChangeListener(this);
296 } else {
297 prefSet.removePreference(mEnableVideoCalling);
298 }
Etan Cohena51d4ef2014-12-15 10:44:42 -0800299
300 if (ImsManager.isVolteEnabledByPlatform(this) &&
Junda Liu08a208a2015-06-23 15:06:00 -0700301 !carrierConfig.getBoolean(
302 CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL)) {
Etan Cohena51d4ef2014-12-15 10:44:42 -0800303 TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Vinit Deshpande84cccac2015-03-16 00:08:19 -0700304 /* tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); */
Etan Cohena51d4ef2014-12-15 10:44:42 -0800305 }
Andrew Leeb97fad82015-01-27 15:31:39 -0800306
Andrew Leeeffef9c2015-02-19 16:02:37 -0800307 Preference wifiCallingSettings = findPreference(
308 getResources().getString(R.string.wifi_calling_settings_key));
Yorke Lee0b8d2252015-06-10 16:31:20 -0700309
310 final PhoneAccountHandle simCallManager = mTelecomManager.getSimCallManager();
Santos Cordon499378a2015-06-25 18:51:39 -0700311 if (simCallManager != null) {
312 Intent intent = PhoneAccountSettingsFragment.buildPhoneAccountConfigureIntent(
313 this, simCallManager);
314 if (intent != null) {
Abhishek Guptaa134adb2016-04-14 18:57:31 -0700315 PackageManager pm = mPhone.getContext().getPackageManager();
316 List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
317 if (!resolutions.isEmpty()) {
318 wifiCallingSettings.setTitle(resolutions.get(0).loadLabel(pm));
319 wifiCallingSettings.setSummary(null);
320 wifiCallingSettings.setIntent(intent);
321 } else {
322 prefSet.removePreference(wifiCallingSettings);
323 }
Yorke Lee0b8d2252015-06-10 16:31:20 -0700324 } else {
325 prefSet.removePreference(wifiCallingSettings);
326 }
Pavel Zhamaitsiak87c43792016-06-20 14:06:02 -0700327 } else if (!ImsManager.isWfcEnabledByPlatform(mPhone.getContext()) ||
328 !ImsManager.isWfcProvisionedOnDevice(mPhone.getContext())) {
Andrew Leeb97fad82015-01-27 15:31:39 -0800329 prefSet.removePreference(wifiCallingSettings);
Andrew Leeeffef9c2015-02-19 16:02:37 -0800330 } else {
Pavel Zhamaitsiakecae65a2015-03-23 14:45:34 -0700331 int resId = com.android.internal.R.string.wifi_calling_off_summary;
Andrew Leeeffef9c2015-02-19 16:02:37 -0800332 if (ImsManager.isWfcEnabledByUser(mPhone.getContext())) {
333 int wfcMode = ImsManager.getWfcMode(mPhone.getContext());
334 switch (wfcMode) {
335 case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
Pavel Zhamaitsiakecae65a2015-03-23 14:45:34 -0700336 resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
Andrew Leeeffef9c2015-02-19 16:02:37 -0800337 break;
338 case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED:
Pavel Zhamaitsiakecae65a2015-03-23 14:45:34 -0700339 resId = com.android.internal.R.string.wfc_mode_cellular_preferred_summary;
Andrew Leeeffef9c2015-02-19 16:02:37 -0800340 break;
341 case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED:
Pavel Zhamaitsiakecae65a2015-03-23 14:45:34 -0700342 resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary;
Andrew Leeeffef9c2015-02-19 16:02:37 -0800343 break;
344 default:
345 if (DBG) log("Unexpected WFC mode value: " + wfcMode);
346 }
347 }
348 wifiCallingSettings.setSummary(resId);
Andrew Leeb97fad82015-01-27 15:31:39 -0800349 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700350 }
351
Andrew Lee785ca2a2014-12-18 12:46:41 -0800352 @Override
353 protected void onNewIntent(Intent newIntent) {
354 setIntent(newIntent);
355
356 mSubscriptionInfoHelper = new SubscriptionInfoHelper(this, getIntent());
357 mSubscriptionInfoHelper.setActionBarTitle(
358 getActionBar(), getResources(), R.string.call_settings_with_label);
359 mPhone = mSubscriptionInfoHelper.getPhone();
360 }
361
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700362 private static void log(String msg) {
363 Log.d(LOG_TAG, msg);
364 }
365
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700366 @Override
367 public boolean onOptionsItemSelected(MenuItem item) {
368 final int itemId = item.getItemId();
369 if (itemId == android.R.id.home) { // See ActionBar#setDisplayHomeAsUpEnabled()
Yorke Leef2d0cac2013-09-09 19:42:56 -0700370 onBackPressed();
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700371 return true;
372 }
373 return super.onOptionsItemSelected(item);
374 }
Andrew Lee8d66d812014-11-24 14:54:02 -0800375
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700376 /**
377 * Finish current Activity and go up to the top level Settings ({@link CallFeaturesSetting}).
378 * This is useful for implementing "HomeAsUp" capability for second-level Settings.
379 */
Andrew Lee5efb1122014-12-05 04:20:42 -0800380 public static void goUpToTopLevelSetting(
Andrew Leedd4f6df2014-12-09 19:13:51 -0800381 Activity activity, SubscriptionInfoHelper subscriptionInfoHelper) {
382 Intent intent = subscriptionInfoHelper.getIntent(CallFeaturesSetting.class);
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700383 intent.setAction(Intent.ACTION_MAIN);
384 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
385 activity.startActivity(intent);
386 activity.finish();
387 }
388}