Skip to content

Instantly share code, notes, and snippets.

@peterjmag
Last active August 12, 2016 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterjmag/eecf0de4bafa19482dd5 to your computer and use it in GitHub Desktop.
Save peterjmag/eecf0de4bafa19482dd5 to your computer and use it in GitHub Desktop.
Some more code from the background in Ex Machina
struct state {
struct wakelock wakelock;
}
init() {
wake_lock_init(&state->wakelock, WAKE_LOCK_SUSPEND, "wakelockname");
}
Before freeing the memory, wake_lock_destroy must be called:
uninit() {
wake_lock_destroy(&state->wakelock);
}
PowerManager pm = (PowerManager)mContext.getSystemService(
Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(
PowerManager.SCREEN_DIM_WAKE_LOCK
| PowerManager.ON_AFTER_RELEASE,
TAG);
wl.acquire();
// ...
wl.release();
@axmachina
Copy link

Good find :)

@rascafr
Copy link

rascafr commented Aug 12, 2016

Well done 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment