diff options
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index e4f2d4756..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 */); } @@ -582,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(); + } } /** @@ -604,6 +610,8 @@ public class VoicemailPlaybackPresenter mView.onPlaybackStopped(); mAudioManager.abandonAudioFocus(this); + + mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); disableProximitySensor(true /* waitForFarState */); } @@ -625,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; } @@ -639,7 +644,6 @@ public class VoicemailPlaybackPresenter } else { Log.i(TAG, "Proximity wake lock already acquired"); } - */ } private void disableProximitySensor(boolean waitForFarState) { @@ -657,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); } } |