diff options
Diffstat (limited to 'src/com/android/dialer/voicemail')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 4ccbe102d..5b4478f53 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -127,8 +127,10 @@ public class VoicemailPlaybackPresenter private Uri mVoicemailUri; private int mPosition; - private boolean mIsPrepared; private boolean mIsPlaying; + // MediaPlayer crashes on some method calls if not prepared but does not have a method which + // exposes its prepared state. Store this locally, so we can check and prevent crashes. + private boolean mIsPrepared; private boolean mShouldResumePlaybackAfterSeeking; @@ -448,6 +450,10 @@ public class VoicemailPlaybackPresenter @Override public void onAudioFocusChange(int focusChange) { + if (!mIsPrepared) { + return; + } + boolean lostFocus = focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS; if (mMediaPlayer.isPlaying() && lostFocus) { @@ -462,6 +468,10 @@ public class VoicemailPlaybackPresenter * playing. */ public void resumePlayback() { + if (!mIsPrepared) { + return; + } + mIsPlaying = true; if (!mMediaPlayer.isPlaying()) { @@ -495,6 +505,10 @@ public class VoicemailPlaybackPresenter * Pauses voicemail playback at the current position. Null-op if already paused. */ public void pausePlayback() { + if (!mIsPrepared) { + return; + } + mPosition = mMediaPlayer.getCurrentPosition(); mIsPlaying = false; @@ -527,8 +541,8 @@ public class VoicemailPlaybackPresenter } private void enableProximitySensor() { - if (mProximityWakeLock == null || isSpeakerphoneOn() || - !mIsPrepared || !mMediaPlayer.isPlaying()) { + if (mProximityWakeLock == null || isSpeakerphoneOn() || !mIsPrepared + || !mMediaPlayer.isPlaying()) { return; } |