diff options
author | uabdullah <uabdullah@google.com> | 2018-01-25 15:43:05 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-25 17:32:57 -0800 |
commit | 8392f80d96bf8e5b070429e53c674522a30f796c (patch) | |
tree | 3c0b3dec7ce07368586f0b8944d47c2eae6ce9ee /java | |
parent | 328494b2e757dce8e385879303a1c2eb0364c635 (diff) |
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
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java | 14 |
1 files changed, 14 insertions, 0 deletions
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. } }; |