1 /* 2 * Copyright (C) 2017 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 17 package com.android.settings.wifi.calling; 18 19 import android.app.Activity; 20 import android.app.settings.SettingsEnums; 21 import android.content.BroadcastReceiver; 22 import android.content.ComponentName; 23 import android.content.Context; 24 import android.content.Intent; 25 import android.content.IntentFilter; 26 import android.content.res.Resources; 27 import android.os.Bundle; 28 import android.os.PersistableBundle; 29 import android.telephony.CarrierConfigManager; 30 import android.telephony.PhoneStateListener; 31 import android.telephony.SubscriptionManager; 32 import android.telephony.TelephonyManager; 33 import android.telephony.ims.ProvisioningManager; 34 import android.text.TextUtils; 35 import android.util.Log; 36 import android.view.LayoutInflater; 37 import android.view.View; 38 import android.view.ViewGroup; 39 import android.widget.Switch; 40 import android.widget.TextView; 41 42 import androidx.appcompat.app.AlertDialog; 43 import androidx.preference.Preference; 44 import androidx.preference.Preference.OnPreferenceClickListener; 45 import androidx.preference.PreferenceScreen; 46 47 import com.android.ims.ImsConfig; 48 import com.android.ims.ImsException; 49 import com.android.ims.ImsManager; 50 import com.android.internal.annotations.VisibleForTesting; 51 import com.android.internal.telephony.Phone; 52 import com.android.settings.R; 53 import com.android.settings.SettingsActivity; 54 import com.android.settings.SettingsPreferenceFragment; 55 import com.android.settings.Utils; 56 import com.android.settings.core.SubSettingLauncher; 57 import com.android.settings.widget.SwitchBar; 58 59 /** 60 * This is the inner class of {@link WifiCallingSettings} fragment. 61 * The preference screen lets you enable/disable Wi-Fi Calling and change Wi-Fi Calling mode. 62 */ 63 public class WifiCallingSettingsForSub extends SettingsPreferenceFragment 64 implements SwitchBar.OnSwitchChangeListener, 65 Preference.OnPreferenceChangeListener { 66 private static final String TAG = "WifiCallingForSub"; 67 68 //String keys for preference lookup 69 private static final String BUTTON_WFC_MODE = "wifi_calling_mode"; 70 private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode"; 71 private static final String PREFERENCE_EMERGENCY_ADDRESS = "emergency_address_key"; 72 73 @VisibleForTesting 74 static final int REQUEST_CHECK_WFC_EMERGENCY_ADDRESS = 1; 75 @VisibleForTesting 76 static final int REQUEST_CHECK_WFC_DISCLAIMER = 2; 77 78 public static final String EXTRA_LAUNCH_CARRIER_APP = "EXTRA_LAUNCH_CARRIER_APP"; 79 public static final String EXTRA_SUB_ID = "EXTRA_SUB_ID"; 80 81 protected static final String FRAGMENT_BUNDLE_SUBID = "subId"; 82 83 public static final int LAUCH_APP_ACTIVATE = 0; 84 public static final int LAUCH_APP_UPDATE = 1; 85 86 //UI objects 87 private SwitchBar mSwitchBar; 88 private Switch mSwitch; 89 private ListWithEntrySummaryPreference mButtonWfcMode; 90 private ListWithEntrySummaryPreference mButtonWfcRoamingMode; 91 private Preference mUpdateAddress; 92 private TextView mEmptyView; 93 94 private boolean mValidListener = false; 95 private boolean mEditableWfcMode = true; 96 private boolean mEditableWfcRoamingMode = true; 97 private boolean mUseWfcHomeModeForRoaming = false; 98 99 private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; 100 private ImsManager mImsManager; 101 private TelephonyManager mTelephonyManager; 102 103 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { 104 /* 105 * Enable/disable controls when in/out of a call and depending on 106 * TTY mode and TTY support over VoLTE. 107 * @see android.telephony.PhoneStateListener#onCallStateChanged(int, 108 * java.lang.String) 109 */ 110 @Override 111 public void onCallStateChanged(int state, String incomingNumber) { 112 final SettingsActivity activity = (SettingsActivity) getActivity(); 113 boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled(); 114 boolean isWfcEnabled = mSwitchBar.isChecked() 115 && isNonTtyOrTtyOnVolteEnabled; 116 117 mSwitchBar.setEnabled((state == TelephonyManager.CALL_STATE_IDLE) 118 && isNonTtyOrTtyOnVolteEnabled); 119 120 boolean isWfcModeEditable = true; 121 boolean isWfcRoamingModeEditable = false; 122 final CarrierConfigManager configManager = (CarrierConfigManager) 123 activity.getSystemService(Context.CARRIER_CONFIG_SERVICE); 124 if (configManager != null) { 125 PersistableBundle b = 126 configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId); 127 if (b != null) { 128 isWfcModeEditable = b.getBoolean( 129 CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL); 130 isWfcRoamingModeEditable = b.getBoolean( 131 CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL); 132 } 133 } 134 135 Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE); 136 if (pref != null) { 137 pref.setEnabled(isWfcEnabled && isWfcModeEditable 138 && (state == TelephonyManager.CALL_STATE_IDLE)); 139 } 140 Preference pref_roam = 141 getPreferenceScreen().findPreference(BUTTON_WFC_ROAMING_MODE); 142 if (pref_roam != null) { 143 pref_roam.setEnabled(isWfcEnabled && isWfcRoamingModeEditable 144 && (state == TelephonyManager.CALL_STATE_IDLE)); 145 } 146 } 147 }; 148 149 /* 150 * Launch carrier emergency address managemnent activity 151 */ 152 private final OnPreferenceClickListener mUpdateAddressListener = 153 preference -> { 154 Intent carrierAppIntent = getCarrierActivityIntent(); 155 if (carrierAppIntent != null) { 156 carrierAppIntent.putExtra(EXTRA_LAUNCH_CARRIER_APP, LAUCH_APP_UPDATE); 157 startActivity(carrierAppIntent); 158 } 159 return true; 160 }; 161 162 private final ProvisioningManager.Callback mProvisioningCallback = 163 new ProvisioningManager.Callback() { 164 @Override 165 public void onProvisioningIntChanged(int item, int value) { 166 if (item == ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED 167 || item == ImsConfig.ConfigConstants.VLT_SETTING_ENABLED) { 168 // The provisioning policy might have changed. Update the body to make sure 169 // this change takes effect if needed. 170 updateBody(); 171 } 172 } 173 }; 174 175 @Override onActivityCreated(Bundle savedInstanceState)176 public void onActivityCreated(Bundle savedInstanceState) { 177 super.onActivityCreated(savedInstanceState); 178 179 mEmptyView = getView().findViewById(android.R.id.empty); 180 setEmptyView(mEmptyView); 181 final Resources res = getResourcesForSubId(); 182 String emptyViewText = res.getString(R.string.wifi_calling_off_explanation, 183 res.getString(R.string.wifi_calling_off_explanation_2)); 184 mEmptyView.setText(emptyViewText); 185 186 mSwitchBar = getView().findViewById(R.id.switch_bar); 187 mSwitchBar.show(); 188 mSwitch = mSwitchBar.getSwitch(); 189 } 190 191 @Override onDestroyView()192 public void onDestroyView() { 193 super.onDestroyView(); 194 mSwitchBar.hide(); 195 } 196 showAlert(Intent intent)197 private void showAlert(Intent intent) { 198 Context context = getActivity(); 199 200 CharSequence title = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_TITLE); 201 CharSequence message = intent.getCharSequenceExtra(Phone.EXTRA_KEY_ALERT_MESSAGE); 202 203 AlertDialog.Builder builder = new AlertDialog.Builder(context); 204 builder.setMessage(message) 205 .setTitle(title) 206 .setIcon(android.R.drawable.ic_dialog_alert) 207 .setPositiveButton(android.R.string.ok, null); 208 AlertDialog dialog = builder.create(); 209 dialog.show(); 210 } 211 212 private IntentFilter mIntentFilter; 213 214 private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { 215 @Override 216 public void onReceive(Context context, Intent intent) { 217 String action = intent.getAction(); 218 if (action.equals(ImsManager.ACTION_IMS_REGISTRATION_ERROR)) { 219 // If this fragment is active then we are immediately 220 // showing alert on screen. There is no need to add 221 // notification in this case. 222 // 223 // In order to communicate to ImsPhone that it should 224 // not show notification, we are changing result code here. 225 setResultCode(Activity.RESULT_CANCELED); 226 227 showAlert(intent); 228 } 229 } 230 }; 231 232 @Override getMetricsCategory()233 public int getMetricsCategory() { 234 return SettingsEnums.WIFI_CALLING_FOR_SUB; 235 } 236 237 @Override getHelpResource()238 public int getHelpResource() { 239 // Return 0 to suppress help icon. The help will be populated by parent page. 240 return 0; 241 } 242 243 @VisibleForTesting getImsManager()244 ImsManager getImsManager() { 245 return ImsManager.getInstance(getActivity(), SubscriptionManager.getPhoneId(mSubId)); 246 } 247 248 @Override onCreate(Bundle savedInstanceState)249 public void onCreate(Bundle savedInstanceState) { 250 super.onCreate(savedInstanceState); 251 252 addPreferencesFromResource(R.xml.wifi_calling_settings); 253 254 // SubId should always be specified when creating this fragment. Either through 255 // fragment.setArguments() or through savedInstanceState. 256 if (getArguments() != null && getArguments().containsKey(FRAGMENT_BUNDLE_SUBID)) { 257 mSubId = getArguments().getInt(FRAGMENT_BUNDLE_SUBID); 258 } else if (savedInstanceState != null) { 259 mSubId = savedInstanceState.getInt( 260 FRAGMENT_BUNDLE_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); 261 } 262 263 mImsManager = getImsManager(); 264 265 mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)) 266 .createForSubscriptionId(mSubId); 267 268 mButtonWfcMode = findPreference(BUTTON_WFC_MODE); 269 mButtonWfcMode.setOnPreferenceChangeListener(this); 270 271 mButtonWfcRoamingMode = findPreference(BUTTON_WFC_ROAMING_MODE); 272 mButtonWfcRoamingMode.setOnPreferenceChangeListener(this); 273 274 mUpdateAddress = findPreference(PREFERENCE_EMERGENCY_ADDRESS); 275 mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener); 276 277 mIntentFilter = new IntentFilter(); 278 mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR); 279 } 280 281 @Override onSaveInstanceState(Bundle outState)282 public void onSaveInstanceState(Bundle outState) { 283 outState.putInt(FRAGMENT_BUNDLE_SUBID, mSubId); 284 super.onSaveInstanceState(outState); 285 } 286 287 @Override onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)288 public View onCreateView(LayoutInflater inflater, ViewGroup container, 289 Bundle savedInstanceState) { 290 291 View view = inflater.inflate( 292 R.layout.wifi_calling_settings_preferences, container, false); 293 294 final ViewGroup prefs_container = view.findViewById(R.id.prefs_container); 295 Utils.prepareCustomPreferencesList(container, view, prefs_container, false); 296 View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState); 297 prefs_container.addView(prefs); 298 299 return view; 300 } 301 updateBody()302 private void updateBody() { 303 if (!mImsManager.isWfcProvisionedOnDevice()) { 304 // This screen is not allowed to be shown due to provisioning policy and should 305 // therefore be closed. 306 finish(); 307 return; 308 } 309 310 CarrierConfigManager configManager = (CarrierConfigManager) 311 getSystemService(Context.CARRIER_CONFIG_SERVICE); 312 boolean isWifiOnlySupported = true; 313 314 if (configManager != null) { 315 PersistableBundle b = configManager.getConfigForSubId(mSubId); 316 if (b != null) { 317 mEditableWfcMode = b.getBoolean( 318 CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL); 319 mEditableWfcRoamingMode = b.getBoolean( 320 CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL); 321 mUseWfcHomeModeForRoaming = b.getBoolean( 322 CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, 323 false); 324 isWifiOnlySupported = b.getBoolean( 325 CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, true); 326 } 327 } 328 329 if (!isWifiOnlySupported) { 330 mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only); 331 mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only); 332 mButtonWfcMode.setEntrySummaries(R.array.wifi_calling_mode_summaries_without_wifi_only); 333 334 mButtonWfcRoamingMode.setEntries( 335 R.array.wifi_calling_mode_choices_v2_without_wifi_only); 336 mButtonWfcRoamingMode.setEntryValues( 337 R.array.wifi_calling_mode_values_without_wifi_only); 338 mButtonWfcRoamingMode.setEntrySummaries( 339 R.array.wifi_calling_mode_summaries_without_wifi_only); 340 } 341 342 343 // NOTE: Buttons will be enabled/disabled in mPhoneStateListener 344 boolean wfcEnabled = mImsManager.isWfcEnabledByUser() 345 && mImsManager.isNonTtyOrTtyOnVolteEnabled(); 346 mSwitch.setChecked(wfcEnabled); 347 int wfcMode = mImsManager.getWfcMode(false); 348 int wfcRoamingMode = mImsManager.getWfcMode(true); 349 mButtonWfcMode.setValue(Integer.toString(wfcMode)); 350 mButtonWfcRoamingMode.setValue(Integer.toString(wfcRoamingMode)); 351 updateButtonWfcMode(wfcEnabled, wfcMode, wfcRoamingMode); 352 } 353 354 @Override onResume()355 public void onResume() { 356 super.onResume(); 357 358 final Context context = getActivity(); 359 360 updateBody(); 361 362 if (mImsManager.isWfcEnabledByPlatform()) { 363 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); 364 365 mSwitchBar.addOnSwitchChangeListener(this); 366 367 mValidListener = true; 368 } 369 370 context.registerReceiver(mIntentReceiver, mIntentFilter); 371 372 Intent intent = getActivity().getIntent(); 373 if (intent.getBooleanExtra(Phone.EXTRA_KEY_ALERT_SHOW, false)) { 374 showAlert(intent); 375 } 376 377 // Register callback for provisioning changes. 378 try { 379 mImsManager.getConfigInterface().addConfigCallback(mProvisioningCallback); 380 } catch (ImsException e) { 381 Log.w(TAG, "onResume: Unable to register callback for provisioning changes."); 382 } 383 384 } 385 386 @Override onPause()387 public void onPause() { 388 super.onPause(); 389 390 final Context context = getActivity(); 391 392 if (mValidListener) { 393 mValidListener = false; 394 395 TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 396 tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); 397 398 mSwitchBar.removeOnSwitchChangeListener(this); 399 } 400 401 context.unregisterReceiver(mIntentReceiver); 402 403 // Remove callback for provisioning changes. 404 try { 405 mImsManager.getConfigInterface().removeConfigCallback( 406 mProvisioningCallback.getBinder()); 407 } catch (ImsException e) { 408 Log.w(TAG, "onPause: Unable to remove callback for provisioning changes"); 409 } 410 411 } 412 413 /** 414 * Listens to the state change of the switch. 415 */ 416 @Override onSwitchChanged(Switch switchView, boolean isChecked)417 public void onSwitchChanged(Switch switchView, boolean isChecked) { 418 Log.d(TAG, "onSwitchChanged(" + isChecked + ")"); 419 420 if (!isChecked) { 421 updateWfcMode(false); 422 return; 423 } 424 425 // Launch disclaimer fragment before turning on WFC 426 final Context context = getActivity(); 427 final Bundle args = new Bundle(); 428 args.putInt(EXTRA_SUB_ID, mSubId); 429 new SubSettingLauncher(context) 430 .setDestination(WifiCallingDisclaimerFragment.class.getName()) 431 .setArguments(args) 432 .setTitleRes(R.string.wifi_calling_settings_title) 433 .setSourceMetricsCategory(getMetricsCategory()) 434 .setResultListener(this, REQUEST_CHECK_WFC_DISCLAIMER) 435 .launch(); 436 } 437 438 /* 439 * Get the Intent to launch carrier emergency address management activity. 440 * Return null when no activity found. 441 */ getCarrierActivityIntent()442 private Intent getCarrierActivityIntent() { 443 // Retrive component name from carrier config 444 CarrierConfigManager configManager = 445 getActivity().getSystemService(CarrierConfigManager.class); 446 if (configManager == null) return null; 447 448 PersistableBundle bundle = configManager.getConfigForSubId(mSubId); 449 if (bundle == null) return null; 450 451 String carrierApp = bundle.getString( 452 CarrierConfigManager.KEY_WFC_EMERGENCY_ADDRESS_CARRIER_APP_STRING); 453 if (TextUtils.isEmpty(carrierApp)) return null; 454 455 ComponentName componentName = ComponentName.unflattenFromString(carrierApp); 456 if (componentName == null) return null; 457 458 // Build and return intent 459 Intent intent = new Intent(); 460 intent.setComponent(componentName); 461 intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, mSubId); 462 return intent; 463 } 464 465 /* 466 * Turn on/off WFC mode with ImsManager and update UI accordingly 467 */ updateWfcMode(boolean wfcEnabled)468 private void updateWfcMode(boolean wfcEnabled) { 469 Log.i(TAG, "updateWfcMode(" + wfcEnabled + ")"); 470 mImsManager.setWfcSetting(wfcEnabled); 471 472 int wfcMode = mImsManager.getWfcMode(false); 473 int wfcRoamingMode = mImsManager.getWfcMode(true); 474 updateButtonWfcMode(wfcEnabled, wfcMode, wfcRoamingMode); 475 if (wfcEnabled) { 476 mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), wfcMode); 477 } else { 478 mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), -1); 479 } 480 } 481 482 @Override onActivityResult(int requestCode, int resultCode, Intent data)483 public void onActivityResult(int requestCode, int resultCode, Intent data) { 484 super.onActivityResult(requestCode, resultCode, data); 485 486 final Context context = getActivity(); 487 488 Log.d(TAG, "WFC activity request = " + requestCode + " result = " + resultCode); 489 490 switch (requestCode) { 491 case REQUEST_CHECK_WFC_EMERGENCY_ADDRESS: 492 if (resultCode == Activity.RESULT_OK) { 493 updateWfcMode(true); 494 } 495 break; 496 case REQUEST_CHECK_WFC_DISCLAIMER: 497 if (resultCode == Activity.RESULT_OK) { 498 // Call address management activity before turning on WFC 499 Intent carrierAppIntent = getCarrierActivityIntent(); 500 if (carrierAppIntent != null) { 501 carrierAppIntent.putExtra(EXTRA_LAUNCH_CARRIER_APP, LAUCH_APP_ACTIVATE); 502 startActivityForResult(carrierAppIntent, 503 REQUEST_CHECK_WFC_EMERGENCY_ADDRESS); 504 } else { 505 updateWfcMode(true); 506 } 507 } 508 break; 509 default: 510 Log.e(TAG, "Unexpected request: " + requestCode); 511 break; 512 } 513 } 514 updateButtonWfcMode(boolean wfcEnabled, int wfcMode, int wfcRoamingMode)515 private void updateButtonWfcMode(boolean wfcEnabled, 516 int wfcMode, int wfcRoamingMode) { 517 mButtonWfcMode.setSummary(getWfcModeSummary(wfcMode)); 518 mButtonWfcMode.setEnabled(wfcEnabled && mEditableWfcMode); 519 // mButtonWfcRoamingMode.setSummary is not needed; summary is just selected value. 520 mButtonWfcRoamingMode.setEnabled(wfcEnabled && mEditableWfcRoamingMode); 521 522 final PreferenceScreen preferenceScreen = getPreferenceScreen(); 523 boolean updateAddressEnabled = (getCarrierActivityIntent() != null); 524 if (wfcEnabled) { 525 if (mEditableWfcMode) { 526 preferenceScreen.addPreference(mButtonWfcMode); 527 } else { 528 // Don't show WFC (home) preference if it's not editable. 529 preferenceScreen.removePreference(mButtonWfcMode); 530 } 531 if (mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming) { 532 preferenceScreen.addPreference(mButtonWfcRoamingMode); 533 } else { 534 // Don't show WFC roaming preference if it's not editable. 535 preferenceScreen.removePreference(mButtonWfcRoamingMode); 536 } 537 if (updateAddressEnabled) { 538 preferenceScreen.addPreference(mUpdateAddress); 539 } else { 540 preferenceScreen.removePreference(mUpdateAddress); 541 } 542 } else { 543 preferenceScreen.removePreference(mButtonWfcMode); 544 preferenceScreen.removePreference(mButtonWfcRoamingMode); 545 preferenceScreen.removePreference(mUpdateAddress); 546 } 547 } 548 549 @Override onPreferenceChange(Preference preference, Object newValue)550 public boolean onPreferenceChange(Preference preference, Object newValue) { 551 if (preference == mButtonWfcMode) { 552 Log.d(TAG, "onPreferenceChange mButtonWfcMode " + newValue); 553 mButtonWfcMode.setValue((String) newValue); 554 int buttonMode = Integer.valueOf((String) newValue); 555 int currentWfcMode = mImsManager.getWfcMode(false); 556 if (buttonMode != currentWfcMode) { 557 mImsManager.setWfcMode(buttonMode, false); 558 mButtonWfcMode.setSummary(getWfcModeSummary(buttonMode)); 559 mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), buttonMode); 560 561 if (mUseWfcHomeModeForRoaming) { 562 mImsManager.setWfcMode(buttonMode, true); 563 // mButtonWfcRoamingMode.setSummary is not needed; summary is selected value 564 } 565 } 566 } else if (preference == mButtonWfcRoamingMode) { 567 mButtonWfcRoamingMode.setValue((String) newValue); 568 int buttonMode = Integer.valueOf((String) newValue); 569 int currentMode = mImsManager.getWfcMode(true); 570 if (buttonMode != currentMode) { 571 mImsManager.setWfcMode(buttonMode, true); 572 // mButtonWfcRoamingMode.setSummary is not needed; summary is just selected value. 573 mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), buttonMode); 574 } 575 } 576 return true; 577 } 578 getWfcModeSummary(int wfcMode)579 private int getWfcModeSummary(int wfcMode) { 580 int resId = com.android.internal.R.string.wifi_calling_off_summary; 581 if (mImsManager.isWfcEnabledByUser()) { 582 switch (wfcMode) { 583 case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY: 584 resId = com.android.internal.R.string.wfc_mode_wifi_only_summary; 585 break; 586 case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED: 587 resId = com.android.internal.R.string.wfc_mode_cellular_preferred_summary; 588 break; 589 case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED: 590 resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary; 591 break; 592 default: 593 Log.e(TAG, "Unexpected WFC mode value: " + wfcMode); 594 } 595 } 596 return resId; 597 } 598 599 @VisibleForTesting getResourcesForSubId()600 Resources getResourcesForSubId() { 601 return SubscriptionManager.getResourcesForSubId(getContext(), mSubId, false); 602 } 603 } 604