Merge "Converting message.obj to AsyncResult to deliver context" into main
diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml
index f24af53..2bd6ac9 100644
--- a/res/values-fi/strings.xml
+++ b/res/values-fi/strings.xml
@@ -617,7 +617,7 @@
     <string name="ota_title_activate" msgid="4049645324841263423">"Aktivoi puhelin"</string>
     <string name="ota_touch_activate" msgid="838764494319694754">"Sinun täytyy soittaa erityinen puhelu aktivoidaksesi puhelimesi palvelun. \n\nPaina Aktivoi ja aktivoi puhelimesi kuulemiesi ohjeiden avulla."</string>
     <string name="ota_hfa_activation_title" msgid="3300556778212729671">"Aktivoidaan…"</string>
-    <string name="ota_hfa_activation_dialog_message" msgid="7921718445773342996">"Puhelimen mobiilitiedonsiirtopalvelua aktivoidaan.\n\nAktivointi voi kestää viisi minuuttia."</string>
+    <string name="ota_hfa_activation_dialog_message" msgid="7921718445773342996">"Puhelimen mobiilidatapalvelua aktivoidaan.\n\nAktivointi voi kestää viisi minuuttia."</string>
     <string name="ota_skip_activation_dialog_title" msgid="7666611236789203797">"Ohitetaanko aktivointi?"</string>
     <string name="ota_skip_activation_dialog_message" msgid="6691722887019708713">"Jos ohitat aktivoinnin, et voi soittaa puheluita etkä muodostaa verkkoyhteyttä (voit tosin muodostaa yhteyden Wi-Fi-verkkoihin). Sinua pyydetään aktivoimaan puhelimesi aina kun käynnistät sen siihen saakka, että aktivoit sen."</string>
     <string name="ota_skip_activation_dialog_skip_label" msgid="5908029466817825633">"Ohita"</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 61143c9..972e7cb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1206,8 +1206,13 @@
     <string name="incall_error_emergency_only">Not registered on network.</string>
     <!-- In-call screen: call failure message displayed in an error dialog -->
     <string name="incall_error_out_of_service">Mobile network not available.</string>
+    <!-- In-call screen: call failure message displayed in an error dialog if 2G is disabled -->
+    <string name="incall_error_out_of_service_2g">Mobile network not available.\n\nConnect to a wireless network to make a call.\n\n2G is disabled on this device, which may be impacting your connectivity. Go to Settings and enable "Allow 2G" to continue.</string>
     <!-- In-call screen: call failure message displayed in an error dialog -->
     <string name="incall_error_out_of_service_wfc">Mobile network is not available. Connect to a wireless network to make a call.</string>
+    <!-- In-call screen: call failure message displayed in an error dialog if the user disabled 2G -->
+    <string name="incall_error_out_of_service_wfc_2g_user">Mobile network is not available.\n\nConnect to a wireless network to make a call.\n\n2G is disabled on this device, which may be impacting your connectivity. Go to Settings and enable "Allow 2G" to continue.</string>
+
     <!-- In-call screen: call failure message displayed in an error dialog -->
     <string name="incall_error_no_phone_number_supplied">To place a call, enter a valid number.</string>
     <!-- In-call screen: call failure message displayed in an error dialog -->
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 2ae39df..b787e84 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -594,7 +594,7 @@
                 mImsStateCallbackController =
                         ImsStateCallbackController.make(this, PhoneFactory.getPhones().length);
                 mTelephonyRcsService = new TelephonyRcsService(this,
-                        PhoneFactory.getPhones().length);
+                        PhoneFactory.getPhones().length, mFeatureFlags);
                 mTelephonyRcsService.initialize();
                 imsRcsController.setRcsService(mTelephonyRcsService);
                 mImsProvisioningController =
diff --git a/src/com/android/phone/security/SafetySourceReceiver.java b/src/com/android/phone/security/SafetySourceReceiver.java
index d2be1a1..76f8e72 100644
--- a/src/com/android/phone/security/SafetySourceReceiver.java
+++ b/src/com/android/phone/security/SafetySourceReceiver.java
@@ -28,8 +28,10 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.flags.Flags;
 import com.android.phone.PhoneGlobals;
+import com.android.telephony.Rlog;
 
 public class SafetySourceReceiver extends BroadcastReceiver {
+    private static final String TAG = "TelephonySafetySourceReceiver";
     @Override
     public void onReceive(Context context, Intent intent) {
 
@@ -72,6 +74,11 @@
 
     @VisibleForTesting
     public Phone getDefaultPhone() {
-        return PhoneGlobals.getPhone();
+        try {
+            return PhoneGlobals.getPhone();
+        } catch (IllegalStateException e) {
+            Rlog.i(TAG, "Unable to get phone. Skipping safety source refresh: " + e.getMessage());
+        }
+        return null;
     }
 }
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index c00adef..ddcb5aa 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -23,12 +23,15 @@
 import android.telecom.DisconnectCause;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 import android.telephony.ims.ImsReasonInfo;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.CallFailCause;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.flags.FeatureFlags;
+import com.android.internal.telephony.flags.FeatureFlagsImpl;
 import com.android.phone.ImsUtil;
 import com.android.phone.PhoneGlobals;
 import com.android.phone.R;
@@ -86,7 +89,7 @@
     public static DisconnectCause toTelecomDisconnectCause(int telephonyDisconnectCause,
             String reason, int phoneId) {
         return toTelecomDisconnectCause(telephonyDisconnectCause, CallFailCause.NOT_VALID,
-                reason, phoneId, null, new FlagsAdapterImpl());
+                reason, phoneId, null, new FlagsAdapterImpl(), false);
     }
 
    /**
@@ -103,7 +106,27 @@
             int telephonyDisconnectCause, int telephonyPreciseDisconnectCause, String reason,
             int phoneId, ImsReasonInfo imsReasonInfo, FlagsAdapter featureFlags) {
         return toTelecomDisconnectCause(telephonyDisconnectCause, telephonyPreciseDisconnectCause,
-                reason, phoneId, imsReasonInfo, getCarrierConfigBundle(phoneId), featureFlags);
+                reason, phoneId, imsReasonInfo, getCarrierConfigBundle(phoneId), featureFlags,
+                false);
+    }
+
+   /**
+    * Converts from a disconnect code in {@link android.telephony.DisconnectCause} into a more
+    * generic {@link android.telecom.DisconnectCause}.object, possibly populated with a localized
+    * message and tone for Slot.
+    * @param telephonyDisconnectCause The code for the reason for the disconnect.
+    * @param telephonyPreciseDisconnectCause The code for the precise reason for the disconnect.
+    * @param reason Description of the reason for the disconnect, not intended for the user to see.
+    * @param phoneId To support localized message based on phoneId
+    * @param imsReasonInfo
+    */
+    public static DisconnectCause toTelecomDisconnectCause(
+            int telephonyDisconnectCause, int telephonyPreciseDisconnectCause, String reason,
+            int phoneId, ImsReasonInfo imsReasonInfo, FlagsAdapter featureFlags,
+            boolean shouldTreatAsEmergency) {
+        return toTelecomDisconnectCause(telephonyDisconnectCause, telephonyPreciseDisconnectCause,
+                reason, phoneId, imsReasonInfo, getCarrierConfigBundle(phoneId), featureFlags,
+                shouldTreatAsEmergency);
     }
 
     /**
@@ -116,7 +139,7 @@
     static DisconnectCause toTelecomDisconnectCause(
             int telephonyDisconnectCause, int telephonyPreciseDisconnectCause, String reason,
             int phoneId, ImsReasonInfo imsReasonInfo, PersistableBundle carrierConfig,
-            FlagsAdapter featureFlags) {
+            FlagsAdapter featureFlags, boolean shouldTreatAsEmergency) {
         Context context = PhoneGlobals.getInstance();
 
         return new DisconnectCause.Builder()
@@ -124,7 +147,7 @@
                 .setLabel(toTelecomDisconnectCauseLabel(context, telephonyDisconnectCause,
                         telephonyPreciseDisconnectCause, carrierConfig, featureFlags))
                 .setDescription(toTelecomDisconnectCauseDescription(
-                        context, telephonyDisconnectCause, phoneId))
+                        context, telephonyDisconnectCause, phoneId, shouldTreatAsEmergency))
                 .setReason(toTelecomDisconnectReason(
                         context, telephonyDisconnectCause, reason, phoneId))
                 .setTone(toTelecomDisconnectCauseTone(
@@ -633,7 +656,8 @@
      * Returns a description of the disconnect cause to be shown to the user.
      */
     private static CharSequence toTelecomDisconnectCauseDescription(
-            Context context, int telephonyDisconnectCause, int phoneId) {
+            Context context, int telephonyDisconnectCause, int phoneId,
+            boolean shouldTreatAsEmergency) {
         if (context == null ) {
             return "";
         }
@@ -756,14 +780,31 @@
 
             case android.telephony.DisconnectCause.OUT_OF_SERVICE:
                 // No network connection.
+                FeatureFlags mFeatureFlags = new FeatureFlagsImpl();
                 if (ImsUtil.shouldPromoteWfc(context, phoneId)) {
                     resourceId = R.string.incall_error_promote_wfc;
                 } else if (ImsUtil.isWfcModeWifiOnly(context, phoneId)) {
                     resourceId = R.string.incall_error_wfc_only_no_wireless_network;
                 } else if (ImsUtil.isWfcEnabled(context, phoneId)) {
-                    resourceId = R.string.incall_error_out_of_service_wfc;
+                    if (!mFeatureFlags.showCallFailNotificationFor2gToggle()) {
+                        resourceId = R.string.incall_error_out_of_service_wfc;
+                        break;
+                    }
+                    if (is2gDisabled(phoneId) && !shouldTreatAsEmergency) {
+                        resourceId = R.string.incall_error_out_of_service_wfc_2g_user;
+                    } else {
+                        resourceId = R.string.incall_error_out_of_service_wfc;
+                    }
                 } else {
-                    resourceId = R.string.incall_error_out_of_service;
+                    if (!mFeatureFlags.showCallFailNotificationFor2gToggle()) {
+                        resourceId = R.string.incall_error_out_of_service;
+                        break;
+                    }
+                    if (is2gDisabled(phoneId) && !shouldTreatAsEmergency) {
+                        resourceId = R.string.incall_error_out_of_service_2g;
+                    } else {
+                        resourceId = R.string.incall_error_out_of_service;
+                    }
                 }
                 break;
 
@@ -986,4 +1027,18 @@
         return config;
     }
 
+    /**
+     * Returns true if 2G is disabled.
+     */
+    protected static boolean is2gDisabled(int phoneId) {
+        Phone phone = PhoneFactory.getPhone(phoneId);
+        if (phone == null) {
+            return false;
+        }
+        long bitmask2g = TelephonyManager.NETWORK_CLASS_BITMASK_2G;
+        long currentlyAllowedNetworkTypes = phone.getAllowedNetworkTypes(
+                TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G);
+        boolean is2gEnabled = (currentlyAllowedNetworkTypes & bitmask2g) != 0;
+        return !is2gEnabled;
+    }
 }
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 7749a2c..5bfad6b 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -2561,7 +2561,8 @@
                                         preciseDisconnectCause,
                                         mOriginalConnection.getVendorDisconnectCause(),
                                         getPhone().getPhoneId(), imsReasonInfo,
-                                        new FlagsAdapterImpl()));
+                                        new FlagsAdapterImpl(),
+                                        shouldTreatAsEmergencyCall()));
                         close();
                     }
                     break;
diff --git a/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java b/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java
index 53b3659..962cbf1 100644
--- a/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java
+++ b/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelector.java
@@ -161,6 +161,7 @@
     private @RadioAccessNetworkType List<Integer> mLastPreferredNetworks;
 
     private CancellationSignal mCancelSignal;
+    private EmergencyRegistrationResult mLastRegResult;
 
     // Members for carrier configuration
     private @RadioAccessNetworkType int[] mImsRatsConfig;
@@ -297,6 +298,7 @@
             return;
         }
 
+        mLastRegResult = result;
         removeMessages(MSG_NETWORK_SCAN_TIMEOUT);
         onWwanNetworkTypeSelected(getAccessNetworkType(result));
         mCancelSignal = null;
@@ -446,6 +448,7 @@
         logi("selectDomain attr=" + attr);
         mTransportSelectorCallback = cb;
         mSelectionAttributes = attr;
+        mLastRegResult = mSelectionAttributes.getEmergencyRegistrationResult();
 
         TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
         mModemCount = tm.getActiveModemCount();
@@ -501,7 +504,26 @@
      */
     private void updateCarrierConfiguration() {
         CarrierConfigManager configMgr = mContext.getSystemService(CarrierConfigManager.class);
-        PersistableBundle b = configMgr.getConfigForSubId(getSubId());
+        PersistableBundle b = configMgr.getConfigForSubId(getSubId(),
+                KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY,
+                KEY_EMERGENCY_OVER_IMS_ROAMING_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY,
+                KEY_EMERGENCY_OVER_CS_SUPPORTED_ACCESS_NETWORK_TYPES_INT_ARRAY,
+                KEY_EMERGENCY_OVER_CS_ROAMING_SUPPORTED_ACCESS_NETWORK_TYPES_INT_ARRAY,
+                KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY,
+                KEY_EMERGENCY_DOMAIN_PREFERENCE_ROAMING_INT_ARRAY,
+                KEY_PREFER_IMS_EMERGENCY_WHEN_VOICE_CALLS_ON_CS_BOOL,
+                KEY_EMERGENCY_VOWIFI_REQUIRES_CONDITION_INT,
+                KEY_EMERGENCY_SCAN_TIMER_SEC_INT,
+                KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT,
+                KEY_MAXIMUM_NUMBER_OF_EMERGENCY_TRIES_OVER_VOWIFI_INT,
+                KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL,
+                KEY_EMERGENCY_NETWORK_SCAN_TYPE_INT,
+                KEY_EMERGENCY_CALL_SETUP_TIMER_ON_CURRENT_NETWORK_SEC_INT,
+                KEY_EMERGENCY_REQUIRES_IMS_REGISTRATION_BOOL,
+                KEY_EMERGENCY_REQUIRES_VOLTE_ENABLED_BOOL,
+                KEY_EMERGENCY_LTE_PREFERRED_AFTER_NR_FAILED_BOOL,
+                KEY_SCAN_LIMITED_SERVICE_AFTER_VOLTE_FAILURE_BOOL,
+                KEY_EMERGENCY_CDMA_PREFERRED_NUMBERS_STRING_ARRAY);
         if (b == null) {
             b = CarrierConfigManager.getDefaultConfig();
         }
@@ -890,10 +912,13 @@
         } else if (csPreferred || mLastNetworkType == EUTRAN || mLastNetworkType == NGRAN) {
             if (!csPreferred && mLastNetworkType == NGRAN && mLtePreferredAfterNrFailure) {
                 // LTE is preferred after dialing over NR failed.
-                List<Integer> imsRats = getImsNetworkTypeConfiguration();
-                imsRats.remove(Integer.valueOf(NGRAN));
-                preferredNetworks = generatePreferredNetworks(imsRats,
+                preferredNetworks = generatePreferredNetworks(getImsNetworkTypeConfiguration(),
                         getCsNetworkTypeConfiguration());
+                // Make NGRAN have the lowest priority
+                if (preferredNetworks.contains(NGRAN)) {
+                    preferredNetworks.remove(Integer.valueOf(NGRAN));
+                    preferredNetworks.add(NGRAN);
+                }
             } else  if (csPriority > NOT_SUPPORTED) {
                 // PS tried, generate the list with CS preferred.
                 preferredNetworks = generatePreferredNetworks(getCsNetworkTypeConfiguration(),
@@ -1276,8 +1301,7 @@
         tm = tm.createForSubscriptionId(getSubId());
         String netIso = tm.getNetworkCountryIso();
 
-        EmergencyRegistrationResult regResult =
-                mSelectionAttributes.getEmergencyRegistrationResult();
+        EmergencyRegistrationResult regResult = mLastRegResult;
         if (regResult != null) {
             if (regResult.getRegState() == REGISTRATION_STATE_HOME) return false;
             if (regResult.getRegState() == REGISTRATION_STATE_ROAMING) return true;
diff --git a/src/com/android/services/telephony/rcs/TelephonyRcsService.java b/src/com/android/services/telephony/rcs/TelephonyRcsService.java
index f6ba40b..63753c2 100644
--- a/src/com/android/services/telephony/rcs/TelephonyRcsService.java
+++ b/src/com/android/services/telephony/rcs/TelephonyRcsService.java
@@ -33,6 +33,7 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.PhoneConfigurationManager;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.metrics.RcsStats;
 import com.android.internal.util.IndentingPrintWriter;
 import com.android.phone.ImsStateCallbackController;
@@ -63,7 +64,8 @@
         /**
          * @return an instance of {@link UceControllerManager} associated with the slot specified.
          */
-        UceControllerManager createUceControllerManager(Context context, int slotId, int subId);
+        UceControllerManager createUceControllerManager(Context context, int slotId, int subId,
+                FeatureFlags featureFlags);
 
         /**
          * @return an instance of {@link SipTransportController} for the slot and subscription
@@ -80,8 +82,8 @@
 
         @Override
         public UceControllerManager createUceControllerManager(Context context, int slotId,
-                int subId) {
-            return new UceControllerManager(context, slotId, subId);
+                int subId, FeatureFlags featureFlags) {
+            return new UceControllerManager(context, slotId, subId, featureFlags);
         }
 
         @Override
@@ -112,6 +114,7 @@
 
     private final Context mContext;
     private final Object mLock = new Object();
+    private final FeatureFlags mFeatureFlags;
     private int mNumSlots;
 
     // Maps slot ID -> RcsFeatureController.
@@ -160,23 +163,26 @@
         return true;
     });
 
-    public TelephonyRcsService(Context context, int numSlots) {
+    public TelephonyRcsService(Context context, int numSlots, FeatureFlags featureFlags) {
         mContext = context;
         mNumSlots = numSlots;
         mFeatureControllers = new SparseArray<>(numSlots);
         mSlotToAssociatedSubIds = new SparseArray<>(numSlots);
         mRcsUceEnabled = sResourceProxy.getDeviceUceEnabled(mContext);
+        mFeatureFlags = featureFlags;
         RcsStats.getInstance().registerUceCallback();
     }
 
     @VisibleForTesting
-    public TelephonyRcsService(Context context, int numSlots, ResourceProxy resourceProxy) {
+    public TelephonyRcsService(Context context, int numSlots, ResourceProxy resourceProxy,
+            FeatureFlags featureFlags) {
         mContext = context;
         mNumSlots = numSlots;
         mFeatureControllers = new SparseArray<>(numSlots);
         mSlotToAssociatedSubIds = new SparseArray<>(numSlots);
         sResourceProxy = resourceProxy;
         mRcsUceEnabled = sResourceProxy.getDeviceUceEnabled(mContext);
+        mFeatureFlags = featureFlags;
         RcsStats.getInstance().registerUceCallback();
     }
 
@@ -310,8 +316,8 @@
     private void updateSupportedFeatures(RcsFeatureController c, int slotId, int subId) {
         if (isDeviceUceEnabled() && doesSubscriptionSupportPresence(subId)) {
             if (c.getFeature(UceControllerManager.class) == null) {
-                c.addFeature(mFeatureFactory.createUceControllerManager(mContext, slotId, subId),
-                        UceControllerManager.class);
+                c.addFeature(mFeatureFactory.createUceControllerManager(
+                        mContext, slotId, subId, mFeatureFlags), UceControllerManager.class);
             }
         } else {
             if (c.getFeature(UceControllerManager.class) != null) {
diff --git a/src/com/android/services/telephony/rcs/UceControllerManager.java b/src/com/android/services/telephony/rcs/UceControllerManager.java
index 02ae048..b7e12a3 100644
--- a/src/com/android/services/telephony/rcs/UceControllerManager.java
+++ b/src/com/android/services/telephony/rcs/UceControllerManager.java
@@ -32,6 +32,7 @@
 import com.android.ims.RcsFeatureManager;
 import com.android.ims.rcs.uce.UceController;
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.flags.FeatureFlags;
 
 import java.io.PrintWriter;
 import java.util.List;
@@ -53,15 +54,17 @@
     private final int mSlotId;
     private final Context mContext;
     private final ExecutorService mExecutorService;
+    private final FeatureFlags mFeatureFlags;
 
     private volatile @Nullable UceController mUceController;
     private volatile @Nullable RcsFeatureManager mRcsFeatureManager;
 
-    public UceControllerManager(Context context, int slotId, int subId) {
+    public UceControllerManager(Context context, int slotId, int subId, FeatureFlags featureFlags) {
         Log.d(LOG_TAG, "create: slotId=" + slotId + ", subId=" + subId);
         mSlotId = slotId;
         mContext = context;
         mExecutorService = Executors.newSingleThreadExecutor();
+        mFeatureFlags = featureFlags;
         initUceController(subId);
     }
 
@@ -70,11 +73,12 @@
      */
     @VisibleForTesting
     public UceControllerManager(Context context, int slotId, ExecutorService executor,
-            UceController uceController) {
+            UceController uceController, FeatureFlags featureFlags) {
         mSlotId = slotId;
         mContext = context;
         mExecutorService = executor;
         mUceController = uceController;
+        mFeatureFlags = featureFlags;
     }
 
     @Override
@@ -440,7 +444,7 @@
         if (mUceController == null) {
             // Create new UceController only when the subscription ID is valid.
             if (SubscriptionManager.isValidSubscriptionId(newSubId)) {
-                mUceController = new UceController(mContext, newSubId);
+                mUceController = new UceController(mContext, newSubId, mFeatureFlags);
             }
         } else if (mUceController.getSubId() != newSubId) {
             // The subscription ID is updated. Remove the old UceController instance.
@@ -448,7 +452,7 @@
             mUceController = null;
             // Create new UceController only when the subscription ID is valid.
             if (SubscriptionManager.isValidSubscriptionId(newSubId)) {
-                mUceController = new UceController(mContext, newSubId);
+                mUceController = new UceController(mContext, newSubId, mFeatureFlags);
             }
         }
     }
diff --git a/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java b/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
index e5f7fd3..71a23e6 100644
--- a/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
+++ b/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
@@ -152,7 +152,8 @@
         android.telecom.DisconnectCause tcCause =
                 DisconnectCauseUtil.toTelecomDisconnectCause(
                         DisconnectCause.BUSY, -1 /*  precise label is NOT given */,
-                        EMPTY_STRING, PHONE_ID, null, getBundleWithBusyToneArray(), mFeatureFlags);
+                        EMPTY_STRING, PHONE_ID, null, getBundleWithBusyToneArray(), mFeatureFlags,
+                        false);
 
         assertBusyCauseWithTargetLabel(R.string.callFailed_userBusy, tcCause);
     }
@@ -170,7 +171,8 @@
         android.telecom.DisconnectCause tcCause =
                 DisconnectCauseUtil.toTelecomDisconnectCause(DisconnectCause.BUSY,
                         CallFailCause.USER_BUSY /* Telephony defined a precise label */,
-                        EMPTY_STRING, PHONE_ID, null, getBundleWithBusyToneArray(), mFeatureFlags);
+                        EMPTY_STRING, PHONE_ID, null, getBundleWithBusyToneArray(), mFeatureFlags,
+                        false);
         // Note: The precise label should not be overridden even though the carrier defined
         // the cause to play a busy tone
         assertBusyCauseWithTargetLabel(R.string.clh_callFailed_user_busy_txt, tcCause);
diff --git a/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java b/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java
index 50085e7..0735c3f 100644
--- a/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java
+++ b/tests/src/com/android/services/telephony/domainselection/EmergencyCallDomainSelectorTest.java
@@ -71,6 +71,7 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyVararg;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
@@ -234,7 +235,7 @@
         when(mTelephonyManager.getActiveModemCount()).thenReturn(1);
 
         mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt()))
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg()))
             .thenReturn(getDefaultPersistableBundle());
 
         mConnectivityManager = mContext.getSystemService(ConnectivityManager.class);
@@ -335,7 +336,7 @@
                 CarrierConfigManager.ImsEmergency.DOMAIN_PS_NON_3GPP,
                 };
         bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY, domainPreference);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -398,7 +399,7 @@
                 CarrierConfigManager.ImsEmergency.DOMAIN_CS
                 };
         bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY, domainPreference);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(true);
@@ -660,7 +661,7 @@
     public void testAirplaneRequiresRegCombinedImsNotRegisteredSelectPs() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_REQUIRES_IMS_REGISTRATION_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -689,7 +690,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putIntArray(KEY_EMERGENCY_OVER_CS_SUPPORTED_ACCESS_NETWORK_TYPES_INT_ARRAY,
                 new int[0]);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -966,7 +967,7 @@
                 CarrierConfigManager.ImsEmergency.DOMAIN_CS
                 };
         bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY, domainPreference);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1000,7 +1001,7 @@
                 CarrierConfigManager.ImsEmergency.DOMAIN_CS
                 };
         bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY, domainPreference);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1025,7 +1026,7 @@
                 CarrierConfigManager.ImsEmergency.DOMAIN_PS_3GPP
                 };
         bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY, domainPreference);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1351,7 +1352,7 @@
     public void testVoLteOnEpsImsNotRegisteredSelectPs() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_REQUIRES_VOLTE_ENABLED_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1374,7 +1375,7 @@
     public void testVoLteOffEpsImsNotRegisteredScanCsPreferred() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_REQUIRES_VOLTE_ENABLED_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         // Disable VoLTE.
         when(mMmTelManager.isAdvancedCallingSettingEnabled()).thenReturn(false);
@@ -1400,7 +1401,7 @@
     public void testRequiresRegEpsImsNotRegisteredScanCsPreferred() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_REQUIRES_IMS_REGISTRATION_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1424,7 +1425,7 @@
 
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_REQUIRES_IMS_REGISTRATION_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1447,7 +1448,7 @@
             throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_REQUIRES_IMS_REGISTRATION_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -1469,7 +1470,7 @@
     public void testDefaultEpsImsRegisteredBarredScanTimeoutWifi() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         mResultConsumer = null;
         createSelector(SLOT_0_SUB_ID);
@@ -1513,7 +1514,7 @@
                 TelephonyManager.SIM_STATE_PIN_REQUIRED);
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(true);
@@ -1538,7 +1539,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_EMERGENCY_VOWIFI_REQUIRES_CONDITION_INT, VOWIFI_REQUIRES_SETTING_ENABLED);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(true);
@@ -1578,7 +1579,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_EMERGENCY_VOWIFI_REQUIRES_CONDITION_INT, VOWIFI_REQUIRES_VALID_EID);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(true);
@@ -1825,7 +1826,7 @@
     public void testFullService() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putInt(KEY_EMERGENCY_NETWORK_SCAN_TYPE_INT, SCAN_TYPE_FULL_SERVICE);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         mResultConsumer = null;
         createSelector(SLOT_0_SUB_ID);
@@ -1856,7 +1857,7 @@
     public void testFullServiceInRoaming() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putInt(KEY_EMERGENCY_NETWORK_SCAN_TYPE_INT, SCAN_TYPE_FULL_SERVICE);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(true);
@@ -1881,7 +1882,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putInt(KEY_EMERGENCY_NETWORK_SCAN_TYPE_INT,
                 SCAN_TYPE_FULL_SERVICE_FOLLOWED_BY_LIMITED_SERVICE);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         mResultConsumer = null;
         createSelector(SLOT_0_SUB_ID);
@@ -2162,7 +2163,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_SCAN_LIMITED_SERVICE_AFTER_VOLTE_FAILURE_BOOL,
                 true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -2415,7 +2416,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 20);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         setupForHandleScanResult();
 
@@ -2440,7 +2441,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 20);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         setupForHandleScanResult();
 
@@ -2464,7 +2465,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 20);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         setupForHandleScanResult();
 
@@ -2477,7 +2478,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 20);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         setupForHandleScanResult();
 
@@ -2502,7 +2503,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 5);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -2556,7 +2557,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 5);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -2635,7 +2636,7 @@
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 20);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         setupForHandleScanResult();
 
@@ -2661,7 +2662,7 @@
         bundle.putBoolean(KEY_EMERGENCY_CALL_OVER_EMERGENCY_PDN_BOOL, true);
         bundle.putInt(KEY_MAXIMUM_CELLULAR_SEARCH_TIMER_SEC_INT, 20);
         bundle.putInt(KEY_MAXIMUM_NUMBER_OF_EMERGENCY_TRIES_OVER_VOWIFI_INT, 2);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         setupForHandleScanResult();
 
@@ -2824,7 +2825,7 @@
     public void testDefaultLimitedServiceScanTypeFullService() throws Exception {
         PersistableBundle bundle = getDefaultPersistableBundle();
         bundle.putInt(KEY_EMERGENCY_NETWORK_SCAN_TYPE_INT, SCAN_TYPE_FULL_SERVICE);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -2847,7 +2848,7 @@
         bundle.putIntArray(KEY_EMERGENCY_OVER_IMS_SUPPORTED_3GPP_NETWORK_TYPES_INT_ARRAY,
                 new int[] { NGRAN, EUTRAN });
         bundle.putBoolean(KEY_EMERGENCY_LTE_PREFERRED_AFTER_NR_FAILED_BOOL, true);
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
@@ -2868,10 +2869,11 @@
 
         verify(mWwanSelectorCallback, times(1)).onRequestEmergencyNetworkScan(
                 any(), anyInt(), anyBoolean(), any(), any());
-        assertEquals(3, mAccessNetwork.size());
+        assertEquals(4, mAccessNetwork.size());
         assertEquals(EUTRAN, (int) mAccessNetwork.get(0));
         assertEquals(UTRAN, (int) mAccessNetwork.get(1));
         assertEquals(GERAN, (int) mAccessNetwork.get(2));
+        assertEquals(NGRAN, (int) mAccessNetwork.get(3));
     }
 
     @Test
@@ -3101,12 +3103,64 @@
                 any(), anyInt(), anyBoolean(), any(), any());
     }
 
+    @Test
+    public void testIsInRoaming() throws Exception {
+        PersistableBundle bundle = getDefaultPersistableBundle();
+        int[] domainPreference = new int[] {
+                CarrierConfigManager.ImsEmergency.DOMAIN_PS_3GPP,
+                };
+        bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_INT_ARRAY, domainPreference);
+        int[] domainPreferenceRoam = new int[] {
+                CarrierConfigManager.ImsEmergency.DOMAIN_PS_3GPP,
+                CarrierConfigManager.ImsEmergency.DOMAIN_CS,
+                };
+        bundle.putIntArray(KEY_EMERGENCY_DOMAIN_PREFERENCE_ROAMING_INT_ARRAY, domainPreferenceRoam);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
+        doReturn("").when(mTelephonyManager).getNetworkCountryIso();
+        doReturn("us").when(mTelephonyManager).getSimCountryIso();
+
+        mResultConsumer = null;
+        createSelector(SLOT_0_SUB_ID);
+        unsolBarringInfoChanged(true);
+
+        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(), eq(false), any(), any());
+        assertEquals(1, mAccessNetwork.size());
+        assertEquals(EUTRAN, (int) mAccessNetwork.get(0));
+        assertNotNull(mResultConsumer);
+
+        regResult = getEmergencyRegResult(EUTRAN, REGISTRATION_STATE_UNKNOWN,
+                0, false, false, 0, 0, "", "", "zz");
+        mResultConsumer.accept(regResult);
+        processAllMessages();
+
+        mDomainSelector.reselectDomain(attr);
+        processAllMessages();
+
+        verify(mWwanSelectorCallback, times(2)).onRequestEmergencyNetworkScan(
+                any(), anyInt(), eq(false), any(), any());
+        assertEquals(3, mAccessNetwork.size());
+        assertEquals(UTRAN, (int) mAccessNetwork.get(0));
+        assertEquals(GERAN, (int) mAccessNetwork.get(1));
+        assertEquals(EUTRAN, (int) mAccessNetwork.get(2));
+    }
+
     private void setupForScanListTest(PersistableBundle bundle) throws Exception {
         setupForScanListTest(bundle, false);
     }
 
     private void setupForScanListTest(PersistableBundle bundle, boolean psFailed) throws Exception {
-        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(bundle);
+        when(mCarrierConfigManager.getConfigForSubId(anyInt(), anyVararg())).thenReturn(bundle);
 
         createSelector(SLOT_0_SUB_ID);
         unsolBarringInfoChanged(false);
diff --git a/tests/src/com/android/services/telephony/rcs/TelephonyRcsServiceTest.java b/tests/src/com/android/services/telephony/rcs/TelephonyRcsServiceTest.java
index d575d77..4cabf95 100644
--- a/tests/src/com/android/services/telephony/rcs/TelephonyRcsServiceTest.java
+++ b/tests/src/com/android/services/telephony/rcs/TelephonyRcsServiceTest.java
@@ -39,6 +39,7 @@
 import com.android.ims.FeatureConnector;
 import com.android.ims.RcsFeatureManager;
 import com.android.internal.telephony.ISub;
+import com.android.internal.telephony.flags.FeatureFlags;
 
 import org.junit.After;
 import org.junit.Before;
@@ -68,6 +69,8 @@
     @Mock
     private TelephonyManager mTelephonyManager;
 
+    @Mock FeatureFlags mFeatureFlags;
+
     private RcsFeatureController mFeatureControllerSlot0;
     private RcsFeatureController mFeatureControllerSlot1;
 
@@ -91,9 +94,9 @@
         doReturn(mFeatureControllerSlot1).when(mFeatureFactory).createController(any(), eq(1),
                 anyInt());
         doReturn(mMockUceSlot0).when(mFeatureFactory).createUceControllerManager(any(), eq(0),
-                anyInt());
+                anyInt(), any());
         doReturn(mMockUceSlot1).when(mFeatureFactory).createUceControllerManager(any(), eq(1),
-                anyInt());
+                anyInt(), any());
         doReturn(mMockSipTransportSlot0).when(mFeatureFactory).createSipTransportController(any(),
                 eq(0), anyInt());
         doReturn(mMockSipTransportSlot1).when(mFeatureFactory).createSipTransportController(any(),
@@ -363,7 +366,8 @@
     }
 
     private TelephonyRcsService createRcsService(int numSlots) {
-        TelephonyRcsService service = new TelephonyRcsService(mContext, numSlots, mResourceProxy);
+        TelephonyRcsService service = new TelephonyRcsService(mContext, numSlots, mResourceProxy,
+                mFeatureFlags);
         service.setFeatureFactory(mFeatureFactory);
         service.initialize();
         verify(mContext).registerReceiver(mReceiverCaptor.capture(), any());
diff --git a/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java b/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
index 17decb9..e506931 100644
--- a/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
+++ b/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
@@ -35,6 +35,7 @@
 import com.android.TestExecutorService;
 import com.android.ims.RcsFeatureManager;
 import com.android.ims.rcs.uce.UceController;
+import com.android.internal.telephony.flags.FeatureFlags;
 
 import org.junit.After;
 import org.junit.Before;
@@ -52,6 +53,7 @@
 
     @Mock private UceController mUceController;
     @Mock private RcsFeatureManager mRcsFeatureManager;
+    @Mock private FeatureFlags mFeatureFlags;
 
     private final ExecutorService mExecutorService = new TestExecutorService();
 
@@ -260,7 +262,7 @@
 
     private UceControllerManager getUceControllerManager() {
         UceControllerManager manager = new UceControllerManager(mContext, mSlotId,
-                mExecutorService, mUceController);
+                mExecutorService, mUceController, mFeatureFlags);
         return manager;
     }
 }