From 8392f80d96bf8e5b070429e53c674522a30f796c Mon Sep 17 00:00:00 2001 From: uabdullah Date: Thu, 25 Jan 2018 15:43:05 -0800 Subject: Route speaker via speaker and headset when tapping speaker button in NUI VM Clicking the speaker button in the NUI VM for a voicemail entry alternates playing the audio via the speaker and headset. This CL does not change the state of the speaker icon, that will be done in a follow up CL (cl/183175378) and the todo for that has been added. Bug: 69858226 Test: N/A PiperOrigin-RevId: 183304029 Change-Id: I3a55e62ab8d1203f659a45db9534fd69deda122f --- .../voicemail/listui/NewVoicemailMediaPlayerView.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'java/com/android/dialer/voicemail') diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java index 66a6fea7c..37a8dc8cd 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java @@ -21,6 +21,7 @@ import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.database.Cursor; +import android.media.AudioManager; import android.net.Uri; import android.provider.VoicemailContract; import android.provider.VoicemailContract.Voicemails; @@ -452,6 +453,19 @@ public final class NewVoicemailMediaPlayerView extends LinearLayout { "NewVoicemailMediaPlayer.speakerButtonListener", "speaker request for voicemailUri: %s", voicemailUri.toString()); + AudioManager audioManager = + (AudioManager) getContext().getSystemService(AudioManager.class); + audioManager.setMode(AudioManager.STREAM_MUSIC); + if (audioManager.isSpeakerphoneOn()) { + LogUtil.i( + "NewVoicemailMediaPlayer.phoneButtonListener", "speaker was on, turning it off"); + audioManager.setSpeakerphoneOn(false); + } else { + LogUtil.i( + "NewVoicemailMediaPlayer.phoneButtonListener", "speaker was off, turning it on"); + audioManager.setSpeakerphoneOn(true); + } + // TODO(uabdullah): Handle colors of speaker icon when speaker is on and off. } }; -- cgit v1.2.3