From b20213ee0e647efbc75d4546b837104b5657dff5 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 1 Jun 2015 14:38:59 -0700 Subject: Continue voicemail playback during rotation. Don't pause playback or release the media player during onPause or onDestroy. Bug: 21235334 Change-Id: I0eccd4e38e89c3416817d80aa25cc3bb529a9d6b --- src/com/android/dialer/CallDetailActivity.java | 4 ++-- .../dialer/voicemail/VoicemailPlaybackPresenter.java | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 7fa3750d2..ce29049d3 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -272,7 +272,7 @@ public class CallDetailActivity extends Activity { @Override public void onPause() { if (mVoicemailPlaybackPresenter != null) { - mVoicemailPlaybackPresenter.onPause(); + mVoicemailPlaybackPresenter.onPause(isFinishing()); } super.onPause(); } @@ -280,7 +280,7 @@ public class CallDetailActivity extends Activity { @Override public void onDestroy() { if (mVoicemailPlaybackPresenter != null) { - mVoicemailPlaybackPresenter.onDestroy(); + mVoicemailPlaybackPresenter.onDestroy(isFinishing()); } super.onDestroy(); } diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 1ee376582..e8b04602d 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -170,24 +170,28 @@ public class VoicemailPlaybackPresenter PlaybackView view, Uri voicemailUri, boolean startPlayingImmediately) { mView = view; mVoicemailUri = voicemailUri; - setPosition(0, startPlayingImmediately); mView.setPresenter(this); - mIsPrepared = false; + if (!mMediaPlayer.isPlaying()) { + setPosition(0, startPlayingImmediately); + mIsPrepared = false; + } checkForContent(); } - public void onPause() { - if (mMediaPlayer.isPlaying()) { + public void onPause(boolean isFinishing) { + // Do not pause for orientation changes. + if (mMediaPlayer.isPlaying() && isFinishing) { pausePlayback(mMediaPlayer.getCurrentPosition(), mIsPlaying); } disableProximitySensor(false /* waitForFarState */); } - public void onDestroy() { - if (mIsPrepared) { + public void onDestroy(boolean isFinishing) { + // Do not release for orientation changes. + if (mIsPrepared && isFinishing) { mMediaPlayer.release(); mIsPrepared = false; } -- cgit v1.2.3