diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-24 14:04:55 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-06-24 14:16:04 -0700 |
commit | 9301ca9766c828a03bad858a17cccfcb16611481 (patch) | |
tree | 2e61237a9f9722ba1b078a5dc69afda793b20c8d /src/com/android/dialer | |
parent | 0feab0229c1c70248ca411d0e95f79aa2ac70c00 (diff) |
Enable proximity sensor onPause.
+ When using speakerphone, add flag to keep the screen on.
Bug: 22047261
Change-Id: I4e28ab526218b4cc1f53f2ec98c4749f24ac95af
Diffstat (limited to 'src/com/android/dialer')
-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 4cd8c4d13..41a471d52 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 */); } @@ -578,7 +580,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 +606,8 @@ public class VoicemailPlaybackPresenter mView.onPlaybackStopped(); mAudioManager.abandonAudioFocus(this); + + mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); disableProximitySensor(true /* waitForFarState */); } @@ -621,11 +629,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 +640,6 @@ public class VoicemailPlaybackPresenter } else { Log.i(TAG, "Proximity wake lock already acquired"); } - */ } private void disableProximitySensor(boolean waitForFarState) { @@ -653,10 +657,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); } } |