Merge "Fix height of "add blocked number" button on the blocked numbers screen." am: e3c7578b61 am: 65671fc977 am: 0577c613e2 am: f03e86dd95

Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/1861799

Change-Id: Id0df79d7f26abe42eb20aee14bdc98a461f81c71
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c38fa4e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+*.iml
diff --git a/src/com/android/server/telecom/AsyncRingtonePlayer.java b/src/com/android/server/telecom/AsyncRingtonePlayer.java
index bf2472f..d7786e1 100644
--- a/src/com/android/server/telecom/AsyncRingtonePlayer.java
+++ b/src/com/android/server/telecom/AsyncRingtonePlayer.java
@@ -77,8 +77,10 @@
      *         {@code False} indicates that a haptic track is NOT present on the ringtone;
      *         in this case the default vibration in {@link Ringer} should be trigger if needed.
      */
-    public @NonNull CompletableFuture<Boolean> play(RingtoneFactory factory, Call incomingCall,
-            @Nullable VolumeShaper.Configuration volumeShaperConfig, boolean isVibrationEnabled) {
+    public @NonNull
+    CompletableFuture<Boolean> play(RingtoneFactory factory, Call incomingCall,
+            @Nullable VolumeShaper.Configuration volumeShaperConfig, boolean isRingerAudible,
+            boolean isVibrationEnabled) {
         Log.d(this, "Posting play.");
         if (mHapticsFuture == null) {
             mHapticsFuture = new CompletableFuture<>();
@@ -88,7 +90,8 @@
         args.arg2 = incomingCall;
         args.arg3 = volumeShaperConfig;
         args.arg4 = isVibrationEnabled;
-        args.arg5 = Log.createSubsession();
+        args.arg5 = isRingerAudible;
+        args.arg6 = Log.createSubsession();
         postMessage(EVENT_PLAY, true /* shouldCreateHandler */, args);
         return mHapticsFuture;
     }
@@ -152,30 +155,33 @@
         Call incomingCall = (Call) args.arg2;
         VolumeShaper.Configuration volumeShaperConfig = (VolumeShaper.Configuration) args.arg3;
         boolean isVibrationEnabled = (boolean) args.arg4;
-        Session session = (Session) args.arg5;
+        boolean isRingerAudible = (boolean) args.arg5;
+        Session session = (Session) args.arg6;
         args.recycle();
 
         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;
-                }
+                completeHapticFuture(false /* ringtoneHasHaptics */);
                 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;
-                if (mHapticsFuture != null) {
-                    mHapticsFuture.complete(false /* ringtoneHasHaptics */);
-                    mHapticsFuture = null;
+            // If the Ringtone Uri is EMPTY, then the "None" Ringtone has been selected.
+            // If ringer is not audible for this call, then the phone is in "Vibrate" mode.
+            // Use haptic-only ringtone or do not play anything.
+            if (!isRingerAudible || Uri.EMPTY.equals(incomingCall.getRingtone())) {
+                if (isVibrationEnabled) {
+                    mRingtone = factory.getHapticOnlyRingtone();
+                    if (mRingtone == null) {
+                        completeHapticFuture(false /* ringtoneHasHaptics */);
+                        return;
+                    }
+                } else {
+                    mRingtone = null;
+                    completeHapticFuture(false /* ringtoneHasHaptics */);
+                    return;
                 }
-
-                return;
             }
 
             ThreadUtil.checkNotOnMainThread();
@@ -189,34 +195,30 @@
                             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;
-                    }
+                    completeHapticFuture(false /* ringtoneHasHaptics */);
                     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);
-                    SystemSettingsUtil systemSettingsUtil = new SystemSettingsUtil();
-                    if (hasHaptics && (volumeShaperConfig == null
-                            || systemSettingsUtil.enableAudioCoupledVibrationForRampingRinger())) {
-                        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;
+            // 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);
+                SystemSettingsUtil systemSettingsUtil = new SystemSettingsUtil();
+                if (hasHaptics && (volumeShaperConfig == null
+                        || systemSettingsUtil.enableAudioCoupledVibrationForRampingRinger())) {
+                    AudioAttributes attributes = mRingtone.getAudioAttributes();
+                    Log.d(this, "handlePlay: %s haptic channel",
+                            (isVibrationEnabled ? "unmuting" : "muting"));
+                    mRingtone.setAudioAttributes(
+                            new AudioAttributes.Builder(attributes)
+                                    .setHapticChannelsMuted(!isVibrationEnabled)
+                                    .build());
                 }
+                completeHapticFuture(hasHaptics);
             }
 
             mRingtone.setLooping(true);
