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

Commit 4e005b17 authored by Flavio Lerda's avatar Flavio Lerda Committed by Android (Google) Code Review
Browse files

Merge "Use the correct stream for playback."

parents 71886c54 a62438c9
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());