Merge "Support promotion of WFC." into nyc-mr1-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0fbd08d..a18ee87 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1011,6 +1011,8 @@
<string name="incall_error_supp_service_hold">Can\'t hold calls.</string>
<!-- In-call screen: call failure message displayed in an error dialog when WFC is enabled, is wifi-only, and not connected to a wireless network. [CHAR_LIMIT=NONE] -->
<string name="incall_error_wfc_only_no_wireless_network">Connect to a wireless network to make a call.</string>
+ <!-- In-call screen: call failure message displayed in an error dialog when the user is connected to a wireless network, but wifi calling is turned off. [CHAR_LIMIT=NONE] -->
+ <string name="incall_error_promote_wfc">Enable Wi-Fi calling to make a call.</string>
<!-- Dialog title for the "radio enable" UI for emergency calls -->
<string name="emergency_enable_radio_dialog_title">Emergency call</string>
diff --git a/src/com/android/phone/ImsUtil.java b/src/com/android/phone/ImsUtil.java
index 868a0f1..4c9089f 100644
--- a/src/com/android/phone/ImsUtil.java
+++ b/src/com/android/phone/ImsUtil.java
@@ -17,6 +17,9 @@
package com.android.phone;
import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.telephony.CarrierConfigManager;
import android.util.Log;
import com.android.ims.ImsConfig;
@@ -66,4 +69,31 @@
if (DBG) Log.d(LOG_TAG, "isWfcModeWifiOnly :: isWifiOnlyMode" + isWifiOnlyMode);
return isWfcEnabled(context) && isWifiOnlyMode;
}
+
+ /**
+ * When a call cannot be placed, determines if the use of WFC should be promoted, per the
+ * carrier config. Use of WFC is promoted to the user if the device is connected to a WIFI
+ * network, WFC is disabled, and the carrier config indicates that the features should be
+ * promoted.
+ *
+ * @return {@code true} if use of WFC should be promoted, {@code false} otherwise.
+ */
+ public static boolean shouldPromoteWfc(Context context) {
+ CarrierConfigManager cfgManager = (CarrierConfigManager) context
+ .getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ if (cfgManager == null || !cfgManager.getConfig()
+ .getBoolean(CarrierConfigManager.KEY_CARRIER_PROMOTE_WFC_ON_CALL_FAIL_BOOL)) {
+ return false;
+ }
+
+ ConnectivityManager cm =
+ (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm != null) {
+ NetworkInfo ni = cm.getActiveNetworkInfo();
+ if (ni != null && ni.isConnected()) {
+ return ni.getType() == ConnectivityManager.TYPE_WIFI && !isWfcEnabled(context);
+ }
+ }
+ return false;
+ }
}
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index 049eaf6..07ea113 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -290,7 +290,9 @@
// TODO: Offer the option to turn the radio on, and automatically retry the call
// once network registration is complete.
- if (ImsUtil.isWfcModeWifiOnly(context)) {
+ if (ImsUtil.shouldPromoteWfc(context)) {
+ resourceId = R.string.incall_error_promote_wfc;
+ } else if (ImsUtil.isWfcModeWifiOnly(context)) {
resourceId = R.string.incall_error_wfc_only_no_wireless_network;
} else if (ImsUtil.isWfcEnabled(context)) {
resourceId = R.string.incall_error_power_off_wfc;
@@ -312,7 +314,9 @@
case android.telephony.DisconnectCause.OUT_OF_SERVICE:
// No network connection.
- if (ImsUtil.isWfcModeWifiOnly(context)) {
+ if (ImsUtil.shouldPromoteWfc(context)) {
+ resourceId = R.string.incall_error_promote_wfc;
+ } else if (ImsUtil.isWfcModeWifiOnly(context)) {
resourceId = R.string.incall_error_wfc_only_no_wireless_network;
} else if (ImsUtil.isWfcEnabled(context)) {
resourceId = R.string.incall_error_out_of_service_wfc;