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

Commit a62438c9 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Use the correct stream for playback.

We were using the STREAM_MUSIC and playing the using setMode to use the
IN_CALL mode.

Instead, use the STREAM_VOICE_CALL: this works basically the same way,
but does not cause issues when the stream is stopped.

Bug: 5240848
Change-Id: I60595b4da7abe01adb1908ee24a4ca9801a1fa85
parent d340308d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -395,7 +395,6 @@ public class VoicemailPlaybackFragment extends Fragment {

        @Override
        public void setSpeakerPhoneOn(boolean on) {
            getAudioManager().setMode(AudioManager.MODE_IN_CALL);
            getAudioManager().setSpeakerphoneOn(on);
            if (on) {
                mPlaybackSpeakerphone.setImageResource(R.drawable.ic_sound_holo_dark);
@@ -403,6 +402,14 @@ public class VoicemailPlaybackFragment extends Fragment {
                mPlaybackSpeakerphone.setImageResource(R.drawable.ic_sound_holo_dark);
            }
        }

        @Override
        public void setVolumeControlStream(int streamType) {
            Activity activity = mActivityReference.get();
            if (activity != null) {
                activity.setVolumeControlStream(streamType);
            }
        }
    }

    /**
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.google.common.base.Preconditions;

import android.content.Context;
import android.database.ContentObserver;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.AsyncTask;
@@ -60,6 +61,9 @@ import javax.annotation.concurrent.ThreadSafe;
@NotThreadSafe
@VisibleForTesting
public class VoicemailPlaybackPresenter {
    /** The stream used to playback voicemail. */
    private static final int PLAYBACK_STREAM = AudioManager.STREAM_VOICE_CALL;

    /** Contract describing the behaviour we need from the ui we are controlling. */
    public interface PlaybackView {
        Context getDataSourceContext();
@@ -89,6 +93,7 @@ public class VoicemailPlaybackPresenter {
        void unregisterContentObserver(ContentObserver observer);
        void enableProximitySensor();
        void disableProximitySensor();
        void setVolumeControlStream(int streamType);
    }

    /** The enumeration of {@link AsyncTask} objects we use in this class. */
@@ -179,6 +184,7 @@ public class VoicemailPlaybackPresenter {
    }

    public void onCreate(Bundle bundle) {
        mView.setVolumeControlStream(PLAYBACK_STREAM);
        checkThatWeHaveContent();
    }

@@ -304,6 +310,7 @@ public class VoicemailPlaybackPresenter {
                        try {
                            mPlayer.reset();
                            mPlayer.setDataSource(mView.getDataSourceContext(), mVoicemailUri);
                            mPlayer.setAudioStreamType(PLAYBACK_STREAM);
                            mPlayer.prepare();
                            return null;
                        } catch (IOException e) {
@@ -428,6 +435,7 @@ public class VoicemailPlaybackPresenter {
        try {
            mPlayer.reset();
            mPlayer.setDataSource(mView.getDataSourceContext(), mVoicemailUri);
            mPlayer.setAudioStreamType(PLAYBACK_STREAM);
            mPlayer.prepare();
            mDuration.set(mPlayer.getDuration());
            int startPosition = constrain(clipPositionInMillis, 0, mDuration.get());