mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-21 02:09:05 +02:00
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) <noreply@anthropic.com>
This commit is contained in:
1 parent
7163bd4b9e
commit
beaae7016f
3 files changed
+5
-21
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user