Support promotion of WFC.
Use new carrier config option to determine if the carrier wishes to promote
the user of Wifi Calling on call fail.'
If the user is on a WIFI network, and WFC is not enabled, and the carrier
wishes to promote the use of WIFI calling, display an alternate message
when calls fail, encouraging the user to enable wifi calling.
Bug: 27970317
Change-Id: Iecdda2dda13585307280c0e366fa6d84dba233c5
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;
+ }
}