Should fix screen not waked up on some devices
This commit is contained in:
parent
1a1bfee678
commit
e73e844070
6 changed files with 85 additions and 0 deletions
|
@ -23,6 +23,7 @@ import android.content.res.Configuration
|
|||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.MotionEvent
|
||||
import android.view.WindowManager
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
@ -46,6 +47,9 @@ class CallActivity : ProximitySensorActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
Compatibility.setShowWhenLocked(this, true)
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.call_activity)
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.annotation.TargetApi
|
|||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
@ -31,6 +32,7 @@ import org.linphone.R
|
|||
import org.linphone.activities.GenericActivity
|
||||
import org.linphone.activities.call.viewmodels.IncomingCallViewModel
|
||||
import org.linphone.activities.call.viewmodels.IncomingCallViewModelFactory
|
||||
import org.linphone.compatibility.Compatibility
|
||||
import org.linphone.core.Call
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallIncomingActivityBinding
|
||||
|
@ -44,6 +46,10 @@ class IncomingCallActivity : GenericActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
Compatibility.setShowWhenLocked(this, true)
|
||||
Compatibility.setTurnScreenOn(this, true)
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.call_incoming_activity)
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone.activities.call
|
|||
|
||||
import android.annotation.TargetApi
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
@ -43,6 +44,8 @@ class OutgoingCallActivity : ProximitySensorActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.call_outgoing_activity)
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.compatibility
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Activity
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
|
@ -28,6 +29,7 @@ import android.os.Environment
|
|||
import android.os.Vibrator
|
||||
import android.provider.MediaStore
|
||||
import android.provider.Settings
|
||||
import android.view.WindowManager
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Content
|
||||
import org.linphone.core.tools.Log
|
||||
|
@ -151,5 +153,21 @@ class Api21Compatibility {
|
|||
}
|
||||
return copyOk
|
||||
}
|
||||
|
||||
fun setShowWhenLocked(activity: Activity, enable: Boolean) {
|
||||
if (enable) {
|
||||
activity.window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
|
||||
} else {
|
||||
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
|
||||
}
|
||||
}
|
||||
|
||||
fun setTurnScreenOn(activity: Activity, enable: Boolean) {
|
||||
if (enable) {
|
||||
activity.window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
||||
} else {
|
||||
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.compatibility
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.app.*
|
||||
|
||||
@TargetApi(27)
|
||||
class Api27Compatibility {
|
||||
companion object {
|
||||
fun setShowWhenLocked(activity: Activity, enable: Boolean) {
|
||||
activity.setShowWhenLocked(enable)
|
||||
}
|
||||
|
||||
fun setTurnScreenOn(activity: Activity, enable: Boolean) {
|
||||
activity.setTurnScreenOn(enable)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,24 @@ class Compatibility {
|
|||
}
|
||||
}
|
||||
|
||||
/* UI */
|
||||
|
||||
fun setShowWhenLocked(activity: Activity, enable: Boolean) {
|
||||
if (Version.sdkStrictlyBelow(Version.API27_OREO_81)) {
|
||||
Api21Compatibility.setShowWhenLocked(activity, enable)
|
||||
} else {
|
||||
Api27Compatibility.setShowWhenLocked(activity, enable)
|
||||
}
|
||||
}
|
||||
|
||||
fun setTurnScreenOn(activity: Activity, enable: Boolean) {
|
||||
if (Version.sdkStrictlyBelow(Version.API27_OREO_81)) {
|
||||
Api21Compatibility.setTurnScreenOn(activity, enable)
|
||||
} else {
|
||||
Api27Compatibility.setTurnScreenOn(activity, enable)
|
||||
}
|
||||
}
|
||||
|
||||
/* Notifications */
|
||||
|
||||
fun createNotificationChannels(
|
||||
|
|
Loading…
Reference in a new issue