Updates menus after provisioning changes
Starts to listen for provisioning changes in mobile network menu and
Call Settings menu. The UI is then updated if provisioning status
changes for Wi-Fi Calling, Enhanced 4G LTE mode or video calling.
This ensures that the Wi-Fi Calling, Enhanced 4G LTE mode and video
calling items in these menus is added/removed correctly immediately
after provisioning changes.
Bug: 119389855
Test: atest TeleServiceTests
Merged-In: Ic4c4d07a2935fcd8d983481722ce1a9437fda7c4
Change-Id: Ic4c4d07a2935fcd8d983481722ce1a9437fda7c4
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 92af129..6c69a33 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -38,6 +38,7 @@
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.feature.ImsFeature;
import android.util.Log;
import android.view.MenuItem;
@@ -214,10 +215,32 @@
}
};
+ private final ProvisioningManager.Callback mProvisioningCallback =
+ new ProvisioningManager.Callback() {
+ @Override
+ public void onProvisioningIntChanged(int item, int value) {
+ if (item == ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED
+ || item == ImsConfig.ConfigConstants.VLT_SETTING_ENABLED
+ || item == ImsConfig.ConfigConstants.LVC_SETTING_ENABLED) {
+ updateVtWfc();
+ }
+ }
+ };
+
@Override
protected void onPause() {
super.onPause();
listenPhoneState(false);
+
+ // Remove callback for provisioning changes.
+ try {
+ if (mImsMgr != null) {
+ mImsMgr.getConfigInterface().removeConfigCallback(
+ mProvisioningCallback.getBinder());
+ }
+ } catch (ImsException e) {
+ Log.w(LOG_TAG, "onPause: Unable to remove callback for provisioning changes");
+ }
}
@Override
@@ -310,7 +333,24 @@
}
}
}
+ updateVtWfc();
+ // Register callback for provisioning changes.
+ try {
+ if (mImsMgr != null) {
+ mImsMgr.getConfigInterface().addConfigCallback(mProvisioningCallback);
+ }
+ } catch (ImsException e) {
+ Log.w(LOG_TAG, "onResume: Unable to register callback for provisioning changes.");
+ }
+ }
+
+ private void updateVtWfc() {
+ PreferenceScreen prefSet = getPreferenceScreen();
+ TelephonyManager telephonyManager = getSystemService(TelephonyManager.class)
+ .createForSubscriptionId(mPhone.getSubId());
+ PersistableBundle carrierConfig =
+ PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
if (mImsMgr.isVtEnabledByPlatform() && mImsMgr.isVtProvisionedOnDevice()
&& (carrierConfig.getBoolean(
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
@@ -320,6 +360,7 @@
? mImsMgr.isVtEnabledByUser() : false;
mEnableVideoCalling.setChecked(currentValue);
mEnableVideoCalling.setOnPreferenceChangeListener(this);
+ prefSet.addPreference(mEnableVideoCalling);
} else {
prefSet.removePreference(mEnableVideoCalling);
}
@@ -335,6 +376,7 @@
mButtonWifiCalling.setTitle(resolutions.get(0).loadLabel(pm));
mButtonWifiCalling.setSummary(null);
mButtonWifiCalling.setIntent(intent);
+ prefSet.addPreference(mButtonWifiCalling);
} else {
prefSet.removePreference(mButtonWifiCalling);
}
@@ -363,6 +405,7 @@
}
}
mButtonWifiCalling.setSummary(resId);
+ prefSet.addPreference(mButtonWifiCalling);
}
try {
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 86babd5..0f856d2 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -57,6 +57,7 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccManager;
+import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.feature.ImsFeature;
import android.text.TextUtils;
import android.util.Log;
@@ -884,6 +885,18 @@
}
}
+ private final ProvisioningManager.Callback mProvisioningCallback =
+ new ProvisioningManager.Callback() {
+ @Override
+ public void onProvisioningIntChanged(int item, int value) {
+ if (item == ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED
+ || item == ImsConfig.ConfigConstants.VLT_SETTING_ENABLED
+ || item == ImsConfig.ConfigConstants.LVC_SETTING_ENABLED) {
+ updateBody();
+ }
+ }
+ };
+
@Override
public void onDestroy() {
super.onDestroy();
@@ -933,6 +946,15 @@
context.getContentResolver().registerContentObserver(ENFORCE_MANAGED_URI, false,
mDpcEnforcedContentObserver);
+ // Register callback for provisioning changes.
+ try {
+ if (mImsMgr != null) {
+ mImsMgr.getConfigInterface().addConfigCallback(mProvisioningCallback);
+ }
+ } catch (ImsException e) {
+ Log.w(LOG_TAG, "onResume: Unable to register callback for provisioning changes.");
+ }
+
Log.i(LOG_TAG, "onResume:-");
}
@@ -1325,6 +1347,17 @@
final Context context = getActivity();
context.unregisterReceiver(mPhoneChangeReceiver);
context.getContentResolver().unregisterContentObserver(mDpcEnforcedContentObserver);
+
+ // Remove callback for provisioning changes.
+ try {
+ if (mImsMgr != null) {
+ mImsMgr.getConfigInterface().removeConfigCallback(
+ mProvisioningCallback.getBinder());
+ }
+ } catch (ImsException e) {
+ Log.w(LOG_TAG, "onPause: Unable to remove callback for provisioning changes");
+ }
+
if (DBG) log("onPause:-");
}