Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99e0aa4d authored by uabdullah's avatar uabdullah Committed by Copybara-Service
Browse files

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
parent e309c166
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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,