diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-11 11:33:19 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-06-11 11:33:19 -0700 |
commit | 00a68273768a9c7caa745af26d5861cc75ae0118 (patch) | |
tree | 37883eb083128365bda1bccd8a5805e89faca287 /src/com | |
parent | 44919b041bd28792e18cfa65ea6868da3d8b9f52 (diff) |
Paranoid mIsPrepared checks.
Returning early if media player is not prepared in all these cases,
just in case.
Bug: 21764908
Change-Id: Ieca0e9fd1c323ea5150464683600542fefb318b3
Diffstat (limited to 'src/com')
-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 a0e48546f..94c61a63a 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; @@ -444,6 +446,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) { @@ -458,6 +464,10 @@ public class VoicemailPlaybackPresenter * playing. */ public void resumePlayback() { + if (!mIsPrepared) { + return; + } + mIsPlaying = true; if (!mMediaPlayer.isPlaying()) { @@ -491,6 +501,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; @@ -523,8 +537,8 @@ public class VoicemailPlaybackPresenter } private void enableProximitySensor() { - if (mProximityWakeLock == null || isSpeakerphoneOn() || - !mIsPrepared || !mMediaPlayer.isPlaying()) { + if (mProximityWakeLock == null || isSpeakerphoneOn() || !mIsPrepared + || !mMediaPlayer.isPlaying()) { return; } |