@@ -259,4 +261,11 @@
     public boolean isPlaying() {
         return mRingtone != null;
     }
+
+    private void completeHapticFuture(boolean ringtoneHasHaptics) {
+        if (mHapticsFuture != null) {
+            mHapticsFuture.complete(ringtoneHasHaptics);
+            mHapticsFuture = null;
+        }
+    }
 }
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index 91276de..6c9b1cc 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -280,25 +280,33 @@
                 }
                 if (mVolumeShaperConfig == null) {
                     float silencePoint = (float) (RAMPING_RINGER_VIBRATION_DURATION)
-                        / (float) (RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION);
+                            / (float) (RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION);
                     mVolumeShaperConfig = new VolumeShaper.Configuration.Builder()
-                        .setDuration(RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION)
-                        .setCurve(new float[] {0.f, silencePoint + EPSILON /*keep monotonicity*/,
-                            1.f}, new float[] {0.f, 0.f, 1.f})
-                        .setInterpolatorType(VolumeShaper.Configuration.INTERPOLATOR_TYPE_LINEAR)
-                        .build();
+                            .setDuration(
+                                    RAMPING_RINGER_VIBRATION_DURATION + RAMPING_RINGER_DURATION)
+                            .setCurve(new float[]{0.f, silencePoint + EPSILON /*keep monotonicity*/,
+                                    1.f}, new float[]{0.f, 0.f, 1.f})
+                            .setInterpolatorType(
+                                    VolumeShaper.Configuration.INTERPOLATOR_TYPE_LINEAR)
+                            .build();
                 }
                 hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall,
-                        mVolumeShaperConfig, isVibratorEnabled);
+                        mVolumeShaperConfig, attributes.isRingerAudible(), isVibratorEnabled);
             } else {
                 // Ramping ringtone is not enabled.
                 hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall, null,
-                        isVibratorEnabled);
+                        attributes.isRingerAudible(), isVibratorEnabled);
                 effect = getVibrationEffectForCall(mRingtoneFactory, foregroundCall);
             }
         } else {
             Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING, "Inaudible: "
                     + attributes.getInaudibleReason());
+            if (isVibratorEnabled && mIsHapticPlaybackSupportedByDevice) {
+                // Attempt to run the attentional haptic ringtone first and fallback to the default
+                // vibration effect if hapticFuture is completed with false.
+                hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall, null,
+                        attributes.isRingerAudible(), isVibratorEnabled);
+            }
             effect = mDefaultVibrationEffect;
         }
 
diff --git a/src/com/android/server/telecom/RingtoneFactory.java b/src/com/android/server/telecom/RingtoneFactory.java
index 6a121f7..b1846fe 100644
--- a/src/com/android/server/telecom/RingtoneFactory.java
+++ b/src/com/android/server/telecom/RingtoneFactory.java
@@ -109,6 +109,27 @@
                 Log.e(this, npe, "getRingtone: NPE while getting ringtone.");
             }
         }
