Skip to content

Commit

Permalink
Downgrades to SDL2 2.0.9
Browse files Browse the repository at this point in the history
Actually simply reverted few files:
```sh
git checkout master -- \
    pythonforandroid/recipes/sdl2/__init__.py \
    pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch \
    pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java
```
- fixes kivy#2167
- fixes kivy#2169
  • Loading branch information
AndreMiras committed May 8, 2020
1 parent b6a35e9 commit 04b8f35
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected void onPostExecute(String result) {
mActivity.getPackageName(), PackageManager.GET_META_DATA).metaData;

PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);
if (mActivity.mMetaData.getInt("wakelock") == 1) {
if ( mActivity.mMetaData.getInt("wakelock") == 1 ) {
mActivity.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
mActivity.mWakeLock.acquire();
}
Expand Down Expand Up @@ -450,32 +450,35 @@ public void appConfirmedActive() {
public void considerLoadingScreenRemoval() {
if (loadingScreenRemovalTimer != null)
return;
if (PythonActivity.mSingleton != null &&
mAppConfirmedActive &&
loadingScreenRemovalTimer == null) {
Log.v(TAG, "loading screen timer Runnable() launched.");
// Remove loading screen but with a delay.
// (app can use p4a's android.loadingscreen module to
// do it quicker if it wants to)
TimerTask removalTask = new TimerTask() {
@Override
public void run() {
// post a runnable to the handler
runOnUiThread(new Runnable() {
runOnUiThread(new Runnable() {
public void run() {
if (((PythonActivity)PythonActivity.mSingleton).mAppConfirmedActive &&
loadingScreenRemovalTimer == null) {
// Remove loading screen but with a delay.
// (app can use p4a's android.loadingscreen module to
// do it quicker if it wants to)
// get a handler (call from main thread)
// this will run when timer elapses
TimerTask removalTask = new TimerTask() {
@Override
public void run() {
Log.v(TAG, "loading screen timer Runnable() finished.");
PythonActivity activity =
((PythonActivity)PythonActivity.mSingleton);
if (activity != null)
activity.removeLoadingScreen();
// post a runnable to the handler
runOnUiThread(new Runnable() {
@Override
public void run() {
PythonActivity activity =
((PythonActivity)PythonActivity.mSingleton);
if (activity != null)
activity.removeLoadingScreen();
}
});
}
});
};
loadingScreenRemovalTimer = new Timer();
loadingScreenRemovalTimer.schedule(removalTask, 5000);
}
};
loadingScreenRemovalTimer = new Timer();
loadingScreenRemovalTimer.schedule(removalTask, 5000);
}
}
});
}

public void removeLoadingScreen() {
Expand Down Expand Up @@ -586,30 +589,14 @@ protected void onResume() {
if (this.mWakeLock != null) {
this.mWakeLock.acquire();
}
Log.v(TAG, "onResume(), mSDLThread exists yet: " + (mSDLThread != null));
Log.v(TAG, "onResume()");
try {
super.onResume();
if (mSDLThread == null && !mIsResumedCalled) {
// Ok so SDL2's onStart() usually launches the native code.
// However, this may fail if native libs aren't loaded yet at that point
// (due ot our loading screen) so we may need to manually trigger this,
// otherwise code would only launch by leaving & re-entering the app:
Log.v(TAG, "Loading screen workaround: triggering native resume");
if (mSDLThread == null && mCurrentNativeState == NativeState.RESUMED) {
// Force a state change so SDL2 doesn't just ignore the resume:
mCurrentNativeState = NativeState.PAUSED;
}
resumeNativeThread(); // native resume to call native code
}
} catch (UnsatisfiedLinkError e) {
// Catch resume while still in loading screen failing to
// call native function (since it's not yet loaded)
Log.v(TAG, "failed to call native onResume() because libs " +
"aren't loaded yet. this is expected to happen");
}
considerLoadingScreenRemoval();
Log.v(TAG, "onResume() done in PythonActivity, " +
"mSDLThread exists yet: " + (mSDLThread != null));
}

@Override
Expand All @@ -619,7 +606,6 @@ public void onWindowFocusChanged(boolean hasFocus) {
} catch (UnsatisfiedLinkError e) {
// Catch window focus while still in loading screen failing to
// call native function (since it's not yet loaded)
return; // no point in barging further
}
considerLoadingScreenRemoval();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
--- a/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/src/main/java/org/libsdl/app/SDLActivity.java
@@ -196,6 +196,16 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
@@ -196,6 +196,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
Log.v(TAG, "onCreate()");
super.onCreate(savedInstanceState);

+ SDLActivity.initialize();
+ // So we can call stuff from static callbacks
+ mSingleton = this;
+
+ SDLActivity.initialize();
+ }
+
+ // We don't do this in onCreate because we unpack and load the app data on a thread
Expand All @@ -17,16 +16,6 @@
// Load shared libraries
String errorMsgBrokenLib = "";
try {
@@ -508,7 +508,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}

// Try a transition to resumed state
- if (mNextNativeState == NativeState.RESUMED) {
+ // python-for-android: we delay finishLoad() -> mSurface can be null!
+ if (mNextNativeState == NativeState.RESUMED && mSurface != null) {
if (mSurface.mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
if (mSDLThread == null) {
// This is the entry point to the C app.
@@ -639,7 +648,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
Handler commandHandler = new SDLCommandHandler();

Expand Down Expand Up @@ -58,11 +47,28 @@
// APK expansion files support

/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
@@ -1475,5 +1475,7 @@ class SDLMain implements Runnable {
@@ -1341,14 +1366,13 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
};

public void onSystemUiVisibilityChange(int visibility) {
- if (SDLActivity.mFullscreenModeActive && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
-
+ // SDL2 BUGFIX (see sdl bug #4424 ) - REMOVE WHEN FIXED IN UPSTREAM !!
+ if (SDLActivity.mFullscreenModeActive && ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0)) {
Handler handler = getWindow().getDecorView().getHandler();
if (handler != null) {
handler.removeCallbacks(rehideSystemUi); // Prevent a hide loop.
handler.postDelayed(rehideSystemUi, 2000);
}
-
}
}

@@ -1475,6 +1499,7 @@ class SDLMain implements Runnable {
String[] arguments = SDLActivity.mSingleton.getArguments();

Log.v("SDL", "Running main function " + function + " from library " + library);

+ SDLActivity.mSingleton.appConfirmedActive();
+ Log.v("SDL", "(python-for-android: appConfirmedActive() was called)");
SDLActivity.nativeRunMain(library, function, arguments);

Log.v("SDL", "Finished main function");
6 changes: 3 additions & 3 deletions pythonforandroid/recipes/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


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

dir_name = 'SDL'

Expand Down

0 comments on commit 04b8f35

Please sign in to comment.