Add error handling for outgoing WFC calls.
+ If POWER_OFF or OUT_OF_SERVICE is returned, show more specific
error messages based on WFC config and current wifi connectivity.
Assumes that IN_SERVICE will return if a call can be made,
regardless of the transport technology being used.
Assumes that OUT_OF_SERVICE will be returned if a call can not
be made and the radio is powered on.
Assumes that POWER_OFF will be returned if a call can not be
made and the radio is powered off.
Bug: 19167571
Change-Id: I32790bd05bb33e4890ee797f9f7a5297f6f0228c
diff --git a/src/com/android/phone/ImsUtil.java b/src/com/android/phone/ImsUtil.java
index c3d780b..868a0f1 100644
--- a/src/com/android/phone/ImsUtil.java
+++ b/src/com/android/phone/ImsUtil.java
@@ -16,9 +16,16 @@
package com.android.phone;
+import android.content.Context;
+import android.util.Log;
+
+import com.android.ims.ImsConfig;
+import com.android.ims.ImsManager;
import com.android.phone.PhoneGlobals;
public class ImsUtil {
+ private static final String LOG_TAG = ImsUtil.class.getSimpleName();
+ private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
private static boolean sImsPhoneSupported = false;
@@ -31,10 +38,32 @@
}
/**
- * @return true if this device supports voice calls using the built-in SIP stack.
+ * @return {@code true} if this device supports voice calls using the built-in SIP stack.
*/
static boolean isImsPhoneSupported() {
return sImsPhoneSupported;
}
+
+ /**
+ * @return {@code true} if WFC is supported by the platform and has been enabled by the user.
+ */
+ public static boolean isWfcEnabled(Context context) {
+ boolean isEnabledByPlatform = ImsManager.isWfcEnabledByPlatform(context);
+ boolean isEnabledByUser = ImsManager.isWfcEnabledByUser(context);
+ if (DBG) Log.d(LOG_TAG, "isWfcEnabled :: isEnabledByPlatform=" + isEnabledByPlatform);
+ if (DBG) Log.d(LOG_TAG, "isWfcEnabled :: isEnabledByUser=" + isEnabledByUser);
+ return isEnabledByPlatform && isEnabledByUser;
+ }
+
+ /**
+ * @return {@code true} if the device is configured to use "Wi-Fi only" mode. If WFC is not
+ * enabled, this will return {@code false}.
+ */
+ public static boolean isWfcModeWifiOnly(Context context) {
+ boolean isWifiOnlyMode =
+ ImsManager.getWfcMode(context) == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY;
+ if (DBG) Log.d(LOG_TAG, "isWfcModeWifiOnly :: isWifiOnlyMode" + isWifiOnlyMode);
+ return isWfcEnabled(context) && isWifiOnlyMode;
+ }
}