Prevent screen rotation while incoming call if screen is locked

This commit is contained in:
Sylvain Berfini 2020-09-21 11:40:55 +02:00
parent 58aca3eeb4
commit 0a3ef8e789
3 changed files with 11 additions and 2 deletions

View file

@ -92,6 +92,8 @@ LinphoneSdkBuildDir=/home/<username>/linphone-sdk/build/
If you encounter the `couldn't find "libc++_shared.so"` crash when the app starts, simply clean the project in Android Studio (under Build menu) and build again. If you encounter the `couldn't find "libc++_shared.so"` crash when the app starts, simply clean the project in Android Studio (under Build menu) and build again.
If during the build you have `DataBinderMapperImpl.java error: cannot find symbol`, try building again.
When submitting an issue, please attach the matching library logs. To enable them, go to Settings -> Advanced and toggle "Debug Mode". When submitting an issue, please attach the matching library logs. To enable them, go to Settings -> Advanced and toggle "Debug Mode".
Then restart the app, reproduce the issue and upload the logs using the "Upload logs" button on the About page. Then restart the app, reproduce the issue and upload the logs using the "Upload logs" button on the About page.

View file

@ -48,8 +48,10 @@ abstract class GenericActivity : AppCompatActivity() {
ensureCoreExists(applicationContext) ensureCoreExists(applicationContext)
hideSystemUI() hideSystemUI()
if (corePreferences.forcePortrait) { requestedOrientation = if (corePreferences.forcePortrait) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
} else {
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
} }
val nightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK val nightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK

View file

@ -23,6 +23,7 @@ import android.Manifest
import android.annotation.TargetApi import android.annotation.TargetApi
import android.app.KeyguardManager import android.app.KeyguardManager
import android.content.Context import android.content.Context
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
@ -84,6 +85,10 @@ class IncomingCallActivity : GenericActivity() {
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
val keyguardLocked = keyguardManager.isKeyguardLocked val keyguardLocked = keyguardManager.isKeyguardLocked
viewModel.screenLocked.value = keyguardLocked viewModel.screenLocked.value = keyguardLocked
if (keyguardLocked) {
// Forbid screen rotation to prevent keyguard to show up above incoming call view
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
}
binding.buttons.setViewModel(viewModel) binding.buttons.setViewModel(viewModel)