Allow view/update EAB Provisioning status
Bug: 37433707
Test: make
Change-Id: I8cafe72015a9d80c3711b7cf472ae8fadcfd8170
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index a0ecf49..e7d08cc 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -206,6 +206,14 @@
android:layout_height="wrap_content"
android:text="@string/wfc_provisioned_switch_string"/>
+ <!-- EAB/Presence provisioned -->
+ <Switch android:id="@+id/eab_provisioned_switch"
+ android:textSize="14sp"
+ android:layout_marginTop="8dip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/eab_provisioned_switch_string"/>
+
<!-- SMSC -->
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1500fe4..e9a8a23 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -71,6 +71,9 @@
<!-- Wifi Calling provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="wfc_provisioned_switch_string">Wifi Calling Provisioned</string>
+ <!-- EAB provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
+ <string name="eab_provisioned_switch_string">EAB/Presence Provisioned</string>
+
<!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="radio_info_radio_power">Mobile Radio Power</string>
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index dde3461..880f3fe 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -21,6 +21,7 @@
import android.app.Dialog;
import android.app.QueuedWork;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -32,6 +33,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.telephony.CarrierConfigManager;
import android.telephony.CellInfo;
import android.telephony.CellInfoCdma;
import android.telephony.CellInfoGsm;
@@ -130,6 +132,9 @@
private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
+ private static final int EAB_PROVISIONED_CONFIG_ID =
+ ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
+
//Values in must match mCellInfoRefreshRates
private static final String[] mCellInfoRefreshRateLabels = {
"Disabled",
@@ -201,6 +206,7 @@
private Switch imsVolteProvisionedSwitch;
private Switch imsVtProvisionedSwitch;
private Switch imsWfcProvisionedSwitch;
+ private Switch eabProvisionedSwitch;
private Spinner preferredNetworkType;
private Spinner cellInfoRefreshRateSpinner;
@@ -406,6 +412,7 @@
imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
+ eabProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
@@ -478,6 +485,7 @@
imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
+ eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_CALL_STATE
@@ -1170,6 +1178,11 @@
setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
}
+ void setEabProvisionedState(boolean state) {
+ Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
+ setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
+ }
+
void setImsConfigProvisionedState(int configItem, boolean state) {
if (phone != null && mImsManager != null) {
QueuedWork.queue(new Runnable() {
@@ -1239,6 +1252,48 @@
}
};
+ private boolean isEabProvisioned() {
+ return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
+ }
+
+ OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ setEabProvisionedState(isChecked);
+ }
+ };
+
+ private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
+ boolean provisioned = defaultValue;
+ if (mImsManager != null) {
+ try {
+ ImsConfig imsConfig = mImsManager.getConfigInterface();
+ if (imsConfig != null) {
+ provisioned =
+ (imsConfig.getProvisionedValue(featureId)
+ == ImsConfig.FeatureValueConstants.ON);
+ }
+ } catch (ImsException ex) {
+ Log.e(TAG, "isFeatureProvisioned() exception:", ex);
+ }
+ }
+
+ log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
+ return provisioned;
+ }
+
+ private static boolean isEabEnabledByPlatform(Context context) {
+ if (context != null) {
+ CarrierConfigManager configManager = (CarrierConfigManager)
+ context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ if (configManager != null && configManager.getConfig().getBoolean(
+ CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void updateImsProvisionedState() {
log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
//delightful hack to prevent on-checked-changed calls from
@@ -1260,6 +1315,11 @@
imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
imsWfcProvisionedSwitch.setEnabled(
mImsManager.isWfcEnabledByPlatform(phone.getContext()));
+
+ eabProvisionedSwitch.setOnCheckedChangeListener(null);
+ eabProvisionedSwitch.setChecked(isEabProvisioned());
+ eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
+ eabProvisionedSwitch.setEnabled(isEabEnabledByPlatform(phone.getContext()));
}
OnClickListener mDnsCheckButtonHandler = new OnClickListener() {