Loading src/com/android/server/telecom/Ringer.java +2 −10 Original line number Diff line number Diff line Loading @@ -415,17 +415,9 @@ public class Ringer { isVibratorEnabled, mIsHapticPlaybackSupportedByDevice); } // Defer ringtone creation to the async player thread. Supplier<Pair<Uri, Ringtone>> ringtoneInfoSupplier; Supplier<Pair<Uri, Ringtone>> ringtoneInfoSupplier = null; final boolean finalHapticChannelsMuted = hapticChannelsMuted; if (isHapticOnly) { if (hapticChannelsMuted) { Log.i(this, "want haptic only ringtone but haptics are muted, skip ringtone play"); ringtoneInfoSupplier = null; } else { ringtoneInfoSupplier = mRingtoneFactory::getHapticOnlyRingtone; } } else { if (!isHapticOnly) { ringtoneInfoSupplier = () -> mRingtoneFactory.getRingtone( foregroundCall, mVolumeShaperConfig, finalHapticChannelsMuted); } Loading src/com/android/server/telecom/RingtoneFactory.java +0 −18 Original line number Diff line number Diff line Loading @@ -127,24 +127,6 @@ public class RingtoneFactory { .build(); } /** Returns a ringtone to be used when ringer is not audible for the incoming call. */ @Nullable public Pair<Uri, Ringtone> getHapticOnlyRingtone() { // Initializing ringtones on the main thread can deadlock ThreadUtil.checkNotOnMainThread(); Uri ringtoneUri = Uri.parse("file://" + mContext.getString( com.android.internal.R.string.config_defaultRingtoneVibrationSound)); AudioAttributes audioAttrs = getDefaultRingtoneAudioAttributes( /* hapticChannelsMuted */ false); Ringtone ringtone = RingtoneManager.getRingtone( mContext, ringtoneUri, /* volumeShaperConfig */ null, audioAttrs); if (ringtone != null) { // Make sure the sound is muted. ringtone.setVolume(0); } return new Pair(ringtoneUri, ringtone); } private Context getWorkProfileContextForUser(UserHandle userHandle) { // UserManager.getUserProfiles returns the enabled profiles along with the context user's // handle itself (so we must filter out the user). Loading tests/src/com/android/server/telecom/tests/RingerTest.java +0 −31 Original line number Diff line number Diff line Loading @@ -475,10 +475,6 @@ public class RingerTest extends TelecomTestCase { // Ensure no audible ringtone is played: assertFalse(startRingingAndWaitForAsync(mockCall2, false)); verify(mockTonePlayer).stopTone(); // Ensure a silent haptics only ringtone is played: verify(mockRingtoneFactory, atLeastOnce()).getHapticOnlyRingtone(); verifyNoMoreInteractions(mockRingtoneFactory); verify(mockRingtone).play(); // Ensure a vibration plays: verify(mockVibrator).vibrate(any(VibrationEffect.class), any(VibrationAttributes.class)); Loading Loading @@ -523,10 +519,6 @@ public class RingerTest extends TelecomTestCase { enableVibrationWhenRinging(); assertFalse(startRingingAndWaitForAsync(mockCall2, false)); verify(mockTonePlayer).stopTone(); // Try to play a silent haptics ringtone verify(mockRingtoneFactory, atLeastOnce()).getHapticOnlyRingtone(); verifyNoMoreInteractions(mockRingtoneFactory); verify(mockRingtone).play(); // Play default vibration when future completes with no audio coupled haptics verify(mockVibrator).vibrate(eq(mRingerUnderTest.mDefaultVibrationEffect), Loading @@ -551,28 +543,6 @@ public class RingerTest extends TelecomTestCase { any(VibrationAttributes.class)); } @SmallTest @Test public void testAudioCoupledHapticsForSilentRingtone() throws Exception { Ringtone mockRingtone = ensureRingtoneMocked(); mRingerUnderTest.startCallWaiting(mockCall1); when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0); setIsUsingHaptics(mockRingtone, true); enableVibrationWhenRinging(); assertFalse(startRingingAndWaitForAsync(mockCall2, false)); verify(mockRingtoneFactory, atLeastOnce()).getHapticOnlyRingtone(); verifyNoMoreInteractions(mockRingtoneFactory); verify(mockTonePlayer).stopTone(); // Try to play a silent haptics ringtone verify(mockRingtone).play(); // Skip vibration for audio coupled haptics verify(mockVibrator, never()).vibrate(any(VibrationEffect.class), any(VibrationAttributes.class)); } @SmallTest @Test public void testCustomVibrationForRingtone() throws Exception { Loading Loading @@ -886,7 +856,6 @@ public class RingerTest extends TelecomTestCase { when(mockRingtoneFactory.getRingtone( any(Call.class), nullable(VolumeShaper.Configuration.class), anyBoolean())) .thenReturn(ringtoneInfo); when(mockRingtoneFactory.getHapticOnlyRingtone()).thenReturn(ringtoneInfo); return mockRingtone; } Loading Loading
src/com/android/server/telecom/Ringer.java +2 −10 Original line number Diff line number Diff line Loading @@ -415,17 +415,9 @@ public class Ringer { isVibratorEnabled, mIsHapticPlaybackSupportedByDevice); } // Defer ringtone creation to the async player thread. Supplier<Pair<Uri, Ringtone>> ringtoneInfoSupplier; Supplier<Pair<Uri, Ringtone>> ringtoneInfoSupplier = null; final boolean finalHapticChannelsMuted = hapticChannelsMuted; if (isHapticOnly) { if (hapticChannelsMuted) { Log.i(this, "want haptic only ringtone but haptics are muted, skip ringtone play"); ringtoneInfoSupplier = null; } else { ringtoneInfoSupplier = mRingtoneFactory::getHapticOnlyRingtone; } } else { if (!isHapticOnly) { ringtoneInfoSupplier = () -> mRingtoneFactory.getRingtone( foregroundCall, mVolumeShaperConfig, finalHapticChannelsMuted); } Loading
src/com/android/server/telecom/RingtoneFactory.java +0 −18 Original line number Diff line number Diff line Loading @@ -127,24 +127,6 @@ public class RingtoneFactory { .build(); } /** Returns a ringtone to be used when ringer is not audible for the incoming call. */ @Nullable public Pair<Uri, Ringtone> getHapticOnlyRingtone() { // Initializing ringtones on the main thread can deadlock ThreadUtil.checkNotOnMainThread(); Uri ringtoneUri = Uri.parse("file://" + mContext.getString( com.android.internal.R.string.config_defaultRingtoneVibrationSound)); AudioAttributes audioAttrs = getDefaultRingtoneAudioAttributes( /* hapticChannelsMuted */ false); Ringtone ringtone = RingtoneManager.getRingtone( mContext, ringtoneUri, /* volumeShaperConfig */ null, audioAttrs); if (ringtone != null) { // Make sure the sound is muted. ringtone.setVolume(0); } return new Pair(ringtoneUri, ringtone); } private Context getWorkProfileContextForUser(UserHandle userHandle) { // UserManager.getUserProfiles returns the enabled profiles along with the context user's // handle itself (so we must filter out the user). Loading
tests/src/com/android/server/telecom/tests/RingerTest.java +0 −31 Original line number Diff line number Diff line Loading @@ -475,10 +475,6 @@ public class RingerTest extends TelecomTestCase { // Ensure no audible ringtone is played: assertFalse(startRingingAndWaitForAsync(mockCall2, false)); verify(mockTonePlayer).stopTone(); // Ensure a silent haptics only ringtone is played: verify(mockRingtoneFactory, atLeastOnce()).getHapticOnlyRingtone(); verifyNoMoreInteractions(mockRingtoneFactory); verify(mockRingtone).play(); // Ensure a vibration plays: verify(mockVibrator).vibrate(any(VibrationEffect.class), any(VibrationAttributes.class)); Loading Loading @@ -523,10 +519,6 @@ public class RingerTest extends TelecomTestCase { enableVibrationWhenRinging(); assertFalse(startRingingAndWaitForAsync(mockCall2, false)); verify(mockTonePlayer).stopTone(); // Try to play a silent haptics ringtone verify(mockRingtoneFactory, atLeastOnce()).getHapticOnlyRingtone(); verifyNoMoreInteractions(mockRingtoneFactory); verify(mockRingtone).play(); // Play default vibration when future completes with no audio coupled haptics verify(mockVibrator).vibrate(eq(mRingerUnderTest.mDefaultVibrationEffect), Loading @@ -551,28 +543,6 @@ public class RingerTest extends TelecomTestCase { any(VibrationAttributes.class)); } @SmallTest @Test public void testAudioCoupledHapticsForSilentRingtone() throws Exception { Ringtone mockRingtone = ensureRingtoneMocked(); mRingerUnderTest.startCallWaiting(mockCall1); when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0); setIsUsingHaptics(mockRingtone, true); enableVibrationWhenRinging(); assertFalse(startRingingAndWaitForAsync(mockCall2, false)); verify(mockRingtoneFactory, atLeastOnce()).getHapticOnlyRingtone(); verifyNoMoreInteractions(mockRingtoneFactory); verify(mockTonePlayer).stopTone(); // Try to play a silent haptics ringtone verify(mockRingtone).play(); // Skip vibration for audio coupled haptics verify(mockVibrator, never()).vibrate(any(VibrationEffect.class), any(VibrationAttributes.class)); } @SmallTest @Test public void testCustomVibrationForRingtone() throws Exception { Loading Loading @@ -886,7 +856,6 @@ public class RingerTest extends TelecomTestCase { when(mockRingtoneFactory.getRingtone( any(Call.class), nullable(VolumeShaper.Configuration.class), anyBoolean())) .thenReturn(ringtoneInfo); when(mockRingtoneFactory.getHapticOnlyRingtone()).thenReturn(ringtoneInfo); return mockRingtone; } Loading