diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-25 17:33:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-25 17:33:55 +0000 |
commit | ef93faed606696c610d9428405b03eb17a890069 (patch) | |
tree | 5384ee92055ad25b7126f3d983fca242a6447bfd /src/com/android | |
parent | 9f76afa1d57d6bba39da713fb349d5fb0eb8d590 (diff) | |
parent | 9301ca9766c828a03bad858a17cccfcb16611481 (diff) |
Merge "Enable proximity sensor onPause." into mnc-dev
Diffstat (limited to 'src/com/android')
-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); } } |