Merge "Make NGRAN have the lowest priority in NO SIM state" into 24D1-dev
diff --git a/res/values/config.xml b/res/values/config.xml
index f8aeb5e..2ad2af3 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -318,13 +318,6 @@
<string-array name="thermal_mitigation_allowlisted_packages" translatable="false">
</string-array>
- <!-- Array of carriers that don't care about NGRAN's preference in the preferred emergency
- network scan list after SIM is removed. -->
- <integer-array name="config_carriers_ignore_ngran_preference_when_sim_removed">
- <!-- 001-01 Test SIM -->
- <item>1911</item>
- </integer-array>
-
<!-- Array of countries that active SIM is needed for emergency calls. Values should be
ISO3166 country codes in lowercase. -->
<string-array name="config_countries_require_sim_for_emergency" translatable="false">
diff --git a/src/com/android/services/telephony/domainselection/CarrierConfigHelper.java b/src/com/android/services/telephony/domainselection/CarrierConfigHelper.java
deleted file mode 100644
index d39a6b7..0000000
--- a/src/com/android/services/telephony/domainselection/CarrierConfigHelper.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telephony.domainselection;
-
-import static android.telephony.AccessNetworkConstants.AccessNetworkType.NGRAN;
-import static android.telephony.CarrierConfigManager.ImsEmergency.KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.os.PersistableBundle;
-import android.os.SystemProperties;
-import android.preference.PreferenceManager;
-import android.telephony.CarrierConfigManager;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.util.ArrayMap;
-import android.util.Log;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.phone.R;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/** Helper class to cache carrier configurations. */
-public class CarrierConfigHelper extends Handler {
- private static final String TAG = "CarrierConfigHelper";
- private static final boolean DBG = (SystemProperties.getInt("ro.debuggable", 0) == 1);
-
- @VisibleForTesting
- public static final String KEY_VONR_EMERGENCY_SUPPORT = "vonr_emergency_support";
-
- private final Context mContext;
- private final CarrierConfigManager mConfigManager;
- private final TelephonyManager mTelephonyManager;
- private final ArrayMap<Integer, Boolean> mVoNrSupported = new ArrayMap<>();
-
- private final CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener =
- (slotIndex, subId, carrierId, specificCarrierId) -> onCarrierConfigurationChanged(
- slotIndex, subId, carrierId);
-
- // For test purpose only
- private final SharedPreferences mSharedPreferences;
-
- private List<Integer> mIgnoreNrWhenSimRemoved = null;
-
- /**
- * Creates an instance.
- *
- * @param context The Context this is associated with.
- * @param looper The Looper to run the CarrierConfigHelper.
- */
- public CarrierConfigHelper(@NonNull Context context, @NonNull Looper looper) {
- this(context, looper, null);
- }
-
- /**
- * Creates an instance.
- *
- * @param context The Context this is associated with.
- * @param looper The Looper to run the CarrierConfigHelper.
- * @param sharedPreferences The SharedPreferences instance.
- */
- @VisibleForTesting
- public CarrierConfigHelper(@NonNull Context context, @NonNull Looper looper,
- @Nullable SharedPreferences sharedPreferences) {
- super(looper);
-
- mContext = context;
- mTelephonyManager = context.getSystemService(TelephonyManager.class);
- mConfigManager = context.getSystemService(CarrierConfigManager.class);
- mConfigManager.registerCarrierConfigChangeListener(this::post,
- mCarrierConfigChangeListener);
- mSharedPreferences = sharedPreferences;
-
- readFromSharedPreference();
- readResourceConfiguration();
- }
-
- /**
- * Returns whether VoNR emergency was supported with the last valid subscription.
- *
- * @param slotIndex The SIM slot index.
- * @return true if VoNR emergency was supported with the last valid subscription.
- * Otherwise, false.
- */
- public boolean isVoNrEmergencySupported(int slotIndex) {
- return mVoNrSupported.get(Integer.valueOf(slotIndex));
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch(msg.what) {
- default:
- super.handleMessage(msg);
- break;
- }
- }
-
- private void readFromSharedPreference() {
- mVoNrSupported.clear();
- int modemCount = mTelephonyManager.getActiveModemCount();
- SharedPreferences sp = (mSharedPreferences != null) ? mSharedPreferences
- : PreferenceManager.getDefaultSharedPreferences(mContext);
- for (int i = 0; i < modemCount; i++) {
- Boolean savedConfig = Boolean.valueOf(
- sp.getBoolean(KEY_VONR_EMERGENCY_SUPPORT + i, false));
- mVoNrSupported.put(Integer.valueOf(i), savedConfig);
- Log.i(TAG, "readFromSharedPreference slot=" + i + ", " + savedConfig);
- }
- }
-
- private void onCarrierConfigurationChanged(int slotIndex, int subId, int carrierId) {
- Log.i(TAG, "onCarrierConfigurationChanged slotIndex=" + slotIndex
- + ", subId=" + subId + ", carrierId=" + carrierId);
-
- if (slotIndex < 0
- || !SubscriptionManager.isValidSubscriptionId(subId)
- || mTelephonyManager.getSimState(slotIndex) != TelephonyManager.SIM_STATE_READY) {
- return;
- }
-
- PersistableBundle b = mConfigManager.getConfigForSubId(subId,
- KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY);
- if (b.isEmpty()) {
- Log.e(TAG, "onCarrierConfigurationChanged empty result");
- return;
- }
-
- if (!CarrierConfigManager.isConfigForIdentifiedCarrier(b)) {
- Log.i(TAG, "onCarrierConfigurationChanged not carrier specific configuration");
- return;
- }
-
- int[] imsRatsConfig = b.getIntArray(
- KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY);
- if (imsRatsConfig == null) imsRatsConfig = new int[0];
- boolean carrierConfig = false;
- for (int i = 0; i < imsRatsConfig.length; i++) {
- if (imsRatsConfig[i] == NGRAN) {
- carrierConfig = true;
- break;
- }
- }
- if (mIgnoreNrWhenSimRemoved.contains(carrierId)) carrierConfig = false;
-
- Boolean savedConfig = mVoNrSupported.get(Integer.valueOf(slotIndex));
- if (carrierConfig == savedConfig) {
- return;
- }
-
- mVoNrSupported.put(Integer.valueOf(slotIndex), Boolean.valueOf(carrierConfig));
-
- SharedPreferences sp = (mSharedPreferences != null) ? mSharedPreferences
- : PreferenceManager.getDefaultSharedPreferences(mContext);
- SharedPreferences.Editor editor = sp.edit();
- editor.putBoolean(KEY_VONR_EMERGENCY_SUPPORT + slotIndex, carrierConfig);
- editor.apply();
-
- Log.i(TAG, "onCarrierConfigurationChanged preference updated slotIndex=" + slotIndex
- + ", supported=" + carrierConfig);
- }
-
- private void readResourceConfiguration() {
- try {
- mIgnoreNrWhenSimRemoved = Arrays.stream(mContext.getResources().getIntArray(
- R.array.config_carriers_ignore_ngran_preference_when_sim_removed))
- .boxed().collect(Collectors.toList());
- } catch (Resources.NotFoundException nfe) {
- Log.e(TAG, "readResourceConfiguration exception=" + nfe);
- } catch (NullPointerException npe) {
- Log.e(TAG, "readResourceConfiguration exception=" + npe);
- }
- if (mIgnoreNrWhenSimRemoved == null) {
- mIgnoreNrWhenSimRemoved = new ArrayList<Integer>();
- }
- Log.i(TAG, "readResourceConfiguration ignoreNrWhenSimRemoved=" + mIgnoreNrWhenSimRemoved);
- }
-
- /** Destroys the instance. */
- public void destroy() {
- if (DBG) Log.d(TAG, "destroy");
- mConfigManager.unregisterCarrierConfigChangeListener(mCarrierConfigChangeListener);
- }
-}
diff --git a/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java b/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java
index 962cbf1..7d7744c 100644
--- a/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java
+++ b/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java
@@ -211,7 +211,6 @@
private final PowerManager.WakeLock mPartialWakeLock;
private final CrossSimRedialingController mCrossSimRedialingController;
- private final CarrierConfigHelper mCarrierConfigHelper;
private final EmergencyCallbackModeHelper mEcbmHelper;
/** Constructor. */
@@ -219,7 +218,6 @@
@NonNull Looper looper, @NonNull ImsStateTracker imsStateTracker,
@NonNull DestroyListener destroyListener,
@NonNull CrossSimRedialingController csrController,
- @NonNull CarrierConfigHelper carrierConfigHelper,
@NonNull EmergencyCallbackModeHelper ecbmHelper) {
super(context, slotId, subId, looper, imsStateTracker, destroyListener, TAG);
@@ -230,7 +228,6 @@
mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mCrossSimRedialingController = csrController;
- mCarrierConfigHelper = carrierConfigHelper;
mEcbmHelper = ecbmHelper;
acquireWakeLock();
}
@@ -532,7 +529,6 @@
b.getIntArray(KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY);
mImsRoamRatsConfig = b.getIntArray(
KEY_EMERGENCY_OVER_IMS_ROAMING_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY);
- maybeModifyImsRats();
mCsRatsConfig =
b.getIntArray(KEY_EMERGENCY_OVER_CS_SUPPORTED_ACCESS_NETWORK_TYPES_INT_ARRAY);
@@ -605,16 +601,6 @@
}
}
- /** Adds NGRAN if SIM is absent or locked and the last valid subscription supported NGRAN. */
- private void maybeModifyImsRats() {
- if (mCarrierConfigHelper.isVoNrEmergencySupported(getSlotId())
- && !isSimReady() && mImsRatsConfig.length < 2) {
- // Default configuration includes only EUTRAN.
- mImsRatsConfig = new int[] { EUTRAN, NGRAN };
- mImsRoamRatsConfig = new int[] { EUTRAN, NGRAN };
- }
- }
-
/**
* Caches the resource configuration.
*/
diff --git a/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionService.java b/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionService.java
index d79a260..8f1a319 100644
--- a/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionService.java
+++ b/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionService.java
@@ -73,7 +73,6 @@
@NonNull ImsStateTracker imsStateTracker,
@NonNull DomainSelectorBase.DestroyListener listener,
@NonNull CrossSimRedialingController crossSimRedialingController,
- @NonNull CarrierConfigHelper carrierConfigHelper,
@NonNull EmergencyCallbackModeHelper emergencyCallbackModeHelper);
}
@@ -84,7 +83,6 @@
@NonNull ImsStateTracker imsStateTracker,
@NonNull DomainSelectorBase.DestroyListener listener,
@NonNull CrossSimRedialingController crossSimRedialingController,
- @NonNull CarrierConfigHelper carrierConfigHelper,
@NonNull EmergencyCallbackModeHelper emergencyCallbackModeHelper) {
DomainSelectorBase selector = null;
@@ -97,7 +95,7 @@
if (isEmergency) {
selector = new EmergencyCallDomainSelector(context, slotId, subId, looper,
imsStateTracker, listener, crossSimRedialingController,
- carrierConfigHelper, emergencyCallbackModeHelper);
+ emergencyCallbackModeHelper);
} else {
selector = new NormalCallDomainSelector(context, slotId, subId, looper,
imsStateTracker, listener);
@@ -201,23 +199,20 @@
private final DomainSelectorFactory mDomainSelectorFactory;
private Handler mServiceHandler;
private CrossSimRedialingController mCrossSimRedialingController;
- private CarrierConfigHelper mCarrierConfigHelper;
private EmergencyCallbackModeHelper mEmergencyCallbackModeHelper;
/** Default constructor. */
public TelephonyDomainSelectionService() {
- this(ImsStateTracker::new, new DefaultDomainSelectorFactory(), null, null);
+ this(ImsStateTracker::new, new DefaultDomainSelectorFactory(), null);
}
@VisibleForTesting
protected TelephonyDomainSelectionService(
@NonNull ImsStateTrackerFactory imsStateTrackerFactory,
@NonNull DomainSelectorFactory domainSelectorFactory,
- @Nullable CarrierConfigHelper carrierConfigHelper,
@Nullable EmergencyCallbackModeHelper ecbmHelper) {
mImsStateTrackerFactory = imsStateTrackerFactory;
mDomainSelectorFactory = domainSelectorFactory;
- mCarrierConfigHelper = carrierConfigHelper;
}
@Override
@@ -242,9 +237,6 @@
}
mCrossSimRedialingController = new CrossSimRedialingController(mContext, getLooper());
- if (mCarrierConfigHelper == null) {
- mCarrierConfigHelper = new CarrierConfigHelper(mContext, getLooper());
- }
if (mEmergencyCallbackModeHelper == null) {
mEmergencyCallbackModeHelper = new EmergencyCallbackModeHelper(mContext, getLooper());
}
@@ -291,11 +283,6 @@
mCrossSimRedialingController = null;
}
- if (mCarrierConfigHelper != null) {
- mCarrierConfigHelper.destroy();
- mCarrierConfigHelper = null;
- }
-
if (mEmergencyCallbackModeHelper != null) {
mEmergencyCallbackModeHelper.destroy();
mEmergencyCallbackModeHelper = null;
@@ -323,7 +310,7 @@
ImsStateTracker ist = getImsStateTracker(slotId);
DomainSelectorBase selector = mDomainSelectorFactory.create(mContext, slotId, subId,
selectorType, isEmergency, getLooper(), ist, mDestroyListener,
- mCrossSimRedialingController, mCarrierConfigHelper, mEmergencyCallbackModeHelper);
+ mCrossSimRedialingController, mEmergencyCallbackModeHelper);
if (selector != null) {
// Ensures that ImsStateTracker is started before selecting the domain if not started
diff --git a/tests/src/com/android/services/telephony/domainselection/CarrierConfigHelperTest.java b/tests/src/com/android/services/telephony/domainselection/CarrierConfigHelperTest.java
deleted file mode 100644
index 8f51dab..0000000
--- a/tests/src/com/android/services/telephony/domainselection/CarrierConfigHelperTest.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telephony.domainselection;
-
-import static android.telephony.AccessNetworkConstants.AccessNetworkType.EUTRAN;
-import static android.telephony.AccessNetworkConstants.AccessNetworkType.NGRAN;
-import static android.telephony.CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL;
-import static android.telephony.CarrierConfigManager.ImsEmergency.KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY;
-
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.assertNotNull;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.PersistableBundle;
-import android.telephony.CarrierConfigManager;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.testing.TestableLooper;
-import android.util.Log;
-
-import com.android.TestContext;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import java.util.concurrent.Executor;
-
-/**
- * Unit tests for CarrierConfigHelper
- */
-public class CarrierConfigHelperTest {
- private static final String TAG = "CarrierConfigHelperTest";
-
- private static final int SLOT_0 = 0;
- private static final int SLOT_1 = 1;
- private static final int SUB_1 = 1;
- private static final int TEST_SIM_CARRIER_ID = 1911;
-
- @Mock private SharedPreferences mSharedPreferences;
- @Mock private SharedPreferences.Editor mEditor;
- @Mock private Resources mResources;
-
- private Context mContext;
- private HandlerThread mHandlerThread;
- private TestableLooper mLooper;
- private CarrierConfigHelper mCarrierConfigHelper;
- private CarrierConfigManager mCarrierConfigManager;
- private TelephonyManager mTelephonyManager;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- mContext = new TestContext() {
- @Override
- public String getSystemServiceName(Class<?> serviceClass) {
- if (serviceClass == TelephonyManager.class) {
- return Context.TELEPHONY_SERVICE;
- } else if (serviceClass == CarrierConfigManager.class) {
- return Context.CARRIER_CONFIG_SERVICE;
- }
- return super.getSystemServiceName(serviceClass);
- }
-
- @Override
- public String getOpPackageName() {
- return "";
- }
-
- @Override
- public Resources getResources() {
- return mResources;
- }
- };
-
- if (Looper.myLooper() == null) {
- Looper.prepare();
- }
-
- mHandlerThread = new HandlerThread("CarrierConfigHelperTest");
- mHandlerThread.start();
-
- try {
- mLooper = new TestableLooper(mHandlerThread.getLooper());
- } catch (Exception e) {
- logd("Unable to create looper from handler.");
- }
-
- doReturn(mEditor).when(mSharedPreferences).edit();
-
- mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
- mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
- doReturn(2).when(mTelephonyManager).getActiveModemCount();
- doReturn(TelephonyManager.SIM_STATE_READY)
- .when(mTelephonyManager).getSimState(anyInt());
-
- doReturn(new int[] { TEST_SIM_CARRIER_ID }).when(mResources).getIntArray(anyInt());
-
- mCarrierConfigHelper = new CarrierConfigHelper(mContext, mHandlerThread.getLooper(),
- mSharedPreferences);
- }
-
- @After
- public void tearDown() throws Exception {
- if (mCarrierConfigHelper != null) {
- mCarrierConfigHelper.destroy();
- mCarrierConfigHelper = null;
- }
-
- if (mLooper != null) {
- mLooper.destroy();
- mLooper = null;
- }
- }
-
- @Test
- public void testInit() throws Exception {
- ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> callbackCaptor =
- ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class);
- ArgumentCaptor<Executor> executorCaptor = ArgumentCaptor.forClass(Executor.class);
-
- verify(mCarrierConfigManager).registerCarrierConfigChangeListener(executorCaptor.capture(),
- callbackCaptor.capture());
- assertNotNull(executorCaptor.getValue());
- assertNotNull(callbackCaptor.getValue());
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
- }
-
- @Test
- public void testCarrierConfigNotApplied() throws Exception {
- ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> callbackCaptor =
- ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class);
-
- verify(mCarrierConfigManager).registerCarrierConfigChangeListener(any(),
- callbackCaptor.capture());
-
- CarrierConfigManager.CarrierConfigChangeListener callback = callbackCaptor.getValue();
-
- assertNotNull(callback);
-
- // NR is included but carrier config is not applied.
- PersistableBundle b = getPersistableBundle(new int[] { EUTRAN, NGRAN }, false);
- doReturn(b).when(mCarrierConfigManager).getConfigForSubId(anyInt(), anyString());
- callback.onCarrierConfigChanged(SLOT_0, SUB_1, 0, 0);
-
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
- }
-
- @Test
- public void testCarrierConfigApplied() throws Exception {
- ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> callbackCaptor =
- ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class);
-
- verify(mCarrierConfigManager).registerCarrierConfigChangeListener(any(),
- callbackCaptor.capture());
-
- CarrierConfigManager.CarrierConfigChangeListener callback = callbackCaptor.getValue();
-
- assertNotNull(callback);
-
- // NR is included and carrier config is applied.
- PersistableBundle b = getPersistableBundle(new int[] { EUTRAN, NGRAN }, true);
- doReturn(b).when(mCarrierConfigManager).getConfigForSubId(anyInt(), anyString());
- callback.onCarrierConfigChanged(SLOT_0, SUB_1, 0, 0);
-
- assertTrue(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_1));
-
- verify(mEditor).putBoolean(eq(CarrierConfigHelper.KEY_VONR_EMERGENCY_SUPPORT + SLOT_0),
- eq(true));
-
- // NR is not included and carrier config is applied.
- b = getPersistableBundle(new int[] { EUTRAN }, true);
- doReturn(b).when(mCarrierConfigManager).getConfigForSubId(anyInt(), anyString());
- callback.onCarrierConfigChanged(SLOT_0, SUB_1, 0, 0);
-
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
-
- verify(mEditor).putBoolean(eq(CarrierConfigHelper.KEY_VONR_EMERGENCY_SUPPORT + SLOT_0),
- eq(false));
- }
-
- @Test
- public void testCarrierConfigInvalidSubId() throws Exception {
- ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> callbackCaptor =
- ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class);
-
- verify(mCarrierConfigManager).registerCarrierConfigChangeListener(any(),
- callbackCaptor.capture());
-
- CarrierConfigManager.CarrierConfigChangeListener callback = callbackCaptor.getValue();
-
- assertNotNull(callback);
-
- // NR is included and carrier config is applied.
- PersistableBundle b = getPersistableBundle(new int[] { EUTRAN, NGRAN }, true);
- doReturn(b).when(mCarrierConfigManager).getConfigForSubId(anyInt(), anyString());
-
- // Invalid subscription
- callback.onCarrierConfigChanged(SLOT_0, SubscriptionManager.INVALID_SUBSCRIPTION_ID, 0, 0);
-
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
- }
-
- @Test
- public void testRestoreFromSharedPreferences() throws Exception {
- doReturn(true).when(mSharedPreferences).getBoolean(anyString(), anyBoolean());
- mCarrierConfigHelper = new CarrierConfigHelper(mContext, mHandlerThread.getLooper(),
- mSharedPreferences);
-
- assertTrue(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
- }
-
- @Test
- public void testCarrierIgnoreNrWhenSimRemoved() throws Exception {
- ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> callbackCaptor =
- ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class);
-
- verify(mCarrierConfigManager).registerCarrierConfigChangeListener(any(),
- callbackCaptor.capture());
-
- CarrierConfigManager.CarrierConfigChangeListener callback = callbackCaptor.getValue();
-
- assertNotNull(callback);
-
- // NR is included and carrier config for TEST SIM is applied.
- PersistableBundle b = getPersistableBundle(new int[] { EUTRAN, NGRAN }, true);
- doReturn(b).when(mCarrierConfigManager).getConfigForSubId(anyInt(), anyString());
- callback.onCarrierConfigChanged(SLOT_0, SUB_1, TEST_SIM_CARRIER_ID, 0);
-
- // NR is ignored.
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_0));
- assertFalse(mCarrierConfigHelper.isVoNrEmergencySupported(SLOT_1));
- }
-
- private static PersistableBundle getPersistableBundle(int[] imsRats, boolean applied) {
- PersistableBundle bundle = new PersistableBundle();
- bundle.putIntArray(KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY, imsRats);
- bundle.putBoolean(KEY_CARRIER_CONFIG_APPLIED_BOOL, applied);
- return bundle;
- }
-
- private static void logd(String str) {
- Log.d(TAG, str);
- }
-}
diff --git a/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java b/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java
index 0735c3f..c8546bf 100644
--- a/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java
+++ b/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java
@@ -155,7 +155,6 @@
@Mock private DomainSelectorBase.DestroyListener mDestroyListener;
@Mock private ProvisioningManager mProvisioningManager;
@Mock private CrossSimRedialingController mCsrdCtrl;
- @Mock private CarrierConfigHelper mCarrierConfigHelper;
@Mock private EmergencyCallbackModeHelper mEcbmHelper;
@Mock private Resources mResources;
@@ -2700,34 +2699,6 @@
}
@Test
- public void testSimLockScanPsPreferredWithNr() throws Exception {
- createSelector(SLOT_0_SUB_ID);
- unsolBarringInfoChanged(false);
-
- // The last valid subscription supported NR.
- doReturn(true).when(mCarrierConfigHelper).isVoNrEmergencySupported(eq(SLOT_0));
- when(mTelephonyManager.getSimState(anyInt())).thenReturn(
- TelephonyManager.SIM_STATE_PIN_REQUIRED);
-
- EmergencyRegistrationResult regResult = getEmergencyRegResult(
- UNKNOWN, REGISTRATION_STATE_UNKNOWN, 0, false, false, 0, 0, "", "");
- SelectionAttributes attr = getSelectionAttributes(SLOT_0, SLOT_0_SUB_ID, regResult);
- mDomainSelector.selectDomain(attr, mTransportSelectorCallback);
- processAllMessages();
-
- bindImsServiceUnregistered();
- processAllMessages();
-
- verify(mWwanSelectorCallback, times(1)).onRequestEmergencyNetworkScan(
- any(), anyInt(), anyBoolean(), any(), any());
- assertEquals(4, mAccessNetwork.size());
- assertEquals(EUTRAN, (int) mAccessNetwork.get(0));
- assertEquals(NGRAN, (int) mAccessNetwork.get(1));
- assertEquals(UTRAN, (int) mAccessNetwork.get(2));
- assertEquals(GERAN, (int) mAccessNetwork.get(3));
- }
-
- @Test
public void testSimLockScanPsPreferredWithNrAtTheEnd() throws Exception {
createSelector(SLOT_0_SUB_ID);
unsolBarringInfoChanged(false);
@@ -2778,33 +2749,6 @@
}
@Test
- public void testInvalidSubscriptionScanPsPreferredWithNr() throws Exception {
- createSelector(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
- unsolBarringInfoChanged(false);
-
- // The last valid subscription supported NR.
- doReturn(true).when(mCarrierConfigHelper).isVoNrEmergencySupported(eq(SLOT_0));
-
- EmergencyRegistrationResult regResult = getEmergencyRegResult(
- UNKNOWN, REGISTRATION_STATE_UNKNOWN, 0, false, false, 0, 0, "", "");
- SelectionAttributes attr = getSelectionAttributes(SLOT_0,
- SubscriptionManager.INVALID_SUBSCRIPTION_ID, regResult);
- mDomainSelector.selectDomain(attr, mTransportSelectorCallback);
- processAllMessages();
-
- bindImsServiceUnregistered();
- processAllMessages();
-
- verify(mWwanSelectorCallback, times(1)).onRequestEmergencyNetworkScan(
- any(), anyInt(), anyBoolean(), any(), any());
- assertEquals(4, mAccessNetwork.size());
- assertEquals(EUTRAN, (int) mAccessNetwork.get(0));
- assertEquals(NGRAN, (int) mAccessNetwork.get(1));
- assertEquals(UTRAN, (int) mAccessNetwork.get(2));
- assertEquals(GERAN, (int) mAccessNetwork.get(3));
- }
-
- @Test
public void testDefaultLimitedServiceEutran() throws Exception {
createSelector(SLOT_0_SUB_ID);
unsolBarringInfoChanged(false);
@@ -3230,7 +3174,7 @@
private void createSelector(int subId) throws Exception {
mDomainSelector = new EmergencyCallDomainSelector(
mContext, SLOT_0, subId, mHandlerThread.getLooper(),
- mImsStateTracker, mDestroyListener, mCsrdCtrl, mCarrierConfigHelper, mEcbmHelper);
+ mImsStateTracker, mDestroyListener, mCsrdCtrl, mEcbmHelper);
mDomainSelector.clearResourceConfiguration();
replaceInstance(DomainSelectorBase.class,
"mWwanSelectorCallback", mDomainSelector, mWwanSelectorCallback);
diff --git a/tests/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionServiceTest.java b/tests/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionServiceTest.java
index e0f7ffb..40a4616 100644
--- a/tests/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/domainselection/TelephonyDomainSelectionServiceTest.java
@@ -82,7 +82,6 @@
@NonNull Looper looper, @NonNull ImsStateTracker imsStateTracker,
@NonNull DomainSelectorBase.DestroyListener listener,
@NonNull CrossSimRedialingController crossSimRedialingController,
- @NonNull CarrierConfigHelper carrierConfigHelper,
@NonNull EmergencyCallbackModeHelper ecbmHelper) {
switch (selectorType) {
case DomainSelectionService.SELECTOR_TYPE_CALLING: // fallthrough
@@ -105,9 +104,8 @@
TestTelephonyDomainSelectionService(Context context,
@NonNull ImsStateTrackerFactory imsStateTrackerFactory,
@NonNull DomainSelectorFactory domainSelectorFactory,
- @Nullable CarrierConfigHelper carrierConfigHelper,
@Nullable EmergencyCallbackModeHelper ecbmHelper) {
- super(imsStateTrackerFactory, domainSelectorFactory, carrierConfigHelper, ecbmHelper);
+ super(imsStateTrackerFactory, domainSelectorFactory, ecbmHelper);
mContext = context;
}
@@ -131,7 +129,6 @@
@Mock private TransportSelectorCallback mSelectorCallback1;
@Mock private TransportSelectorCallback mSelectorCallback2;
@Mock private ImsStateTracker mImsStateTracker;
- @Mock private CarrierConfigHelper mCarrierConfigHelper;
@Mock private EmergencyCallbackModeHelper mEcbmHelper;
private final ServiceState mServiceState = new ServiceState();
@@ -154,7 +151,7 @@
mContext = new TestContext();
mDomainSelectionService = new TestTelephonyDomainSelectionService(mContext,
- mImsStateTrackerFactory, mDomainSelectorFactory, mCarrierConfigHelper, mEcbmHelper);
+ mImsStateTrackerFactory, mDomainSelectorFactory, mEcbmHelper);
mDomainSelectionService.onCreate();
mServiceHandler = new Handler(mDomainSelectionService.getLooper());
mTestableLooper = new TestableLooper(mDomainSelectionService.getLooper());