Skip to content

Commit

Permalink
Merge pull request #1066 from autosportlabs/sdl2_wakelock
Browse files Browse the repository at this point in the history
implement wakelock for sdl2
  • Loading branch information
inclement authored Jul 2, 2017
2 parents f966541 + 7025e54 commit 1a4a2c3
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ protected void onPostExecute(String result) {

PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);
if ( mActivity.mMetaData.getInt("wakelock") == 1 ) {
mActivity.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
mActivity.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
mActivity.mWakeLock.acquire();
}
if ( mActivity.mMetaData.getInt("surface.transparent") != 0 ) {
Log.v(TAG, "Surface will be transparent.");
Expand Down Expand Up @@ -452,5 +453,27 @@ protected void showLoadingScreen() {
}

}

@Override
protected void onPause() {
// fooabc
if ( this.mWakeLock != null && mWakeLock.isHeld()){
this.mWakeLock.release();
}

Log.v(TAG, "onPause()");
super.onPause();
}

@Override
protected void onResume() {
if ( this.mWakeLock != null){
this.mWakeLock.acquire();
}
Log.v(TAG, "onResume()");
super.onResume();
}



}

0 comments on commit 1a4a2c3

Please sign in to comment.