+        return setRingtoneAudioAttributes(ringtone);
+    }
+
+    public Ringtone getRingtone(Call incomingCall) {
+        return getRingtone(incomingCall, null);
+    }
+
+    /** Returns a ringtone to be used when ringer is not audible for the incoming call. */
+    @Nullable
+    public Ringtone getHapticOnlyRingtone() {
+        Uri ringtoneUri = Uri.parse("file://" + mContext.getString(
+                com.android.internal.R.string.config_defaultRingtoneVibrationSound));
+        Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri, null);
+        if (ringtone != null) {
+            // Make sure the sound is muted.
+            ringtone.setVolume(0);
+        }
+        return setRingtoneAudioAttributes(ringtone);
+    }
+
+    private Ringtone setRingtoneAudioAttributes(Ringtone ringtone) {
         if (ringtone != null) {
             ringtone.setAudioAttributes(new AudioAttributes.Builder()
                     .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
@@ -118,10 +139,6 @@
         return ringtone;
     }
 
-    public Ringtone getRingtone(Call incomingCall) {
-        return getRingtone(incomingCall, null);
-    }
-
     private Context getWorkProfileContextForUser(UserHandle userHandle) {
         // UserManager.getEnabledProfiles returns the enabled profiles along with the user's handle
         // itself (so we must filter out the user).
diff --git a/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java b/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
index 4a308e0..0c30a16 100644
--- a/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
+++ b/src/com/android/server/telecom/callfiltering/CallScreeningServiceFilter.java
@@ -313,11 +313,15 @@
 
     private void bindCallScreeningService(
             CompletableFuture<CallFilteringResult> resultFuture) {
-        mConnection = new CallScreeningServiceConnection(resultFuture);
+        CallScreeningServiceConnection connection = new CallScreeningServiceConnection(
+                resultFuture);
         if (!CallScreeningServiceHelper.bindCallScreeningService(mContext,
-                mCallsManager.getCurrentUserHandle(), mPackageName, mConnection)) {
+                mCallsManager.getCurrentUserHandle(), mPackageName, connection)) {
             Log.i(this, "Call screening service binding failed.");
             resultFuture.complete(mPriorStageResult);
+            mConnection = null;
+        } else {
+            mConnection = connection;
         }
     }
 
diff --git a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
index 68caf67..9ff9986 100644
--- a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
@@ -62,6 +62,7 @@
 import org.mockito.Mock;
 
 import java.util.Collections;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.TimeUnit;
 
@@ -229,12 +230,30 @@
         CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, PKG_NAME,
                 CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
                 mAppLabelProxy, mParcelableCallUtilsConverter);
-        filter.startFilterLookup(inputResult);
+        CompletableFuture<CallFilteringResult> result = filter.startFilterLookup(inputResult)
+                .toCompletableFuture();
+
+        assertEquals(result.isDone(), false);
+
         filter.unbindCallScreeningService();
     }
 
     @SmallTest
     @Test
+    public void testBindingFailed() {
+        // Use an empty package name here, which fails in the bindCallScreeningService.
+        CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, "",
+                CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
+                mAppLabelProxy, mParcelableCallUtilsConverter);
+
+        CompletableFuture<CallFilteringResult> result = filter.startFilterLookup(inputResult)
+                .toCompletableFuture();
+
+        assertEquals(result.isDone(), true);
+    }
+
+    @SmallTest
+    @Test
     public void testAllowCall() throws Exception {
         CallScreeningServiceFilter filter = new CallScreeningServiceFilter(mCall, PKG_NAME,
                 CallScreeningServiceFilter.PACKAGE_TYPE_CARRIER, mContext, mCallsManager,
diff --git a/tests/src/com/android/server/telecom/tests/RingerTest.java b/tests/src/com/android/server/telecom/tests/RingerTest.java
index 0e93481..00456e2 100644
--- a/tests/src/com/android/server/telecom/tests/RingerTest.java
+++ b/tests/src/com/android/server/telecom/tests/RingerTest.java
@@ -149,7 +149,8 @@
         when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true);
         when(mockRingtoneFactory.hasHapticChannels(any(Ringtone.class))).thenReturn(false);
         when(mockRingtonePlayer.play(any(RingtoneFactory.class), any(Call.class),
-                nullable(VolumeShaper.Configuration.class), anyBoolean())).thenReturn(mFuture);
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean()))
+                .thenReturn(mFuture);
         mRingerUnderTest = new Ringer(mockPlayerFactory, mContext, mockSystemSettingsUtil,
                 mockRingtonePlayer, mockRingtoneFactory, mockVibrator, spyVibrationEffectProxy,
                 mockInCallController);
@@ -174,7 +175,7 @@
         assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
         verify(mockTonePlayer, never()).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                eq(null), eq(false));
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -192,7 +193,7 @@
         assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
         verify(mockTonePlayer, never()).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -208,7 +209,7 @@
         mRingCompletionFuture.get();
         verify(mockTonePlayer, never()).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -225,7 +226,7 @@
         mRingCompletionFuture.get();
         verify(mockTonePlayer, never()).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -241,7 +242,7 @@
         assertTrue(mRingerUnderTest.startRinging(mockCall2, true));
         verify(mockTonePlayer, never()).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -260,7 +261,7 @@
         assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
         verify(mockTonePlayer).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -276,8 +277,8 @@
         assertTrue(mRingerUnderTest.startRinging(mockCall2, false));
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
-        verify(mockRingtonePlayer).play(
-                any(RingtoneFactory.class), any(Call.class), isNull(), eq(true));
+        verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+                eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
         verify(mockVibrator, never()).vibrate(any(VibrationEffect.class),
                 any(AudioAttributes.class));
     }
@@ -293,8 +294,10 @@
         assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
-        verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+        // Try to play a silent haptics ringtone
+        verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+                eq(false) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+        // Play default vibration when future completes with no audio coupled haptics
         verify(mockVibrator).vibrate(eq(mRingerUnderTest.mDefaultVibrationEffect),
                 any(AudioAttributes.class));
     }
@@ -305,21 +308,44 @@
         mRingerUnderTest.startCallWaiting(mockCall1);
         Ringtone mockRingtone = mock(Ringtone.class);
         when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
-        when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
         when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
         mFuture.complete(false); // not using audio coupled haptics
         enableVibrationWhenRinging();
         assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
-        verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+        // Try to play a silent haptics ringtone
+        verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+                eq(false) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+        // Play default vibration when future completes with no audio coupled haptics
         verify(mockVibrator).vibrate(eq(mRingerUnderTest.mDefaultVibrationEffect),
                 any(AudioAttributes.class));
     }
 
     @SmallTest
     @Test
+    public void testAudioCoupledHapticsForSilentRingtone() throws Exception {
+        mRingerUnderTest.startCallWaiting(mockCall1);
+        Ringtone mockRingtone = mock(Ringtone.class);
+        when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
+        when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
+        mFuture.complete(true); // using audio coupled haptics
+        enableVibrationWhenRinging();
+        assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
+        mRingCompletionFuture.get();
+        verify(mockTonePlayer).stopTone();
+        // Try to play a silent haptics ringtone
+        verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), isNull(),
+                eq(false) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+        // Skip vibration for audio coupled haptics
+        verify(mockVibrator, never()).vibrate(any(VibrationEffect.class),
+                any(AudioAttributes.class));
+    }
+
+    @SmallTest
+    @Test
     public void testStopRingingBeforeHapticsLookupComplete() throws Exception {
         enableVibrationWhenRinging();
         Ringtone mockRingtone = mock(Ringtone.class);
@@ -329,7 +355,7 @@
         mRingerUnderTest.startRinging(mockCall1, false);
         // Make sure we haven't started the vibrator yet, but have started ringing.
         verify(mockRingtonePlayer).play(nullable(RingtoneFactory.class), nullable(Call.class),
-                nullable(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never()).vibrate(nullable(VibrationEffect.class),
                 nullable(AudioAttributes.class));
         // Simulate something stopping the ringer
@@ -357,7 +383,7 @@
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
         verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), eq(null),
-                eq(true));
+                eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
         verify(mockVibrator).vibrate(eq(spyVibrationEffectProxy.get(FAKE_RINGTONE_URI, mContext)),
                 any(AudioAttributes.class));
     }
@@ -373,7 +399,7 @@
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
         verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), eq(null),
-                eq(false));
+                eq(true) /* isRingerAudible */, eq(false) /* isVibrationEnabled */);
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -391,7 +417,7 @@
         verify(mockTonePlayer).stopTone();
         verify(mockRingtonePlayer).play(
             any(RingtoneFactory.class), any(Call.class), any(VolumeShaper.Configuration.class),
-                eq(true));
+                eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
     }
 
     @SmallTest
@@ -408,7 +434,7 @@
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }
@@ -426,7 +452,7 @@
         mRingCompletionFuture.get();
         verify(mockTonePlayer).stopTone();
         verify(mockRingtonePlayer, never()).play(any(RingtoneFactory.class), any(Call.class),
-                any(VolumeShaper.Configuration.class), anyBoolean());
+                nullable(VolumeShaper.Configuration.class), anyBoolean(), anyBoolean());
         verify(mockVibrator, never())
                 .vibrate(any(VibrationEffect.class), any(AudioAttributes.class));
     }