From beaae7016ff9b91d62f191ba1ff93a65d4ef0d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 16 Oct 2026 18:07:51 +0200 Subject: [PATCH] Android: Keep the orientation setting on large Android 17 screens Android 17 ignores fixed orientations on sw600dp+ displays, but exempts games, and we declare appCategory="game". Tested on an Android 17 tablet emulator: with the category, Portrait is honored (letterboxed); without it, the system logs "Ignoring requested fixed orientation". So stop hiding the rotation setting there, and drop the smallestScreenWidthDp plumbing that only existed for that check. Co-Authored-By: Claude Opus 5.5 (1M context) --- android/jni/app-android.cpp | 12 ++---------- android/src/org/ppsspp/ppsspp/NativeApp.java | 2 +- android/src/org/ppsspp/ppsspp/PpssppActivity.java | 12 ++---------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 00b1f1f806..8bd62c41ea 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -134,7 +134,6 @@ static int optimalSampleRate = 0; static int sampleRate = 0; static int framesPerBuffer = 0; static int androidVersion; -static int smallestScreenWidthDp; static int deviceType; // This is the ACTUAL display size, not the hardware scaled display size. @@ -457,10 +456,7 @@ bool System_GetPropertyBool(SystemProperty prop) { case SYSPROP_DISPLAY_HAS_CAMERA_CUTOUT: return g_hasCameraCutout; case SYSPROP_CAN_RESTRICT_ORIENTATION: - // On Android 17+, large displays (sw600dp+) ignore orientation restrictions. - if (androidVersion >= 37 && smallestScreenWidthDp >= 600) { - return false; - } + // Android 17+ ignores orientation requests on large screens, but not from games (appCategory="game"). return true; #ifndef HTTPS_NOT_AVAILABLE case SYSPROP_SUPPORTS_HTTPS: @@ -650,7 +646,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init (JNIEnv * env, jclass, jstring jmodel, jint jdeviceType, jstring jlangRegion, jstring japkpath, jstring jdataDir, jstring jexternalStorageDir, jstring jexternalFilesDir, jstring jNativeLibDir, jstring jadditionalStorageDirs, jstring jcacheDir, jstring jshortcutParam, jstring jInstallerName, - jint jAndroidVersion, jstring jboard, jint jSmallestScreenWidthDp) { + jint jAndroidVersion, jstring jboard) { SetCurrentThreadName("androidInit"); // Makes sure we get early permission grants. @@ -662,7 +658,6 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init renderer_inited = false; exitRenderLoop = false; androidVersion = jAndroidVersion; - smallestScreenWidthDp = jSmallestScreenWidthDp; deviceType = jdeviceType; Path apkPath(GetJavaString(env, japkpath)); @@ -1318,9 +1313,6 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNI System_PostUIMessage(UIMessage::PERMISSION_GRANTED, prm); } else if (msg == "sustained_perf_supported") { sustainedPerfSupported = true; - } else if (msg == "smallestScreenWidthDp") { - // Changes on fold/unfold. Decides SYSPROP_CAN_RESTRICT_ORIENTATION. - smallestScreenWidthDp = (int)parseLong(prm); } else if (msg == "safe_insets") { // INFO_LOG(Log::System, "Got insets: %s", prm.c_str()); // We don't bother with supporting exact rectangular regions. Safe insets are good enough. diff --git a/android/src/org/ppsspp/ppsspp/NativeApp.java b/android/src/org/ppsspp/ppsspp/NativeApp.java index 3afe2123f7..f330718753 100644 --- a/android/src/org/ppsspp/ppsspp/NativeApp.java +++ b/android/src/org/ppsspp/ppsspp/NativeApp.java @@ -27,7 +27,7 @@ public class NativeApp { public static final int RESULT_ERROR_ACTIVITY_NOT_FOUND = 1; public static final int RESULT_ERROR_OTHER_ACTIVITY_ERROR = 2; - public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalStorageDir, String extFilesDir, String nativeLibDir, String additionalStorageDirs, String cacheDir, String shortcutParam, String installerName, int androidVersion, String board, int smallestScreenWidthDp); + public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalStorageDir, String extFilesDir, String nativeLibDir, String additionalStorageDirs, String cacheDir, String shortcutParam, String installerName, int androidVersion, String board); public static native void audioInit(); public static native void audioShutdown(); public static native void audioConfig(int optimalFramesPerBuffer, int optimalSampleRate); diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index 5ba5838a9a..9c1046874e 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -483,9 +483,8 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList PackageManager packageManager = getPackageManager(); String installerName = getInstallerName(packageManager); - int smallestScreenWidthDp = getResources().getConfiguration().smallestScreenWidthDp; NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate); - NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, extStorageDir, externalFilesDir, nativeLibDir, additionalStorageDirs, cacheDir, shortcut, installerName, Build.VERSION.SDK_INT, Build.BOARD, smallestScreenWidthDp); + NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, extStorageDir, externalFilesDir, nativeLibDir, additionalStorageDirs, cacheDir, shortcut, installerName, Build.VERSION.SDK_INT, Build.BOARD); sendInitialGrants(); @@ -555,11 +554,6 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList @SuppressLint("SourceLockedOrientationActivity") private void updateScreenRotation(String cause) { - if (Build.VERSION.SDK_INT >= 37 && getResources().getConfiguration().smallestScreenWidthDp >= 600) { - // Android 17+ on large screens (sw600dp+) ignores orientation requests to push for adaptive apps. - // If we try anyway, it's just a waste of time and might cause weirdness. - return; - } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (isInMultiWindowMode()) { // Do not try to enforce rotation! This can result in re-init loops. @@ -1176,9 +1170,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList if (m_hasNoNativeBinary) { return; } - // The surface size change that comes with it is what actually updates the native side, except - // for this, which the native side was told once at init. Changes on fold/unfold. - NativeApp.sendMessageFromJava("smallestScreenWidthDp", String.valueOf(newConfig.smallestScreenWidthDp)); + // The surface size change that comes with it is what actually updates the native side. // This re-measures the display, so the density check below sees the new value. updateSystemUiVisibility(); // A density change doesn't resize the surface, so it needs separate handling.