Merge "Fix crash in telephony tests"
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 6a7737a..f18535c 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -81,6 +81,7 @@
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -888,8 +889,10 @@
boolean dataAllowed;
boolean notAllowedDueToRoamingOff;
- List<DataDisallowedReason> reasons = phone.getDataNetworkController()
- .getInternetDataDisallowedReasons();
+ List<DataDisallowedReason> reasons = new ArrayList<>();
+ if (phone.getDataNetworkController() != null) {
+ reasons = phone.getDataNetworkController().getInternetDataDisallowedReasons();
+ }
dataAllowed = reasons.isEmpty();
notAllowedDueToRoamingOff = (reasons.size() == 1
&& reasons.contains(DataDisallowedReason.ROAMING_DISABLED));
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 88b4443..3f05f0a 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -6805,7 +6805,11 @@
Phone phone = PhoneFactory.getPhone(phoneId);
if (phone != null) {
boolean retVal;
- retVal = phone.getDataSettingsManager().isDataEnabled();
+ if (phone.getDataSettingsManager() == null) {
+ retVal = false;
+ } else {
+ retVal = phone.getDataSettingsManager().isDataEnabled();
+ }
if (DBG) log("isDataEnabled: " + retVal + ", subId=" + subId);
return retVal;
} else {
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index 7c2c829..c6dbfc6 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -72,13 +72,6 @@
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.telephony.data.NetworkSlicingConfig;
-import android.telephony.ims.ImsException;
-import android.telephony.ims.ImsManager;
-import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ImsRcsManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
@@ -99,6 +92,9 @@
import androidx.appcompat.app.AlertDialog.Builder;
import androidx.appcompat.app.AppCompatActivity;
+import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
+import com.android.ims.ImsManager;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.euicc.EuiccConnector;
@@ -181,6 +177,18 @@
*/
private static final int ALWAYS_ON_DSDS_MODE = 1;
+ private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
+ ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
+
+ private static final int IMS_VT_PROVISIONED_CONFIG_ID =
+ ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
+
+ 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 CELL_INFO_REFRESH_RATES
private static final String[] CELL_INFO_REFRESH_RATE_LABELS = {
"Disabled",
@@ -285,7 +293,6 @@
private TelephonyManager mTelephonyManager;
private ImsManager mImsManager = null;
private Phone mPhone = null;
- private ProvisioningManager mProvisioningManager = null;
private String mPingHostnameResultV4;
private String mPingHostnameResultV6;
@@ -419,9 +426,8 @@
mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
// update the phoneId
+ mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex);
mPhone = PhoneFactory.getPhone(phoneIndex);
- mImsManager = new ImsManager(mPhone.getContext());
- mProvisioningManager = ProvisioningManager.createForSubscriptionId(mPhone.getSubId());
updateAllFields();
}
@@ -481,8 +487,7 @@
mTelephonyManager = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
.createForSubscriptionId(mPhone.getSubId());
- mImsManager = new ImsManager(mPhone.getContext());
- mProvisioningManager = ProvisioningManager.createForSubscriptionId(mPhone.getSubId());
+ mImsManager = ImsManager.getInstance(getApplicationContext(), mPhone.getPhoneId());
sPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager);
@@ -550,7 +555,7 @@
mImsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
mEabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
- if (!isImsSupportedOnDevice(mPhone.getContext())) {
+ if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
mImsVolteProvisionedSwitch.setVisibility(View.GONE);
mImsVtProvisionedSwitch.setVisibility(View.GONE);
mImsWfcProvisionedSwitch.setVisibility(View.GONE);
@@ -781,8 +786,7 @@
R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
menu.add(1, MENU_ITEM_VIEW_SDN, 0,
R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
-
- if (isImsSupportedOnDevice(mPhone.getContext())) {
+ if (ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
menu.add(1, MENU_ITEM_GET_IMS_STATUS,
0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
}
@@ -1510,38 +1514,34 @@
mRadioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
}
- private void setImsVolteProvisionedState(boolean state) {
+ void setImsVolteProvisionedState(boolean state) {
Log.d(TAG, "setImsVolteProvisioned state: " + ((state) ? "on" : "off"));
- setImsConfigProvisionedState(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE, state);
+ setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
}
- private void setImsVtProvisionedState(boolean state) {
+ void setImsVtProvisionedState(boolean state) {
Log.d(TAG, "setImsVtProvisioned() state: " + ((state) ? "on" : "off"));
- setImsConfigProvisionedState(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE, state);
+ setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
}
- private void setImsWfcProvisionedState(boolean state) {
+ void setImsWfcProvisionedState(boolean state) {
Log.d(TAG, "setImsWfcProvisioned() state: " + ((state) ? "on" : "off"));
- setImsConfigProvisionedState(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, state);
+ setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
}
- private void setEabProvisionedState(boolean state) {
+ void setEabProvisionedState(boolean state) {
Log.d(TAG, "setEabProvisioned() state: " + ((state) ? "on" : "off"));
- setRcsConfigProvisionedState(ImsRcsManager.CAPABILITY_TYPE_PRESENCE_UCE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE, state);
+ setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
}
- private void setImsConfigProvisionedState(int capability, int tech, boolean state) {
- if (mProvisioningManager != null) {
+ void setImsConfigProvisionedState(int configItem, boolean state) {
+ if (mPhone != null && mImsManager != null) {
mQueuedWork.execute(new Runnable() {
public void run() {
try {
- mProvisioningManager.setProvisioningStatusForCapability(
- capability, tech, state);
- } catch (RuntimeException e) {
+ mImsManager.getConfigInterface().setProvisionedValue(
+ configItem, state ? 1 : 0);
+ } catch (ImsException e) {
Log.e(TAG, "setImsConfigProvisioned() exception:", e);
}
}
@@ -1549,71 +1549,6 @@
}
}
- private void setRcsConfigProvisionedState(int capability, int tech, boolean state) {
- if (mProvisioningManager != null) {
- mQueuedWork.execute(new Runnable() {
- public void run() {
- try {
- mProvisioningManager.setRcsProvisioningStatusForCapability(
- capability, tech, state);
- } catch (RuntimeException e) {
- Log.e(TAG, "setRcsConfigProvisioned() exception:", e);
- }
- }
- });
- }
- }
-
- private boolean isImsVolteProvisioningRequired() {
- return isImsConfigProvisioningRequired(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
- private boolean isImsVtProvisioningRequired() {
- return isImsConfigProvisioningRequired(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
- private boolean isImsWfcProvisioningRequired() {
- return isImsConfigProvisioningRequired(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
- }
-
- private boolean isEabProvisioningRequired() {
- return isRcsConfigProvisioningRequired(
- ImsRcsManager.CAPABILITY_TYPE_PRESENCE_UCE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
- private boolean isImsConfigProvisioningRequired(int capability, int tech) {
- if (mProvisioningManager != null) {
- try {
- return mProvisioningManager.isProvisioningRequiredForCapability(
- capability, tech);
- } catch (RuntimeException e) {
- Log.e(TAG, "isImsConfigProvisioningRequired() exception:", e);
- }
- }
-
- return false;
- }
-
- private boolean isRcsConfigProvisioningRequired(int capability, int tech) {
- if (mProvisioningManager != null) {
- try {
- return mProvisioningManager.isRcsProvisioningRequiredForCapability(
- capability, tech);
- } catch (RuntimeException e) {
- Log.e(TAG, "isRcsConfigProvisioningRequired() exception:", e);
- }
- }
-
- return false;
- }
-
OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -1649,8 +1584,11 @@
};
private boolean isImsVolteProvisioned() {
- return getImsConfigProvisionedState(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
+ if (mImsManager != null) {
+ return mImsManager.isVolteEnabledByPlatform()
+ && mImsManager.isVolteProvisionedOnDevice();
+ }
+ return false;
}
OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
@@ -1661,8 +1599,11 @@
};
private boolean isImsVtProvisioned() {
- return getImsConfigProvisionedState(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
+ if (mImsManager != null) {
+ return mImsManager.isVtEnabledByPlatform()
+ && mImsManager.isVtProvisionedOnDevice();
+ }
+ return false;
}
OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
@@ -1673,8 +1614,11 @@
};
private boolean isImsWfcProvisioned() {
- return getImsConfigProvisionedState(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
+ if (mImsManager != null) {
+ return mImsManager.isWfcEnabledByPlatform()
+ && mImsManager.isWfcProvisionedOnDevice();
+ }
+ return false;
}
OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
@@ -1685,8 +1629,7 @@
};
private boolean isEabProvisioned() {
- return getRcsConfigProvisionedState(ImsRcsManager.CAPABILITY_TYPE_PRESENCE_UCE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
+ return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
}
OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
@@ -1696,30 +1639,23 @@
}
};
- private boolean getImsConfigProvisionedState(int capability, int tech) {
- if (mProvisioningManager != null) {
+ private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
+ boolean provisioned = defaultValue;
+ if (mImsManager != null) {
try {
- return mProvisioningManager.getProvisioningStatusForCapability(
- capability, tech);
- } catch (RuntimeException e) {
- Log.e(TAG, "getImsConfigProvisionedState() exception:", e);
+ ImsConfig imsConfig = mImsManager.getConfigInterface();
+ if (imsConfig != null) {
+ provisioned =
+ (imsConfig.getProvisionedValue(featureId)
+ == ImsConfig.FeatureValueConstants.ON);
+ }
+ } catch (ImsException ex) {
+ Log.e(TAG, "isFeatureProvisioned() exception:", ex);
}
}
- return false;
- }
-
- private boolean getRcsConfigProvisionedState(int capability, int tech) {
- if (mProvisioningManager != null) {
- try {
- return mProvisioningManager.getRcsProvisioningStatusForCapability(
- capability, tech);
- } catch (RuntimeException e) {
- Log.e(TAG, "getRcsConfigProvisionedState() exception:", e);
- }
- }
-
- return false;
+ log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
+ return provisioned;
}
private boolean isEabEnabledByPlatform() {
@@ -1738,56 +1674,35 @@
}
private void updateImsProvisionedState() {
- if (!isImsSupportedOnDevice(mPhone.getContext())) {
+ if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
return;
}
-
- updateServiceEnabledByPlatform();
-
- updateEabProvisionedSwitch(isEabEnabledByPlatform());
- }
-
- private void updateVolteProvisionedSwitch(boolean isEnabledByPlatform) {
- boolean isProvisioned = isEnabledByPlatform && isImsVolteProvisioned();
- log("updateImsProvisionedState isProvisioned" + isProvisioned);
-
+ log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
+ //delightful hack to prevent on-checked-changed calls from
+ //actually forcing the ims provisioning to its transient/current value.
mImsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
- mImsVolteProvisionedSwitch.setChecked(isProvisioned);
+ mImsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
mImsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
mImsVolteProvisionedSwitch.setEnabled(!IS_USER_BUILD
- && isEnabledByPlatform && isImsVolteProvisioningRequired());
- }
-
- private void updateVtProvisionedSwitch(boolean isEnabledByPlatform) {
- boolean isProvisioned = isEnabledByPlatform && isImsVtProvisioned();
- log("updateVtProvisionedSwitch isProvisioned" + isProvisioned);
+ && mImsManager.isVolteEnabledByPlatform());
mImsVtProvisionedSwitch.setOnCheckedChangeListener(null);
- mImsVtProvisionedSwitch.setChecked(isProvisioned);
+ mImsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
mImsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
mImsVtProvisionedSwitch.setEnabled(!IS_USER_BUILD
- && isEnabledByPlatform && isImsVtProvisioningRequired());
- }
-
- private void updateWfcProvisionedSwitch(boolean isEnabledByPlatform) {
- boolean isProvisioned = isEnabledByPlatform && isImsWfcProvisioned();
- log("updateWfcProvisionedSwitch isProvisioned" + isProvisioned);
+ && mImsManager.isVtEnabledByPlatform());
mImsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
- mImsWfcProvisionedSwitch.setChecked(isProvisioned);
+ mImsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
mImsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
mImsWfcProvisionedSwitch.setEnabled(!IS_USER_BUILD
- && isEnabledByPlatform && isImsWfcProvisioningRequired());
- }
-
- private void updateEabProvisionedSwitch(boolean isEnabledByPlatform) {
- log("updateEabProvisionedSwitch isEabWfcProvisioned()=" + isEabProvisioned());
+ && mImsManager.isWfcEnabledByPlatform());
mEabProvisionedSwitch.setOnCheckedChangeListener(null);
mEabProvisionedSwitch.setChecked(isEabProvisioned());
mEabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
mEabProvisionedSwitch.setEnabled(!IS_USER_BUILD
- && isEnabledByPlatform && isEabProvisioningRequired());
+ && isEabEnabledByPlatform());
}
OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
@@ -2026,28 +1941,4 @@
intent.putExtra("isDefault", isChecked);
sendBroadcast(intent);
}
-
- private boolean isImsSupportedOnDevice(Context context) {
- return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS);
- }
-
- private void updateServiceEnabledByPlatform() {
- ImsMmTelManager imsMmTelManager = mImsManager.getImsMmTelManager(mPhone.getSubId());
- try {
- imsMmTelManager.isSupported(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getMainExecutor(), (result) -> {
- updateVolteProvisionedSwitch(result);
- });
- imsMmTelManager.isSupported(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
- AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getMainExecutor(), (result) -> {
- updateVtProvisionedSwitch(result);
- });
- imsMmTelManager.isSupported(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- AccessNetworkConstants.TRANSPORT_TYPE_WLAN, getMainExecutor(), (result) -> {
- updateWfcProvisionedSwitch(result);
- });
- } catch (ImsException e) {
- e.printStackTrace();
- }
- }
}
diff --git a/tests/src/com/android/phone/PhoneInterfaceManagerTest.java b/tests/src/com/android/phone/PhoneInterfaceManagerTest.java
index ffc0177..08bdb9b 100644
--- a/tests/src/com/android/phone/PhoneInterfaceManagerTest.java
+++ b/tests/src/com/android/phone/PhoneInterfaceManagerTest.java
@@ -33,6 +33,7 @@
import com.android.internal.telephony.RILConstants;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -90,6 +91,7 @@
}
@Test
+ @Ignore("b/254731907")
public void matchLocaleFromSupportedLocaleList_inputLocaleChangeToSupportedLocale() {
// Input zh-TW, then look up the matched supported locale, zh-Hant-TW, instead.
String result1 = mPhoneInterfaceManager.matchLocaleFromSupportedLocaleList(