From 99e0aa4d3be26001182634f15327da5b0749c74c Mon Sep 17 00:00:00 2001 From: uabdullah Date: Wed, 28 Feb 2018 15:03:28 -0800 Subject: Never start playing voicemails in the NUI VM tab from the speaker All voicemails played from the VM tab should always be played from the non-speaker mode. Bug: 71500892 Test: N/A PiperOrigin-RevId: 187388964 Change-Id: I3f6a5887784b0192074157cfd8a91727d124ed06 --- .../android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'java') diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java index 519a0dfbd..efa1060ed 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java @@ -17,6 +17,7 @@ package com.android.dialer.voicemail.listui; import android.content.Context; +import android.media.AudioManager; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; import android.media.MediaPlayer.OnErrorListener; @@ -63,6 +64,7 @@ public class NewVoicemailMediaPlayer { () -> { try { mediaPlayer.setDataSource(context, uri); + setAudioManagerToNonSpeakerMode(context); } catch (IOException e) { LogUtil.i( "NewVoicemailMediaPlayer", @@ -86,6 +88,13 @@ public class NewVoicemailMediaPlayer { } } + /** We should never start playing voicemails from the speaker mode */ + private void setAudioManagerToNonSpeakerMode(Context context) { + AudioManager audioManager = context.getSystemService(AudioManager.class); + audioManager.setMode(AudioManager.STREAM_MUSIC); + audioManager.setSpeakerphoneOn(false); + } + private void verifyListenersNotNull() { Assert.isNotNull( newVoicemailMediaPlayerOnErrorListener, -- cgit v1.2.3