8000 Merge pull request #1066 from autosportlabs/sdl2_wakelock · pygame/python-for-android@1a4a2c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a4a2c3

Browse files
authored
Merge pull request kivy#1066 from autosportlabs/sdl2_wakelock
implement wakelock for sdl2
2 parents f966541 + 7025e54 commit 1a4a2c3

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ protected void onPostExecute(String result) {
183183

184184
PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);
185185
if ( mActivity.mMetaData.getInt("wakelock") == 1 ) {
186-
mActivity.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
186+
mActivity.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
187+
mActivity.mWakeLock.acquire();
187188
}
188189
if ( mActivity.mMetaData.getInt("surface.transparent") != 0 ) {
189190
Log.v(TAG, "Surface will be transparent.");
@@ -452,5 +453,27 @@ protected void showLoadingScreen() {
452453
}
453454

454455
}
456+
457+
@Override
458+
protected void onPause() {
459+
// fooabc
460+
if ( this.mWakeLock != null && mWakeLock.isHeld()){
461+
this.mWakeLock.release();
462+
}
463+
464+
Log.v(TAG, "onPause()");
465+
super.onPause();
466+
}
467+
468+
@Override
469+
protected void onResume() {
470+
if ( this.mWakeLock != null){
471+
this.mWakeLock.acquire();
472+
}
473+
Log.v(TAG, "onResume()");
474+
super.onResume();
475+
}
476+
477+
455478

456479
}

0 commit comments

Comments
 (0)
0