Skip to content

Commit adf71a4

Browse files
Jonas Thieminclement
authored andcommitted
Bump to SDL2 2.0.10 & make sure to extract .java from SDL2 tarball
1 parent f5dbf21 commit adf71a4

File tree

19 files changed

+106
-5196
lines changed

19 files changed

+106
-5196
lines changed

pythonforandroid/bootstrap.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,23 @@ def name(self):
137137
modname = self.__class__.__module__
138138
return modname.split(".", 2)[-1]
139139

140+
def _copy_in_final_files(self):
141+
if self.name == "sdl2":
142+
# Get the paths for copying SDL2's java source code:
143+
sdl2_recipe = Recipe.get_recipe("sdl2", self.ctx)
144+
sdl2_build_dir = sdl2_recipe.get_jni_dir()
145+
src_dir = join(sdl2_build_dir, "SDL", "android-project",
146+
"app", "src", "main", "java",
147+
"org", "libsdl", "app")
148+
target_dir = join(self.dist_dir, 'src', 'main', 'java', 'org',
149+
'libsdl', 'app')
150+
151+
# Do actual copying:
152+
info('Copying in SDL2 .java files from: ' + str(src_dir))
153+
if not os.path.exists(target_dir):
154+
os.makedirs(target_dir)
155+
copy_files(src_dir, target_dir, override=True)
156+
140157
def prepare_build_dir(self):
141158
'''Ensure that a build dir exists for the recipe. This same single
142159
dir will be used for building all different archs.'''
@@ -159,7 +176,12 @@ def prepare_build_dir(self):
159176
def prepare_dist_dir(self):
160177
ensure_dir(self.dist_dir)
161178

162-
def run_distribute(self):
179+
def assemble_distribution(self):
180+
''' Copies all the files into the distribution (this function is
181+
overridden by the specific bootstrap classes to do this)
182+
and add in the distribution info.
183+
'''
184+
self._copy_in_final_files()
163185
self.distribution.save_info(self.dist_dir)
164186

165187
@classmethod

pythonforandroid/bootstraps/empty/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class EmptyBootstrap(Bootstrap):
88

99
can_be_chosen_automatically = False
1010

11-
def run_distribute(self):
11+
def assemble_distribution(self):
1212
print('empty bootstrap has no distribute')
1313
exit(1)
1414

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SDL2GradleBootstrap(Bootstrap):
1212
set(Bootstrap.recipe_depends).union({'sdl2'})
1313
)
1414

15-
def run_distribute(self):
15+
def assemble_distribution(self):
1616
info_main("# Creating Android project ({})".format(self.name))
1717

1818
arch = self.ctx.archs[0]
@@ -49,7 +49,7 @@ def run_distribute(self):
4949

5050
self.strip_libraries(arch)
5151
self.fry_eggs(site_packages_dir)
52-
super().run_distribute()
52+
super().assemble_distribution()
5353

5454

5555
bootstrap = SDL2GradleBootstrap()

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

Lines changed: 41 additions & 27 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,35 +450,32 @@ public void appConfirmedActive() {
450450
public void considerLoadingScreenRemoval() {
451451
if (loadingScreenRemovalTimer != null)
452452
return;
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() {
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() {
463465
@Override
464466
public void run() {
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-
});
467+
Log.v(TAG, "loading screen timer Runnable() finished.");
468+
PythonActivity activity =
469+
((PythonActivity)PythonActivity.mSingleton);
470+
if (activity != null)
471+
activity.removeLoadingScreen();
475472
}
476-
};
477-
loadingScreenRemovalTimer = new Timer();
478-
loadingScreenRemovalTimer.schedule(removalTask, 5000);
473+
});
479474
}
480-
}
481-
});
475+
};
476+
loadingScreenRemovalTimer = new Timer();
477+
loadingScreenRemovalTimer.schedule(removalTask, 5000);
478+
}
482479
}
483480

484481
public void removeLoadingScreen() {
@@ -589,14 +586,30 @@ protected void onResume() {
589586
if (this.mWakeLock != null) {
590587
this.mWakeLock.acquire();
591588
}
592-
Log.v(TAG, "onResume()");
589+
Log.v(TAG, "onResume(), mSDLThread exists yet: " + (mSDLThread != null));
593590
try {
594591
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+
}
595604
} catch (UnsatisfiedLinkError e) {
596605
// Catch resume while still in loading screen failing to
597606
// 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");
598609
}
599610
considerLoadingScreenRemoval();
611+
Log.v(TAG, "onResume() done in PythonActivity, " +
612+
"mSDLThread exists yet: " + (mSDLThread != null));
600613
}
601614

602615
@Override
@@ -606,6 +619,7 @@ public void onWindowFocusChanged(boolean hasFocus) {
606619
} catch (UnsatisfiedLinkError e) {
607620
// Catch window focus while still in loading screen failing to
608621
// call native function (since it's not yet loaded)
622+
return; // no point in barging further
609623
}
610624
considerLoadingScreenRemoval();
611625
}

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/libsdl/app/HIDDevice.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

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