diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-12 18:30:42 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-12 18:30:43 +0000 |
commit | 7d3f9ec02c696f761589c61101c07a175bca8321 (patch) | |
tree | 68875fed0261ac600373e9bafcec07235760f6e9 /src/com | |
parent | 42d8f97b49dd90c11077a680d40088d2505e1129 (diff) | |
parent | 00a68273768a9c7caa745af26d5861cc75ae0118 (diff) |
Merge "Paranoid mIsPrepared checks." into mnc-dev
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 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; } |