Fix / android 7 unlock screen on incoming call

This commit is contained in:
Valere 2020-06-20 09:41:09 +02:00
parent 76bcf9dcf7
commit 64a67b57b8

View File

@ -215,8 +215,8 @@ class VectorCallActivity : VectorBaseActivity(), CallControlsView.InteractionLis
pipRenderer.release() pipRenderer.release()
fullscreenRenderer.release() fullscreenRenderer.release()
} }
super.onDestroy()
turnScreenOffAndKeyguardOn() turnScreenOffAndKeyguardOn()
super.onDestroy()
} }
private fun renderState(state: VectorCallViewState) { private fun renderState(state: VectorCallViewState) {
@ -450,9 +450,11 @@ class VectorCallActivity : VectorBaseActivity(), CallControlsView.InteractionLis
setShowWhenLocked(true) setShowWhenLocked(true)
setTurnScreenOn(true) setTurnScreenOn(true)
} else { } else {
@Suppress("DEPRECATION")
window.addFlags( window.addFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
) )
} }
@ -464,13 +466,15 @@ class VectorCallActivity : VectorBaseActivity(), CallControlsView.InteractionLis
} }
private fun turnScreenOffAndKeyguardOn() { private fun turnScreenOffAndKeyguardOn() {
Timber.v("## VOIP turnScreenOnAndKeyguardOn")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(false) setShowWhenLocked(false)
setTurnScreenOn(false) setTurnScreenOn(false)
} else { } else {
@Suppress("DEPRECATION")
window.clearFlags( window.clearFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
) )
} }
} }