SDL icon indicating copy to clipboard operation
SDL copied to clipboard

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

Open dustdfg opened this issue 2 years ago • 4 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

dustdfg avatar Aug 20 '22 11:08 dustdfg

https://user-images.githubusercontent.com/97330399/185794999-a6299bb1-a708-44ac-8b12-518ad1988f63.mp4

dustdfg avatar Aug 21 '22 14:08 dustdfg

This sounds like an OS-side bug.

Cacodemon345 avatar Aug 23 '22 06:08 Cacodemon345

This sounds like an OS-side bug.

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

dustdfg avatar Aug 23 '22 10:08 dustdfg

would it make sense to apply the fix used here?

https://github.com/exelix11/SysDVR/commit/81ffb43b4ee02f2b1b1926f1107df4213bb013d0

this is from one of the issues that mentions this one

snowkittykira avatar May 11 '24 02:05 snowkittykira

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.

MikuAuahDark avatar Jun 01 '24 01:06 MikuAuahDark

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

slouken avatar Jun 01 '24 15:06 slouken

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

MikuAuahDark avatar Jun 21 '24 02:06 MikuAuahDark