diff options
Diffstat (limited to 'src/com/android/dialer/voicemail')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 4cd8c4d13..d0fe2e44b 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -33,6 +33,7 @@ import android.os.PowerManager; import android.provider.VoicemailContract; import android.util.Log; import android.view.View; +import android.view.WindowManager.LayoutParams; import android.widget.SeekBar; import com.android.dialer.R; @@ -285,6 +286,7 @@ public class VoicemailPlaybackPresenter mMediaPlayer = null; } + mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); disableProximitySensor(false /* waitForFarState */); } @@ -337,6 +339,10 @@ public class VoicemailPlaybackPresenter } private boolean queryHasContent(Uri voicemailUri) { + if (voicemailUri == null) { + return false; + } + ContentResolver contentResolver = mContext.getContentResolver(); Cursor cursor = contentResolver.query( voicemailUri, HAS_CONTENT_PROJECTION, null, null, null); @@ -578,7 +584,11 @@ public class VoicemailPlaybackPresenter Log.d(TAG, "Resumed playback at " + mPosition + "."); mView.onPlaybackStarted(mDuration.get(), getScheduledExecutorServiceInstance()); - enableProximitySensor(); + if (isSpeakerphoneOn()) { + mActivity.getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + enableProximitySensor(); + } } /** @@ -600,6 +610,8 @@ public class VoicemailPlaybackPresenter mView.onPlaybackStopped(); mAudioManager.abandonAudioFocus(this); + + mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); disableProximitySensor(true /* waitForFarState */); } @@ -621,11 +633,8 @@ public class VoicemailPlaybackPresenter } private void enableProximitySensor() { - // Disable until proximity sensor behavior in onPause is fixed: b/21932251. - - /* if (mProximityWakeLock == null || isSpeakerphoneOn() || !mIsPrepared - || !mMediaPlayer.isPlaying()) { + || mMediaPlayer == null || !mMediaPlayer.isPlaying()) { return; } @@ -635,7 +644,6 @@ public class VoicemailPlaybackPresenter } else { Log.i(TAG, "Proximity wake lock already acquired"); } - */ } private void disableProximitySensor(boolean waitForFarState) { @@ -653,10 +661,15 @@ public class VoicemailPlaybackPresenter public void setSpeakerphoneOn(boolean on) { mAudioManager.setSpeakerphoneOn(on); + if (on) { disableProximitySensor(false /* waitForFarState */); + if (mIsPrepared && mMediaPlayer != null && mMediaPlayer.isPlaying()) { + mActivity.getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); + } } else { enableProximitySensor(); + mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); } } |