libsdl-org / SDL

Simple Directmedia Layer

Home Page:https://libsdl.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android bug: I can rotate screen and app rotates even when I locked screen rotation in system settings

dustdfg opened this issue · comments

Hello!

I can rotate screen and game rotates even when I locked screen rotation in system settings.

Test Devices:

  1. Xiaomi Mi 8 Lite (android 10)
  2. Xiaomi Redmi 8 (android 10)
  3. Samsung Galaxy A02s (android 11)

Tested Versions:

  1. 2.0.22
  2. 2.24.0
ScreenRecording_20220821_155851.mp4

This sounds like an OS-side bug.

This sounds like an OS-side bug.

Yes, but other apps has normal behavior. It is relevant to SDL apps but not to other

would it make sense to apply the fix used here?

exelix11/SysDVR@81ffb43

this is from one of the issues that mentions this one

The proper way to fix this is to use ActivityInfo.SCREEN_ORIENTATION_FULL_USER instead of ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR. The former will respect user's orientation lock in their navigation bar. This also can be applied to landscape or portrait-only orientation by using ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE and ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT respectively. However be aware that the last 2 is Android 4.3+ and this may be need to be addressed in separate issue.

I can write patches to fix the first case (changing ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR to ActivityInfo.SCREEN_ORIENTATION_FULL_USER). However, simply changing them is considered behavior change. So I'd like to know @slouken thoughts on addressing this.

TL;DR:

  • SDL uses ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR for resizable window or when it allows any orientation.
  • ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR does not respect user orientation lock in their status bar.
  • ActivityInfo.SCREEN_ORIENTATION_FULL_USER is the equivalent whilst respecting user orientation lock.
  • However, changing this can be considered behavior change.

Yes, we probably want to use FULL_USER for SDL 3.0, and possibly also for SDL 2.0

I believe this should be closed as completed as it's been fixed in 2.30.4.