Skip to content

implement wakelock for sdl2 #1066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not this.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();
}



}