Skip to content

Commit 2808130

Browse files
authored
Merge pull request #2180 from AndreMiras/feature/downgrade_sdl2_2.0.9
Downgrades to SDL2 2.0.9
2 parents b6a35e9 + 04b8f35 commit 2808130

File tree

3 files changed

+52
-60
lines changed

3 files changed

+52
-60
lines changed

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ protected void onPostExecute(String result) {
193193
mActivity.getPackageName(), PackageManager.GET_META_DATA).metaData;
194194

195195
PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);
196-
if (mActivity.mMetaData.getInt("wakelock") == 1) {
196+
if ( mActivity.mMetaData.getInt("wakelock") == 1 ) {
197197
mActivity.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
198198
mActivity.mWakeLock.acquire();
199199
}
@@ -450,32 +450,35 @@ public void appConfirmedActive() {
450450
public void considerLoadingScreenRemoval() {
451451
if (loadingScreenRemovalTimer != null)
452452
return;
453-
if (PythonActivity.mSingleton != null &&
454-
mAppConfirmedActive &&
455-
loadingScreenRemovalTimer == null) {
456-
Log.v(TAG, "loading screen timer Runnable() launched.");
457-
// Remove loading screen but with a delay.
458-
// (app can use p4a's android.loadingscreen module to
459-
// do it quicker if it wants to)
460-
TimerTask removalTask = new TimerTask() {
461-
@Override
462-
public void run() {
463-
// post a runnable to the handler
464-
runOnUiThread(new Runnable() {
453+
runOnUiThread(new Runnable() {
454+
public void run() {
455+
if (((PythonActivity)PythonActivity.mSingleton).mAppConfirmedActive &&
456+
loadingScreenRemovalTimer == null) {
457+
// Remove loading screen but with a delay.
458+
// (app can use p4a's android.loadingscreen module to
459+
// do it quicker if it wants to)
460+
// get a handler (call from main thread)
461+
// this will run when timer elapses
462+
TimerTask removalTask = new TimerTask() {
465463
@Override
466464
public void run() {
467-
Log.v(TAG, "loading screen timer Runnable() finished.");
468-
PythonActivity activity =
469-
((PythonActivity)PythonActivity.mSingleton);
470-
if (activity != null)
471-
activity.removeLoadingScreen();
465+
// post a runnable to the handler
466+
runOnUiThread(new Runnable() {
467+
@Override
468+
public void run() {
469+
PythonActivity activity =
470+
((PythonActivity)PythonActivity.mSingleton);
471+
if (activity != null)
472+
activity.removeLoadingScreen();
473+
}
474+
});
472475
}
473-
});
476+
};
477+
loadingScreenRemovalTimer = new Timer();
478+
loadingScreenRemovalTimer.schedule(removalTask, 5000);
474479
}
475-
};
476-
loadingScreenRemovalTimer = new Timer();
477-
loadingScreenRemovalTimer.schedule(removalTask, 5000);
478-
}
480+
}
481+
});
479482
}
480483

481484
public void removeLoadingScreen() {
@@ -586,30 +589,14 @@ protected void onResume() {
586589
if (this.mWakeLock != null) {
587590
this.mWakeLock.acquire();
588591
}
589-
Log.v(TAG, "onResume(), mSDLThread exists yet: " + (mSDLThread != null));
592+
Log.v(TAG, "onResume()");
590593
try {
591594
super.onResume();
592-
if (mSDLThread == null && !mIsResumedCalled) {
593-
// Ok so SDL2's onStart() usually launches the native code.
594-
// However, this may fail if native libs aren't loaded yet at that point
595-
// (due ot our loading screen) so we may need to manually trigger this,
596-
// otherwise code would only launch by leaving & re-entering the app:
597-
Log.v(TAG, "Loading screen workaround: triggering native resume");
598-
if (mSDLThread == null && mCurrentNativeState == NativeState.RESUMED) {
599-
// Force a state change so SDL2 doesn't just ignore the resume:
600-
mCurrentNativeState = NativeState.PAUSED;
601-
}
602-
resumeNativeThread(); // native resume to call native code
603-
}
604595
} catch (UnsatisfiedLinkError e) {
605596
// Catch resume while still in loading screen failing to
606597
// call native function (since it's not yet loaded)
607-
Log.v(TAG, "failed to call native onResume() because libs " +
608-
"aren't loaded yet. this is expected to happen");
609598
}
610599
considerLoadingScreenRemoval();
611-
Log.v(TAG, "onResume() done in PythonActivity, " +
612-
"mSDLThread exists yet: " + (mSDLThread != null));
613600
}
614601

615602
@Override
@@ -619,7 +606,6 @@ public void onWindowFocusChanged(boolean hasFocus) {
619606
} catch (UnsatisfiedLinkError e) {
620607
// Catch window focus while still in loading screen failing to
621608
// call native function (since it's not yet loaded)
622-
return; // no point in barging further
623609
}
624610
considerLoadingScreenRemoval();
625611
}

pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
--- a/src/main/java/org/libsdl/app/SDLActivity.java
22
+++ b/src/main/java/org/libsdl/app/SDLActivity.java
3-
@@ -196,6 +196,16 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
3+
@@ -196,6 +196,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
44
Log.v(TAG, "onCreate()");
55
super.onCreate(savedInstanceState);
66

7+
+ SDLActivity.initialize();
78
+ // So we can call stuff from static callbacks
89
+ mSingleton = this;
9-
+
10-
+ SDLActivity.initialize();
1110
+ }
1211
+
1312
+ // We don't do this in onCreate because we unpack and load the app data on a thread
@@ -17,16 +16,6 @@
1716
// Load shared libraries
1817
String errorMsgBrokenLib = "";
1918
try {
20-
@@ -508,7 +508,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
21-
}
22-
23-
// Try a transition to resumed state
24-
- if (mNextNativeState == NativeState.RESUMED) {
25-
+ // python-for-android: we delay finishLoad() -> mSurface can be null!
26-
+ if (mNextNativeState == NativeState.RESUMED && mSurface != null) {
27-
if (mSurface.mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
28-
if (mSDLThread == null) {
29-
// This is the entry point to the C app.
3019
@@ -639,7 +648,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
3120
Handler commandHandler = new SDLCommandHandler();
3221

@@ -58,11 +47,28 @@
5847
// APK expansion files support
5948

6049
/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
61-
@@ -1475,5 +1475,7 @@ class SDLMain implements Runnable {
50+
@@ -1341,14 +1366,13 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
51+
};
52+
53+
public void onSystemUiVisibilityChange(int visibility) {
54+
- if (SDLActivity.mFullscreenModeActive && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
55+
-
56+
+ // SDL2 BUGFIX (see sdl bug #4424 ) - REMOVE WHEN FIXED IN UPSTREAM !!
57+
+ if (SDLActivity.mFullscreenModeActive && ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0)) {
58+
Handler handler = getWindow().getDecorView().getHandler();
59+
if (handler != null) {
60+
handler.removeCallbacks(rehideSystemUi); // Prevent a hide loop.
61+
handler.postDelayed(rehideSystemUi, 2000);
62+
}
63+
-
64+
}
65+
}
66+
67+
@@ -1475,6 +1499,7 @@ class SDLMain implements Runnable {
68+
String[] arguments = SDLActivity.mSingleton.getArguments();
69+
6270
Log.v("SDL", "Running main function " + function + " from library " + library);
63-
6471
+ SDLActivity.mSingleton.appConfirmedActive();
65-
+ Log.v("SDL", "(python-for-android: appConfirmedActive() was called)");
6672
SDLActivity.nativeRunMain(library, function, arguments);
6773

6874
Log.v("SDL", "Finished main function");

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
class LibSDL2Recipe(BootstrapNDKRecipe):
7-
version = "2.0.10"
8-
url = "https://www.libsdl.org/release/SDL2-{version}.zip"
9-
md5sum = "6b2e9a4a2faba4ff277062cf669724f4"
7+
version = "2.0.9"
8+
url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz"
9+
md5sum = 'f2ecfba915c54f7200f504d8b48a5dfe'
1010

1111
dir_name = 'SDL'
1212

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy