Commit a00c9196 authored by Etan Cohen's avatar Etan Cohen
Browse files

WFC configuration: add API to get and set user settings.

Change-Id: Ia6ab8e5941b707d77321059450e6235f27ecbf38
parent c479f66e
......@@ -216,9 +216,20 @@ public class ImsConfig {
* Value is in Integer format.
*/
public static final int EAB_SETTING_ENABLED = 24;
/**
* Wi-Fi calling roaming status.
* Value is in Integer format. ON (1), OFF(0).
*/
public static final int VOICE_OVER_WIFI_ROAMING = 25;
/**
* Wi-Fi calling modem - WfcModeFeatureValueConstants.
* Value is in Integer format.
*/
public static final int VOICE_OVER_WIFI_MODE = 26;
// Expand the operator config items as needed here, need to change
// PROVISIONED_CONFIG_END after that.
public static final int PROVISIONED_CONFIG_END = EAB_SETTING_ENABLED;
public static final int PROVISIONED_CONFIG_END = VOICE_OVER_WIFI_MODE;
// Expand the operator config items as needed here.
}
......@@ -243,6 +254,15 @@ public class ImsConfig {
public static final int ON = 1;
}
/**
* Defines IMS feature value.
*/
public static class WfcModeFeatureValueConstants {
public static final int WIFI_ONLY = 0;
public static final int CELLULAR_PREFERRED = 1;
public static final int WIFI_PREFERRED = 2;
}
public ImsConfig(IImsConfig iconfig, Context context) {
if (DBG) Rlog.d(TAG, "ImsConfig creates");
miConfig = iconfig;
......
......@@ -17,6 +17,7 @@
package com.android.ims;
import android.app.PendingIntent;
import android.app.QueuedWork;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
......@@ -58,6 +59,8 @@ public class ImsManager {
public static final int PROPERTY_DBG_VOLTE_AVAIL_OVERRIDE_DEFAULT = 0;
public static final String PROPERTY_DBG_VT_AVAIL_OVERRIDE = "persist.dbg.vt_avail_ovr";
public static final int PROPERTY_DBG_VT_AVAIL_OVERRIDE_DEFAULT = 0;
public static final String PROPERTY_DBG_WFC_AVAIL_OVERRIDE = "persist.dbg.wfc_avail_ovr";
public static final int PROPERTY_DBG_WFC_AVAIL_OVERRIDE_DEFAULT = 0;
/**
* For accessing the IMS related service.
......@@ -171,7 +174,7 @@ public class ImsManager {
int enabled = android.provider.Settings.Global.getInt(
context.getContentResolver(),
android.provider.Settings.Global.ENHANCED_4G_MODE_ENABLED, ImsConfig.FeatureValueConstants.ON);
return (enabled == 1)? true:false;
return (enabled == 1) ? true : false;
}
/**
......@@ -274,6 +277,133 @@ public class ImsManager {
com.android.internal.R.bool.config_carrier_vt_available);
}
/**
* Returns the user configuration of WFC setting
*/
public static boolean isWfcEnabledByUser(Context context) {
int enabled = android.provider.Settings.Global.getInt(context.getContentResolver(),
android.provider.Settings.Global.WFC_IMS_ENABLED,
ImsConfig.FeatureValueConstants.ON);
return (enabled == 1) ? true : false;
}
/**
* Change persistent WFC enabled setting
*/
public static void setWfcSetting(Context context, boolean enabled) {
int value = enabled ? 1 : 0;
android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.WFC_IMS_ENABLED, value);
ImsManager imsManager = ImsManager.getInstance(context,
SubscriptionManager.getDefaultVoicePhoneId());
if (imsManager != null) {
try {
ImsConfig config = imsManager.getConfigInterface();
// FIXME: replace NETWORK_TYPE_LTE with NETWORK_TYPE_IWLAN
// when available
config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI,
TelephonyManager.NETWORK_TYPE_LTE,
enabled ? ImsConfig.FeatureValueConstants.ON
: ImsConfig.FeatureValueConstants.OFF, null);
} catch (ImsException e) {
// do nothing
}
}
}
/**
* Returns the user configuration of WFC modem setting
*/
public static int getWfcMode(Context context) {
int setting = android.provider.Settings.Global.getInt(context.getContentResolver(),
android.provider.Settings.Global.WFC_IMS_MODE,
ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
if (DBG) log("getWfcMode - setting=" + setting);
return setting;
}
/**
* Returns the user configuration of WFC modem setting
*/
public static void setWfcMode(Context context, int wfcMode) {
if (DBG) log("setWfcMode - setting=" + wfcMode);
android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.WFC_IMS_MODE, wfcMode);
final ImsManager imsManager = ImsManager.getInstance(context,
SubscriptionManager.getDefaultVoicePhoneId());
if (imsManager != null) {
final int value = wfcMode;
QueuedWork.singleThreadExecutor().submit(new Runnable() {
public void run() {
try {
imsManager.getConfigInterface().setProvisionedValue(
ImsConfig.ConfigConstants.VOICE_OVER_WIFI_MODE,
value);
} catch (ImsException e) {
// do nothing
}
}
});
}
}
/**
* Returns the user configuration of WFC roaming setting
*/
public static boolean isWfcRoamingEnabledByUser(Context context) {
int enabled = android.provider.Settings.Global.getInt(context.getContentResolver(),
android.provider.Settings.Global.WFC_IMS_ROAMING_ENABLED,
ImsConfig.FeatureValueConstants.ON);
return (enabled == 1) ? true : false;
}
/**
* Change persistent WFC roaming enabled setting
*/
public static void setWfcRoamingSetting(Context context, boolean enabled) {
final int value = enabled
? ImsConfig.FeatureValueConstants.ON
: ImsConfig.FeatureValueConstants.OFF;
android.provider.Settings.Global.putInt(context.getContentResolver(),
android.provider.Settings.Global.WFC_IMS_ROAMING_ENABLED, value);
final ImsManager imsManager = ImsManager.getInstance(context,
SubscriptionManager.getDefaultVoicePhoneId());
if (imsManager != null) {
QueuedWork.singleThreadExecutor().submit(new Runnable() {
public void run() {
try {
imsManager.getConfigInterface().setProvisionedValue(
ImsConfig.ConfigConstants.VOICE_OVER_WIFI_ROAMING,
value);
} catch (ImsException e) {
// do nothing
}
}
});
}
}
/**
* Returns a platform configuration for WFC which may override the user
* setting. Note: WFC presumes that VoLTE is enabled (these are
* configuration settings which must be done correctly).
*/
public static boolean isWfcEnabledByPlatform(Context context) {
if (SystemProperties.getInt(PROPERTY_DBG_WFC_AVAIL_OVERRIDE,
PROPERTY_DBG_WFC_AVAIL_OVERRIDE_DEFAULT) == 1) {
return true;
}
return
context.getResources().getBoolean(
com.android.internal.R.bool.config_device_wfc_ims_available) &&
context.getResources().getBoolean(
com.android.internal.R.bool.config_carrier_wfc_ims_available);
}
private ImsManager(Context context, int phoneId) {
mContext = context;
mPhoneId = phoneId;
......@@ -699,15 +829,15 @@ public class ImsManager {
return proxy;
}
private void log(String s) {
private static void log(String s) {
Rlog.d(TAG, s);
}
private void loge(String s) {
private static void loge(String s) {
Rlog.e(TAG, s);
}
private void loge(String s, Throwable t) {
private static void loge(String s, Throwable t) {
Rlog.e(TAG, s, t);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment