[automerger skipped] Import translations. DO NOT MERGE
am: 258c9e234d -s ours
am skip reason: subject contains skip directive

Change-Id: I46e008325a0a49ed8b5e6b9abe106d96f009e09c
diff --git a/src/com/android/server/telecom/AsyncRingtonePlayer.java b/src/com/android/server/telecom/AsyncRingtonePlayer.java
index 3745bc5..8f11882 100644
--- a/src/com/android/server/telecom/AsyncRingtonePlayer.java
+++ b/src/com/android/server/telecom/AsyncRingtonePlayer.java
@@ -26,6 +26,7 @@
 import android.os.HandlerThread;
 import android.os.Message;
 import android.telecom.Log;
+import android.telecom.Logging.Session;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.os.SomeArgs;
@@ -107,6 +108,7 @@
         args.arg2 = incomingCall;
         args.arg3 = volumeShaperConfig;
         args.arg4 = isVibrationEnabled;
+        args.arg5 = Log.createSubsession();
         postMessage(EVENT_PLAY, true /* shouldCreateHandler */, args);
         return mHapticsFuture;
     }
@@ -173,73 +175,87 @@
         Call incomingCall = (Call) args.arg2;
         VolumeShaper.Configuration volumeShaperConfig = (VolumeShaper.Configuration) args.arg3;
         boolean isVibrationEnabled = (boolean) args.arg4;
+        Session session = (Session) args.arg5;
         args.recycle();
-        // don't bother with any of this if there is an EVENT_STOP waiting.
-        if (mHandler.hasMessages(EVENT_STOP)) {
-            mHapticsFuture.complete(false /* ringtoneHasHaptics */);
-            mHapticsFuture = null;
-            return;
-        }
 
-        // If the Ringtone Uri is EMPTY, then the "None" Ringtone has been selected. Do not play
-        // anything.
-        if(Uri.EMPTY.equals(incomingCall.getRingtone())) {
-            mRingtone = null;
-            mHapticsFuture.complete(false /* ringtoneHasHaptics */);
-            mHapticsFuture = null;
-            return;
-        }
-
-        ThreadUtil.checkNotOnMainThread();
-        Log.i(this, "handlePlay: Play ringtone.");
-
-        if (mRingtone == null) {
-            mRingtone = factory.getRingtone(incomingCall, volumeShaperConfig);
-            if (mRingtone == null) {
-                Uri ringtoneUri = incomingCall.getRingtone();
-                String ringtoneUriString = (ringtoneUri == null) ? "null" :
-                        ringtoneUri.toSafeString();
-                Log.addEvent(null, LogUtils.Events.ERROR_LOG, "Failed to get ringtone from " +
-                        "factory. Skipping ringing. Uri was: " + ringtoneUriString);
-                mHapticsFuture.complete(false /* ringtoneHasHaptics */);
-                mHapticsFuture = null;
-                return;
-            }
-
-            // With the ringtone to play now known, we can determine if it has haptic channels or
-            // not; we will complete the haptics future so the default vibration code in Ringer
-            // can know whether to trigger the vibrator.
-            if (mHapticsFuture != null && !mHapticsFuture.isDone()) {
-                boolean hasHaptics = factory.hasHapticChannels(mRingtone);
-
-                Log.i(this, "handlePlay: hasHaptics=%b, isVibrationEnabled=%b", hasHaptics,
-                        isVibrationEnabled);
-                if (hasHaptics) {
-                    AudioAttributes attributes = mRingtone.getAudioAttributes();
-                    Log.d(this, "handlePlay: %s haptic channel",
-                            (isVibrationEnabled ? "unmuting" : "muting"));
-                    mRingtone.setAudioAttributes(
-                            new AudioAttributes.Builder(attributes)
-                                    .setHapticChannelsMuted(!isVibrationEnabled)
-                                    .build());
+        Log.continueSession(session, "ARP.hP");
+        try {
+            // don't bother with any of this if there is an EVENT_STOP waiting.
+            if (mHandler.hasMessages(EVENT_STOP)) {
+                if (mHapticsFuture != null) {
+                    mHapticsFuture.complete(false /* ringtoneHasHaptics */);
+                    mHapticsFuture = null;
                 }
-                mHapticsFuture.complete(hasHaptics);
-                mHapticsFuture = null;
-            }
-        }
-
-        if (mShouldPauseBetweenRepeat) {
-            // We're trying to pause between repeats, so the ringtone will not intentionally loop.
-            // Instead, we'll use a handler message to perform repeats.
-            handleRepeat();
-        } else {
-            mRingtone.setLooping(true);
-            if (mRingtone.isPlaying()) {
-                Log.d(this, "Ringtone already playing.");
                 return;
             }
-            mRingtone.play();
-            Log.i(this, "Play ringtone, looping.");
+
+            // If the Ringtone Uri is EMPTY, then the "None" Ringtone has been selected. Do not play
+            // anything.
+            if (Uri.EMPTY.equals(incomingCall.getRingtone())) {
+                mRingtone = null;
+                if (mHapticsFuture != null) {
+                    mHapticsFuture.complete(false /* ringtoneHasHaptics */);
+                    mHapticsFuture = null;
+                }
+
+                return;
+            }
+
+            ThreadUtil.checkNotOnMainThread();
+            Log.i(this, "handlePlay: Play ringtone.");
+
+            if (mRingtone == null) {
+                mRingtone = factory.getRingtone(incomingCall, volumeShaperConfig);
+                if (mRingtone == null) {
+                    Uri ringtoneUri = incomingCall.getRingtone();
+                    String ringtoneUriString = (ringtoneUri == null) ? "null" :
+                            ringtoneUri.toSafeString();
+                    Log.addEvent(null, LogUtils.Events.ERROR_LOG, "Failed to get ringtone from " +
+                            "factory. Skipping ringing. Uri was: " + ringtoneUriString);
+                    if (mHapticsFuture != null) {
+                        mHapticsFuture.complete(false /* ringtoneHasHaptics */);
+                        mHapticsFuture = null;
+                    }
+                    return;
+                }
+
+                // With the ringtone to play now known, we can determine if it has haptic channels or
+                // not; we will complete the haptics future so the default vibration code in Ringer
+                // can know whether to trigger the vibrator.
+                if (mHapticsFuture != null && !mHapticsFuture.isDone()) {
+                    boolean hasHaptics = factory.hasHapticChannels(mRingtone);
+
+                    Log.i(this, "handlePlay: hasHaptics=%b, isVibrationEnabled=%b", hasHaptics,
+                            isVibrationEnabled);
+                    if (hasHaptics) {
+                        AudioAttributes attributes = mRingtone.getAudioAttributes();
+                        Log.d(this, "handlePlay: %s haptic channel",
+                                (isVibrationEnabled ? "unmuting" : "muting"));
+                        mRingtone.setAudioAttributes(
+                                new AudioAttributes.Builder(attributes)
+                                        .setHapticChannelsMuted(!isVibrationEnabled)
+                                        .build());
+                    }
+                    mHapticsFuture.complete(hasHaptics);
+                    mHapticsFuture = null;
+                }
+            }
+
+            if (mShouldPauseBetweenRepeat) {
+                // We're trying to pause between repeats, so the ringtone will not intentionally loop.
+                // Instead, we'll use a handler message to perform repeats.
+                handleRepeat();
+            } else {
+                mRingtone.setLooping(true);
+                if (mRingtone.isPlaying()) {
+                    Log.d(this, "Ringtone already playing.");
+                    return;
+                }
+                mRingtone.play();
+                Log.i(this, "Play ringtone, looping.");
+            }
+        } finally {
+            Log.cancelSubsession(session);
         }
     }
 
diff --git a/src/com/android/server/telecom/CallAudioManager.java b/src/com/android/server/telecom/CallAudioManager.java
index 7e4c3ba..3345fa4 100644
--- a/src/com/android/server/telecom/CallAudioManager.java
+++ b/src/com/android/server/telecom/CallAudioManager.java
@@ -431,35 +431,45 @@
     }
 
     void silenceRingers() {
-        for (Call call : mRingingCalls) {
-            call.silence();
-        }
+        synchronized (mCallsManager.getLock()) {
+            for (Call call : mRingingCalls) {
+                call.silence();
+            }
 
-        mRinger.stopRinging();
-        mRinger.stopCallWaiting();
+            mRinger.stopRinging();
+            mRinger.stopCallWaiting();
+        }
     }
 
     @VisibleForTesting
     public boolean startRinging() {
-        return mRinger.startRinging(mForegroundCall,
-                mCallAudioRouteStateMachine.isHfpDeviceAvailable());
+        synchronized (mCallsManager.getLock()) {
+            return mRinger.startRinging(mForegroundCall,
+                    mCallAudioRouteStateMachine.isHfpDeviceAvailable());
+        }
     }
 
     @VisibleForTesting
     public void startCallWaiting(String reason) {
-        if (mRingingCalls.size() == 1) {
-            mRinger.startCallWaiting(mRingingCalls.iterator().next(), reason);
+        synchronized (mCallsManager.getLock()) {
+            if (mRingingCalls.size() == 1) {
+                mRinger.startCallWaiting(mRingingCalls.iterator().next(), reason);
+            }
         }
     }
 
     @VisibleForTesting
     public void stopRinging() {
-        mRinger.stopRinging();
+        synchronized (mCallsManager.getLock()) {
+            mRinger.stopRinging();
+        }
     }
 
     @VisibleForTesting
     public void stopCallWaiting() {
-        mRinger.stopCallWaiting();
+        synchronized (mCallsManager.getLock()) {
+            mRinger.stopCallWaiting();
+        }
     }
 
     @VisibleForTesting
@@ -801,10 +811,12 @@
     private void maybeStopRingingAndCallWaitingForAnsweredOrRejectedCall(Call call) {
         // Check to see if the call being answered/rejected is the only ringing call, since this
         // will be called before the connection service acknowledges the state change.
-        if (mRingingCalls.size() == 0 ||
-                (mRingingCalls.size() == 1 && call == mRingingCalls.iterator().next())) {
-            mRinger.stopRinging();
-            mRinger.stopCallWaiting();
+        synchronized (mCallsManager.getLock()) {
+            if (mRingingCalls.size() == 0 ||
+                    (mRingingCalls.size() == 1 && call == mRingingCalls.iterator().next())) {
+                mRinger.stopRinging();
+                mRinger.stopCallWaiting();
+            }
         }
     }
 
diff --git a/src/com/android/server/telecom/CallAudioModeStateMachine.java b/src/com/android/server/telecom/CallAudioModeStateMachine.java
index 42a1d36..48d09fc 100644
--- a/src/com/android/server/telecom/CallAudioModeStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioModeStateMachine.java
@@ -327,18 +327,25 @@
                     }
                     return HANDLED;
                 case NO_MORE_HOLDING_CALLS:
-                    // Do nothing.
+                    if (args.foregroundCallIsVoip) {
+                        transitionTo(mVoipCallFocusState);
+                    }
                     return HANDLED;
                 case NEW_ACTIVE_OR_DIALING_CALL:
-                    // Do nothing. Already active.
+                    if (args.foregroundCallIsVoip) {
+                        transitionTo(mVoipCallFocusState);
+                    }
                     return HANDLED;
                 case NEW_RINGING_CALL:
                     // Don't make a call ring over an active call, but do play a call waiting tone.
                     mCallAudioManager.startCallWaiting("call already active");
                     return HANDLED;
                 case NEW_HOLDING_CALL:
-                    // Don't do anything now. Putting an active call on hold will be handled when
+                    // Just check the voip mode. Putting an active call on hold will be handled when
                     // NO_MORE_ACTIVE_CALLS is processed.
+                    if (args.foregroundCallIsVoip) {
+                        transitionTo(mVoipCallFocusState);
+                    }
                     return HANDLED;
                 case FOREGROUND_VOIP_MODE_CHANGE:
                     if (args.foregroundCallIsVoip) {
@@ -382,18 +389,25 @@
                     }
                     return HANDLED;
                 case NO_MORE_HOLDING_CALLS:
-                    // Do nothing.
+                    if (!args.foregroundCallIsVoip) {
+                        transitionTo(mSimCallFocusState);
+                    }
                     return HANDLED;
                 case NEW_ACTIVE_OR_DIALING_CALL:
-                    // Do nothing. Already active.
+                    if (!args.foregroundCallIsVoip) {
+                        transitionTo(mSimCallFocusState);
+                    }
                     return HANDLED;
                 case NEW_RINGING_CALL:
                     // Don't make a call ring over an active call, but do play a call waiting tone.
                     mCallAudioManager.startCallWaiting("call already active");
                     return HANDLED;
                 case NEW_HOLDING_CALL:
-                    // Don't do anything now. Putting an active call on hold will be handled when
+                    // Just check the voip mode. Putting an active call on hold will be handled when
                     // NO_MORE_ACTIVE_CALLS is processed.
+                    if (!args.foregroundCallIsVoip) {
+                        transitionTo(mSimCallFocusState);
+                    }
                     return HANDLED;
                 case FOREGROUND_VOIP_MODE_CHANGE:
                     if (!args.foregroundCallIsVoip) {
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 0adfc41..f7e7958 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -35,6 +35,7 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
+import android.os.PersistableBundle;
 import android.os.Process;
 import android.os.SystemClock;
 import android.os.SystemProperties;
@@ -1100,9 +1101,11 @@
                 call.setIsVoipAudioMode(true);
             }
         }
-        if (isRttSettingOn() ||
+
+        boolean isRttSettingOn = isRttSettingOn(phoneAccountHandle);
+        if (isRttSettingOn ||
                 extras.getBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, false)) {
-            Log.i(this, "Incoming call requesting RTT, rtt setting is %b", isRttSettingOn());
+            Log.i(this, "Incoming call requesting RTT, rtt setting is %b", isRttSettingOn);
             call.createRttStreams();
             // Even if the phone account doesn't support RTT yet, the connection manager might
             // change that. Set this to check it later.
@@ -1532,11 +1535,12 @@
 
                     boolean isVoicemail = isVoicemail(callToUse.getHandle(), accountToUse);
 
-                    if (!isVoicemail && (isRttSettingOn() || (extras != null
+                    boolean isRttSettingOn = isRttSettingOn(phoneAccountHandle);
+                    if (!isVoicemail && (isRttSettingOn || (extras != null
                             && extras.getBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT,
                             false)))) {
                         Log.d(this, "Outgoing call requesting RTT, rtt setting is %b",
-                                isRttSettingOn());
+                                isRttSettingOn);
                         if (callToUse.isEmergencyCall() || (accountToUse != null
                                 && accountToUse.hasCapabilities(PhoneAccount.CAPABILITY_RTT))) {
                             // If the call requested RTT and it's an emergency call, ignore the
@@ -2319,9 +2323,22 @@
         mProximitySensorManager.turnOff(screenOnImmediately);
     }
 
-    private boolean isRttSettingOn() {
-        return Settings.Secure.getInt(mContext.getContentResolver(),
+    private boolean isRttSettingOn(PhoneAccountHandle handle) {
+        boolean isRttModeSettingOn = Settings.Secure.getInt(mContext.getContentResolver(),
                 Settings.Secure.RTT_CALLING_MODE, 0) != 0;
+        // If the carrier config says that we should ignore the RTT mode setting from the user,
+        // assume that it's off (i.e. only make an RTT call if it's requested through the extra).
+        boolean shouldIgnoreRttModeSetting = getCarrierConfigForPhoneAccount(handle)
+                .getBoolean(CarrierConfigManager.KEY_IGNORE_RTT_MODE_SETTING_BOOL, false);
+        return isRttModeSettingOn && !shouldIgnoreRttModeSetting;
+    }
+
+    private PersistableBundle getCarrierConfigForPhoneAccount(PhoneAccountHandle handle) {
+        int subscriptionId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(handle);
+        CarrierConfigManager carrierConfigManager =
+                mContext.getSystemService(CarrierConfigManager.class);
+        PersistableBundle result = carrierConfigManager.getConfigForSubId(subscriptionId);
+        return result == null ? new PersistableBundle() : result;
     }
 
     void phoneAccountSelected(Call call, PhoneAccountHandle account, boolean setDefault) {
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index 2909b72..1dceb01 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -326,7 +326,7 @@
         }
 
         if (hapticsFuture != null) {
-           mVibrateFuture = hapticsFuture.thenAccept(isUsingAudioCoupledHaptics -> {
+            mVibrateFuture = hapticsFuture.thenAccept(isUsingAudioCoupledHaptics -> {
                 if (!isUsingAudioCoupledHaptics || !mIsHapticPlaybackSupportedByDevice) {
                     Log.i(this, "startRinging: fileHasHaptics=%b, hapticsSupported=%b",
                             isUsingAudioCoupledHaptics, mIsHapticPlaybackSupportedByDevice);
diff --git a/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java b/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java
index 5b1971e..291fef8 100644
--- a/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java
+++ b/src/com/android/server/telecom/callfiltering/CallScreeningServiceController.java
@@ -253,7 +253,7 @@
         PersistableBundle configBundle = configManager.getConfig();
         if (configBundle != null) {
             componentName = ComponentName.unflattenFromString(configBundle.getString
-                    (CarrierConfigManager.KEY_CARRIER_CALL_SCREENING_APP_STRING));
+                    (CarrierConfigManager.KEY_CARRIER_CALL_SCREENING_APP_STRING, ""));
         }
 
         return componentName != null ? componentName.getPackageName() : null;
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java b/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java
index 01add22..3f70453 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioManagerTest.java
@@ -31,6 +31,7 @@
 import com.android.server.telecom.InCallTonePlayer;
 import com.android.server.telecom.RingbackPlayer;
 import com.android.server.telecom.Ringer;
+import com.android.server.telecom.TelecomSystem;
 import com.android.server.telecom.bluetooth.BluetoothStateReceiver;
 
 import org.junit.Before;
@@ -66,6 +67,7 @@
     @Mock private RingbackPlayer mRingbackPlayer;
     @Mock private DtmfLocalTonePlayer mDtmfLocalTonePlayer;
     @Mock private BluetoothStateReceiver mBluetoothStateReceiver;
+    @Mock private TelecomSystem.SyncRoot mLock;
 
     private CallAudioManager mCallAudioManager;
 
@@ -81,6 +83,7 @@
             }).when(mockInCallTonePlayer).startTone();
             return mockInCallTonePlayer;
         }).when(mPlayerFactory).createPlayer(anyInt());
+        when(mCallsManager.getLock()).thenReturn(mLock);
         mCallAudioManager = new CallAudioManager(
                 mCallAudioRouteStateMachine,
                 mCallsManager,
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioModeTransitionTests.java b/tests/src/com/android/server/telecom/tests/CallAudioModeTransitionTests.java
index 81339ed..ff5986e 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioModeTransitionTests.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioModeTransitionTests.java
@@ -414,6 +414,82 @@
         ));
 
         result.add(new ModeTestParameters(
+                "Swap between voip and sim calls - 1",
+                CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState
+                CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType
+                new CallAudioModeStateMachine.MessageArgs(
+                        false, // hasActiveOrDialingCalls
+                        false, // hasRingingCalls
+                        true, // hasHoldingCalls
+                        false, // isTonePlaying
+                        true, // foregroundCallIsVoip
+                        null // session
+                ),
+                CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName
+                FOCUS_VOICE, // expectedFocus
+                AudioManager.MODE_IN_COMMUNICATION, // expectedMode
+                NO_CHANGE, // expectedRingingInteraction
+                NO_CHANGE // expectedCallWaitingInteraction
+        ));
+
+        result.add(new ModeTestParameters(
+                "Swap between voip and sim calls - 2",
+                CallAudioModeStateMachine.ENTER_COMMS_FOCUS_FOR_TESTING, // initialAudioState
+                CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType
+                new CallAudioModeStateMachine.MessageArgs(
+                        false, // hasActiveOrDialingCalls
+                        false, // hasRingingCalls
+                        true, // hasHoldingCalls
+                        false, // isTonePlaying
+                        false, // foregroundCallIsVoip
+                        null // session
+                ),
+                CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName
+                FOCUS_VOICE, // expectedFocus
+                AudioManager.MODE_IN_CALL, // expectedMode
+                NO_CHANGE, // expectedRingingInteraction
+                NO_CHANGE // expectedCallWaitingInteraction
+        ));
+
+        result.add(new ModeTestParameters(
+                "Swap between voip and sim calls - 3",
+                CallAudioModeStateMachine.ENTER_COMMS_FOCUS_FOR_TESTING, // initialAudioState
+                CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType
+                new CallAudioModeStateMachine.MessageArgs(
+                        false, // hasActiveOrDialingCalls
+                        false, // hasRingingCalls
+                        true, // hasHoldingCalls
+                        false, // isTonePlaying
+                        false, // foregroundCallIsVoip
+                        null // session
+                ),
+                CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName
+                FOCUS_VOICE, // expectedFocus
+                AudioManager.MODE_IN_CALL, // expectedMode
+                NO_CHANGE, // expectedRingingInteraction
+                NO_CHANGE // expectedCallWaitingInteraction
+        ));
+
+        result.add(new ModeTestParameters(
+                "Swap between voip and sim calls - 4",
+                CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState
+                CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType
+                new CallAudioModeStateMachine.MessageArgs(
+                        false, // hasActiveOrDialingCalls
+                        false, // hasRingingCalls
+                        true, // hasHoldingCalls
+                        false, // isTonePlaying
+                        true, // foregroundCallIsVoip
+                        null // session
+                ),
+                CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName
+                FOCUS_VOICE, // expectedFocus
+                AudioManager.MODE_IN_COMMUNICATION, // expectedMode
+                NO_CHANGE, // expectedRingingInteraction
+                NO_CHANGE // expectedCallWaitingInteraction
+        ));
+
+        result.add(new ModeTestParameters(
                 "Call is taken off hold - 1",
                 CallAudioModeStateMachine.ENTER_TONE_OR_HOLD_FOCUS_FOR_TESTING, // initialAudioState
                 CallAudioModeStateMachine.NO_MORE_HOLDING_CALLS, // messageType
diff --git a/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java b/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
index 86bbadb..19278a5 100644
--- a/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
@@ -51,6 +51,7 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IInterface;
+import android.os.PersistableBundle;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.telecom.CallAudioState;
@@ -209,6 +210,8 @@
                 return Context.AUDIO_SERVICE;
             } else if (svcClass == TelephonyManager.class) {
                 return Context.TELEPHONY_SERVICE;
+            } else if (svcClass == CarrierConfigManager.class) {
+                return Context.CARRIER_CONFIG_SERVICE;
             }
             throw new UnsupportedOperationException();
         }
@@ -513,6 +516,9 @@
 
         when(mNotificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true);
 
+        when(mCarrierConfigManager.getConfig()).thenReturn(new PersistableBundle());
+        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(new PersistableBundle());
+
         when(mUserManager.getSerialNumberForUser(any(UserHandle.class))).thenReturn(-1L);
 
         doReturn(null).when(mApplicationContextSpy).registerReceiver(any(BroadcastReceiver.class),